static TestResult * tcase_run_checked_setup (SRunner *sr, TCase *tc) { TestResult *tr = NULL; List *l; Fixture *f; enum fork_status fstat = srunner_fork_status(sr); l = tc->ch_sflst; if (fstat == CK_FORK) { send_ctx_info(CK_CTX_SETUP); } for (list_front(l); !list_at_end(l); list_advance(l)) { if (fstat == CK_NOFORK) { send_ctx_info(CK_CTX_SETUP); } f = list_val(l); f->fun(); /* Stop the setup and return the failure if nofork mode. */ if (fstat == CK_NOFORK) { tr = receive_result_info_nofork (tc->name, "checked_setup", 0); if (tr->rtype != CK_PASS) { break; } free(tr->file); free(tr->msg); free(tr); tr = NULL; } } return tr; }
static int srunner_run_unchecked_setup (SRunner *sr, TCase *tc) { TestResult *tr; List *l; Fixture *f; int rval = 1; set_fork_status(CK_NOFORK); l = tc->unch_sflst; for (list_front(l); !list_at_end(l); list_advance(l)) { send_ctx_info(CK_CTX_SETUP); f = list_val(l); f->fun(); tr = receive_result_info_nofork (tc->name, "unchecked_setup", 0); if (tr->rtype != CK_PASS) { srunner_add_failure(sr, tr); rval = 0; break; } free(tr->file); free(tr->msg); free(tr); } set_fork_status(srunner_fork_status(sr)); return rval; }
static TestResult *tcase_run_tfun_nofork (SRunner *sr, TCase *tc, TF *tfun, int i) { TestResult *tr; tr = tcase_run_checked_setup(sr, tc); if (tr == NULL) { tfun->fn(i); tcase_run_checked_teardown(tc); return receive_result_info_nofork(tc->name, tfun->name, i); } return tr; }
static TestResult * tcase_run_tfun_nofork (SRunner * sr, TCase * tc, TF * tfun, int i) { TestResult *tr; struct timespec ts_start = { 0, 0 }, ts_end = { 0, 0}; tr = tcase_run_checked_setup (sr, tc); if (tr == NULL) { clock_gettime (check_get_clockid (), &ts_start); if (0 == setjmp (error_jmp_buffer)) { tfun->fn (i); } clock_gettime (check_get_clockid (), &ts_end); tcase_run_checked_teardown (tc); return receive_result_info_nofork (tc->name, tfun->name, i, DIFF_IN_USEC (ts_start, ts_end)); } return tr; }
static TestResult * srunner_run_setup (List * fixture_list, enum fork_status fork_usage, const char *test_name, const char *setup_name) { TestResult *tr = NULL; Fixture *setup_fixture; if (fork_usage == CK_FORK) { send_ctx_info (CK_CTX_SETUP); } for (check_list_front (fixture_list); !check_list_at_end (fixture_list); check_list_advance (fixture_list)) { setup_fixture = (Fixture *) check_list_val (fixture_list); if (fork_usage == CK_NOFORK) { send_ctx_info (CK_CTX_SETUP); if (0 == setjmp (error_jmp_buffer)) { setup_fixture->fun (); } /* Stop the setup and return the failure in nofork mode. */ tr = receive_result_info_nofork (test_name, setup_name, 0, -1); if (tr->rtype != CK_PASS) { break; } free (tr->file); free (tr->msg); free (tr); tr = NULL; } else { setup_fixture->fun (); } } return tr; }