butil_unittest_main.cpp 858 B

1234567891011121314151617181920212223242526272829
  1. // Copyright (c) 2014 Baidu, Inc.
  2. #include <sys/resource.h>
  3. #include <gtest/gtest.h>
  4. #include <gflags/gflags.h>
  5. #include "butil/base_switches.h"
  6. #include "butil/at_exit.h"
  7. #include "test/multiprocess_func_list.h"
  8. // Disable coredumps by default to avoid generating a lot of coredumps
  9. // after running death tests.
  10. DEFINE_bool(disable_coredump, true, "Never core dump");
  11. int main(int argc, char** argv) {
  12. butil::AtExitManager at_exit;
  13. testing::InitGoogleTest(&argc, argv);
  14. google::ParseCommandLineFlags(&argc, &argv, true);
  15. if (FLAGS_disable_coredump) {
  16. rlimit core_limit;
  17. core_limit.rlim_cur = 0;
  18. core_limit.rlim_max = 0;
  19. setrlimit(RLIMIT_CORE, &core_limit);
  20. }
  21. #if !BRPC_WITH_GLOG
  22. CHECK(!google::SetCommandLineOption("crash_on_fatal_log", "true").empty());
  23. #endif
  24. return RUN_ALL_TESTS();
  25. }