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.

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.
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(fail_with_core_dump, EXPECT_SIGNAL_DEATH(SIGABRT))
     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"  --------------------------------------------------------------
     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