diff --git a/src/base/test/task_test_util.h b/src/base/test/task_test_util.h index dd9d95b1552..045b674b953 100644 --- a/src/base/test/task_test_util.h +++ b/src/base/test/task_test_util.h @@ -394,6 +394,18 @@ static inline unsigned long long int task_util_retry_count() { setrlimit(RLIMIT_CORE, ¤t_core_limit); \ } while (false) +#define TASK_UTIL_EXPECT_EXIT(statement, type, regex) \ + do { \ + rlimit current_core_limit; \ + getrlimit(RLIMIT_CORE, ¤t_core_limit); \ + rlimit new_core_limit; \ + new_core_limit.rlim_cur = 0; \ + new_core_limit.rlim_max = 0; \ + setrlimit(RLIMIT_CORE, &new_core_limit); \ + EXPECT_EXIT(statement, type, regex); \ + setrlimit(RLIMIT_CORE, ¤t_core_limit); \ + } while (false) + #define TASK_UTIL_ASSERT_EQ(expected, actual) \ do { \ diff --git a/src/io/test/event_manager_test.cc b/src/io/test/event_manager_test.cc index 3018e45972a..49efc539177 100644 --- a/src/io/test/event_manager_test.cc +++ b/src/io/test/event_manager_test.cc @@ -29,14 +29,14 @@ typedef EventManagerTest EventManagerDeathTest; TEST_F(EventManagerDeathTest, Poll) { usleep(10000); - EXPECT_EXIT(evm_.Poll(), - ::testing::KilledBySignal(SIGABRT), ".*Poll.*"); + TASK_UTIL_EXPECT_EXIT(evm_.Poll(), ::testing::KilledBySignal(SIGABRT), + ".*Poll.*"); } TEST_F(EventManagerDeathTest, RunOnce) { usleep(10000); - EXPECT_EXIT(evm_.RunOnce(), - ::testing::KilledBySignal(SIGABRT), ".*RunOnce.*"); + TASK_UTIL_EXPECT_EXIT(evm_.RunOnce(), ::testing::KilledBySignal(SIGABRT), + ".*RunOnce.*"); } int main(int argc, char **argv) {