From 2acc00efa6761129f02b73fcd69fe78e0fb3886b Mon Sep 17 00:00:00 2001 From: Ananth Suryanarayana Date: Thu, 3 Nov 2016 16:35:47 -0700 Subject: [PATCH] Avoid core-file from getting generated during EXPECT_DEATH Change-Id: Ie474d65ec4cbb509857fef0c90147aadb2f50b12 Closes-Bug: #1639082 --- src/base/test/task_test_util.h | 12 ++++++++++++ src/io/test/event_manager_test.cc | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) 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) {