Skip to content

Commit

Permalink
Avoid core-file from getting generated during EXPECT_DEATH
Browse files Browse the repository at this point in the history
Change-Id: Ie474d65ec4cbb509857fef0c90147aadb2f50b12
Closes-Bug: #1639082
  • Loading branch information
ananth-at-camphor-networks committed Nov 3, 2016
1 parent a638f7c commit 2acc00e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions src/base/test/task_test_util.h
Expand Up @@ -394,6 +394,18 @@ static inline unsigned long long int task_util_retry_count() {
setrlimit(RLIMIT_CORE, &current_core_limit); \
} while (false)

#define TASK_UTIL_EXPECT_EXIT(statement, type, regex) \
do { \
rlimit current_core_limit; \
getrlimit(RLIMIT_CORE, &current_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, &current_core_limit); \
} while (false)


#define TASK_UTIL_ASSERT_EQ(expected, actual) \
do { \
Expand Down
8 changes: 4 additions & 4 deletions src/io/test/event_manager_test.cc
Expand Up @@ -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) {
Expand Down

0 comments on commit 2acc00e

Please sign in to comment.