| the Compartmented Robust Posix C++ Unit Test system | hosted by |
|---|
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)
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/crpcutjdsOrT/fail_with_core_dump is not empty!!
phase="running" --------------------------------------------------------------
Died with core dump
-------------------------------------------------------------------------------
===============================================================================
Files remain under /tmp/crpcutjdsOrT
Total 2 test cases selected
UNTESTED : 0
PASSED : 1
FAILED : 1