Exemplo n.º 1
0
static void *run_test_from_thread (void *arg) {
        struct run_args *run_args = arg;
	
        pthread_detach(pthread_self());

	run_test0(run_args);

        pthread_mutex_lock(&test_lock);
        tests_running_cnt--;
        pthread_mutex_unlock(&test_lock);

        free(run_args);

        return NULL;
}
Exemplo n.º 2
0
static int run_test_from_thread (void *arg) {
        struct run_args *run_args = arg;

	thrd_detach(thrd_current());

	run_test0(run_args);

        TEST_LOCK();
        tests_running_cnt--;
        TEST_UNLOCK();

        free(run_args);

        return 0;
}
Exemplo n.º 3
0
static int run_test (const char *testname,
                     int (*test_main) (int, char **),
                     int argc, char **argv) {
        int r;

        if (tests_run_in_parallel) {
#ifdef _MSC_VER
                TEST_FAIL("Parallel runs not supported on this platform, yet\n");
#else
                pthread_t thr;
                struct run_args *run_args = calloc(1, sizeof(*run_args));
                run_args->testname = testname;
                run_args->test_main = test_main;
                run_args->argc = argc;
                run_args->argv = argv;

                pthread_mutex_lock(&test_lock);
                tests_running_cnt++;
                pthread_mutex_unlock(&test_lock);

                r = pthread_create(&thr, NULL, run_test_from_thread, run_args);
                if (r != 0) {
                        pthread_mutex_lock(&test_lock);
                        tests_running_cnt--;
                        pthread_mutex_unlock(&test_lock);

                        TEST_FAIL("Failed to start thread for test %s: %s\n",
                                  testname, strerror(r));
                }
#endif
        } else {
		struct run_args run_args = { .testname = testname,
					     .test_main = test_main,
					     .argc = argc,
					     .argv = argv };
		
		tests_running_cnt++;
		r =  run_test0(&run_args);
		tests_running_cnt--;
		
        /* Wait for everything to be cleaned up since broker
         * destroys are handled in its own thread. */
        test_wait_exit(5);

		test_curr = NULL;
        }
        return r;
}