This example demonstrates testcoe's crash handling capabilities, showing how it detects crashes and provides detailed stack traces.
main.cpp- Main program that initializes testcoe and runs the testscrash_tests.cpp- Various tests demonstrating different types of crashes
# Build using CMake
mkdir -p build
cd build
cmake ..
cmake --build .By default, all crash-causing tests are skipped to prevent unintentional crashes:
# Run the example with all tests (non-crashing)
./examples/crash/crash_exampleTo run a specific crash test, use the Google Test filter mechanism:
# Run only the segmentation fault test
./examples/crash/crash_example --gtest_filter=CrashTests.SegmentationFaultOr use the provided CMake targets:
# Run only the divide by zero test
cmake --build . --target run_crash_example_DivideByZeroSegmentationFault- Demonstrates handling of null pointer dereferenceDivideByZero- Demonstrates handling of division by zeroAbort- Demonstrates handling of program abortStackOverflow- Demonstrates handling of stack overflowOutOfBounds- Demonstrates handling of out-of-bounds accessStreamRedirection- Demonstrates handling of crashes with redirected streams
To enable a crash test, edit crash_tests.cpp and:
- Comment out the
GTEST_SKIP()line in the test you want to run - Uncomment the crash-causing code
- testcoe catches and reports various types of crashes
- When a crash occurs, testcoe:
- Displays the type of signal that occurred
- Shows a detailed stack trace
- Provides helpful debugging information
- testcoe restores output streams even when a crash occurs with redirected streams