| the Compartmented Robust Posix C++ Unit Test system |
|
|---|
A test modifier which states that the test shall not dump core, no matter what happens.
Used in: The modifier list of a test.
See TEST(name, ...)
Prevent the test process from dumping core. This can be useful in
situations where a core dump is expected, for example when verifying
that an assert(expr) traps.
![]() | Note |
|---|---|
The NO_CORE_FILE modifier uses
setrlimit(RLIMIT_CORE,
0) to prevent the core dump. Calling
setrlimit(RLIMIT_CORE,
n) inside a test defeats the purpose
of the NO_CORE_FILE modifier.
|
![]() | Tip |
|---|---|
EXPECT_SIGNAL_DEATH(signo, action?)
is useful together with
NO_CORE_FILE to verify
that assert(expr) traps.
|
Example: The test program
#include <crpcut.hpp>
extern "C"
{
#include <signal.h>
}
TEST(pass_sigabort, EXPECT_SIGNAL_DEATH(SIGABRT), NO_CORE_FILE)
{
abort();
}
TEST(fail_with_core_dump, EXPECT_SIGNAL_DEATH(SIGABRT))
{
abort();
}
int main(int argc, char *argv[])
{
return crpcut::run(argc, argv);
}
reports one failed test, due to a left-behind core file:
FAILED!: fail_with_core_dump
/tmp/crpcutjmjOnL/fail_with_core_dump is not empty!
phase="running" --------------------------------------------------------------
samples/no_core.cpp:40
Died with core dump
-------------------------------------------------------------------------------
===============================================================================
Files remain under /tmp/crpcutjmjOnL
2 test cases selected
Sum Critical Non-critical
PASSED : 1 1 0
FAILED : 1 1 0