END_TEST START_TEST(test_check_failure_lnos) { int i; int line_no; int passed = 0; TestResult *tr; for (i = 0; i < sub_ntests; i++) { if (master_tests[i].failure_type == CK_PASS) { passed++; continue; } fail_if(i - passed > sub_nfailed, NULL); tr = tr_fail_array[i - passed]; fail_unless(tr != NULL, NULL); line_no = master_tests_lineno[i]; if (line_no > 0 && tr_lno(tr) != line_no) { char *emsg = malloc(MAXSTR); snprintf(emsg, MAXSTR, "For test %d: Expected lno %d, got %d", i, line_no, tr_lno(tr)); fail(emsg); free(emsg); } } }
END_TEST START_TEST(test_send_test_error) { TestResult *tr; setup_messaging(); send_ctx_info(CK_CTX_SETUP); send_loc_info("abc123.c", 10); send_ctx_info(CK_CTX_TEST); send_loc_info("abc124.c", 22); send_loc_info("abc125.c", 25); tr = receive_test_result(1); teardown_messaging(); ck_assert_msg (tr != NULL, "No test result received"); ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST, "Bad CTX received"); ck_assert_msg (strcmp(tr_lfile(tr), "abc125.c") == 0, "Bad loc file received"); ck_assert_msg (tr_lno(tr) == 25, "Bad loc line received"); if (tr != NULL) tr_free(tr); }
END_TEST START_TEST(test_send_big) { TestResult *tr; int i; setup_messaging(); send_ctx_info(CK_CTX_SETUP); send_loc_info("abc123.c", 10); for (i = 0; i < 10000; i++) { send_ctx_info(CK_CTX_TEST); send_loc_info("abc124.c", i); } tr = receive_test_result(0); teardown_messaging(); ck_assert_msg (tr != NULL, "No test result received"); ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST, "Bad CTX received"); ck_assert_msg (strcmp(tr_lfile(tr), "abc124.c") == 0, "Bad loc file received"); ck_assert_msg (tr_lno(tr) == i -1, "Bad loc line received"); if (tr != NULL) tr_free(tr); }
END_TEST START_TEST(test_check_failure_lnos) { int i; int line_no; int passed = 0; int failed; TestResult *tr; /* Create list of line numbers where failures occurred */ rewind(line_num_failures); for (i = 0; i < sub_ntests; i++) { if (master_tests[i].failure_type == CK_PASS) { passed++; continue; } failed = i - passed; ck_assert_msg(i - passed <= sub_nfailed, NULL); tr = tr_fail_array[failed]; ck_assert_msg(tr != NULL, NULL); line_no = get_next_failure_line_num(line_num_failures); if(line_no == -1) { ck_abort_msg("Did not find the %dth failure line number for suite %s, msg %s", (failed+1), tr_tcname(tr), tr_msg(tr)); } if (line_no > 0 && tr_lno(tr) != line_no) { ck_abort_msg("For test %d (failure %d): Expected lno %d, got %d for suite %s, msg %s", i, failed, line_no, tr_lno(tr), tr_tcname(tr), tr_msg(tr)); } } /* At this point, there should be no remaining failures */ line_no = get_next_failure_line_num(line_num_failures); ck_assert_msg(line_no == -1, "No more failure line numbers expected, but found %d", line_no); }