Question

I get an error: unknown location(0): fatal error in "suite_1_test_1": child has exited; pid: 5817; uid: 0; exit value: 255

Inside suite_1_test_1 I run a program A with execvp() (after fork()), which may be exit with an error code that is not 0. this error code indicates what happened to program A.

The problem is that, if I get this fatal error, I can't handle the exit() value, and the BOOST TEST gets out immediately.

Can I somehow turn it off for a moment?

Thanks

Was it helpful?

Solution

Well, it is possible to do so:

boost::unit_test case fails because a child process exits with nonzero

just do #define BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE before the #define BOOST_TEST_MODULE aot_test_module in the main()

When using shared libraries, run with command line option --catch_system_errors=no or export BOOST_TEST_CATCH_SYSTEM_ERRORS=“no”.

OTHER TIPS

It seems that boost registers signal handlers or other stuff, that still catch errors from the forked (and overridden) process. You will have a hard time "unhooking" the test framework from that child process.

However, unit test frameworks are seldom meant to be used together with the spawning of child processes, so I would just not use fork and exec* inside Boost.Test. Factor these calls out of the units you are testing. After all, a process is not a signle unit, it's more a whole component. I guess you will not have many of those subprocesses, so it should not hurt too much to test the collaboration of those processes with another framework or just a simple script.

As I understand execvp() replaces your test program. So Boost.Test is not runing any longer. It only returns in case of failour. I would not use it in this context with Boost.Test.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top