BUG: https://open.cryptomilk.org/issues/26
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
<a href="https://lwn.net/Articles/558106/">Learn more ...</a>
+@section main-threads Threading
+
+cmocka is not thread safe and it is not the goal of it to be it. However if
+you use cmocka for writing tests in an application which uses threads, you
+can set the following envionment variable:
+
+<pre>
+ CMOCKA_TEST_ABORT='1' ./my_threading_test
+</pre>
+
+With this environment variable set to '1', cmocka will call <tt>abort()</tt> if
+a test fails. Else it is likely that you will run into deadlocks with mutexes
+or other funny errors.
+
*/
/* Exit the currently executing test. */
-static void exit_test(const int quit_application) {
- if (global_running_test) {
+static void exit_test(const int quit_application)
+{
+ const char *abort_test = getenv("CMOCKA_TEST_ABORT");
+
+ if (abort_test != NULL && abort_test[0] == '1') {
+ abort();
+ } else if (global_running_test) {
longjmp(global_run_test_env, 1);
} else if (quit_application) {
exit(-1);