void check_list_apply (List *lp, void (*fp) (void *)) { if (lp == NULL || fp == NULL) return; for (check_list_front(lp); !check_list_at_end(lp); check_list_advance(lp)) fp (check_list_val(lp)); }
static void suite_free (Suite *s) { List *l; if (s == NULL) return; l = s->tclst; for (check_list_front(l); !check_list_at_end(l); check_list_advance (l)) { tcase_free (check_list_val(l)); } check_list_free (s->tclst); free(s); }
static void srunner_send_evt(SRunner * sr, void *obj, enum cl_event evt) { List *l; Log *lg; l = sr->loglst; for(check_list_front(l); !check_list_at_end(l); check_list_advance(l)) { lg = (Log *)check_list_val(l); fflush(lg->lfile); lg->lfun(sr, lg->lfile, lg->mode, obj, evt); fflush(lg->lfile); } }
static void srunner_iterate_suites (SRunner * sr, const char *sname, const char *tcname, enum print_output CK_ATTRIBUTE_UNUSED print_mode) { List *slst; List *tcl; TCase *tc; slst = sr->slst; for (check_list_front (slst); !check_list_at_end (slst); check_list_advance (slst)) { Suite *s = (Suite *) check_list_val (slst); if (((sname != NULL) && (strcmp (sname, s->name) != 0)) || ((tcname != NULL) && (!suite_tcase (s, tcname)))) continue; log_suite_start (sr, s); tcl = s->tclst; for (check_list_front (tcl); !check_list_at_end (tcl); check_list_advance (tcl)) { tc = (TCase *) check_list_val (tcl); if ((tcname != NULL) && (strcmp (tcname, tc->name) != 0)) { continue; } srunner_run_tcase (sr, tc); } log_suite_end (sr, s); } }
int suite_tcase (Suite *s, const char *tcname) { List *l; TCase *tc; if (s == NULL) return 0; l = s->tclst; for (check_list_front (l); !check_list_at_end (l); check_list_advance (l)) { tc = check_list_val (l); if (strcmp (tcname, tc->name) == 0) return 1; } return 0; }
static void srunner_fprint_results (FILE *file, SRunner *sr, enum print_output print_mode) { List *resultlst; #if ENABLE_SUBUNIT if (print_mode == CK_SUBUNIT) return; #endif resultlst = sr->resultlst; for (check_list_front(resultlst); !check_list_at_end(resultlst); check_list_advance(resultlst)) { TestResult *tr = check_list_val(resultlst); tr_fprint (file, tr, print_mode); } return; }
static void srunner_iterate_tcase_tfuns (SRunner * sr, TCase * tc) { List *tfl; TF *tfun; TestResult *tr = NULL; tfl = tc->tflst; for (check_list_front (tfl); !check_list_at_end (tfl); check_list_advance (tfl)) { int i; tfun = (TF *) check_list_val (tfl); for (i = tfun->loop_start; i < tfun->loop_end; i++) { log_test_start (sr, tc, tfun); switch (srunner_fork_status (sr)) { case CK_FORK: #if defined(HAVE_FORK) && HAVE_FORK==1 tr = tcase_run_tfun_fork (sr, tc, tfun, i); #else /* HAVE_FORK */ eprintf ("This version does not support fork", __FILE__, __LINE__); #endif /* HAVE_FORK */ break; case CK_NOFORK: tr = tcase_run_tfun_nofork (sr, tc, tfun, i); break; case CK_FORK_GETENV: default: eprintf ("Bad fork status in SRunner", __FILE__, __LINE__); } if (NULL != tr) { srunner_add_failure (sr, tr); log_test_end (sr, tr); } } } }
static void srunner_run_teardown (List * fixture_list, enum fork_status fork_usage) { Fixture *fixture; for (check_list_front (fixture_list); !check_list_at_end (fixture_list); check_list_advance (fixture_list)) { fixture = (Fixture *) check_list_val (fixture_list); send_ctx_info (CK_CTX_TEARDOWN); if (fork_usage == CK_NOFORK) { if (0 == setjmp (error_jmp_buffer)) { fixture->fun (); } else { /* Abort the remaining teardowns */ break; } } else { fixture->fun (); } } }
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; }