From 3fc746e07a40a2d82853a6f2a03dfe57cc1f8894 Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Fri, 17 Aug 2018 12:12:22 -0500 Subject: [PATCH 1/7] Ignore ctags file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5322588a..bd7cc3fa 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.autosave *.swp *.swap +/tags # Generated binaries *.o From d03714b63f6ebe3d9f0b71ab59b40f847215f0d3 Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Fri, 17 Aug 2018 12:22:15 -0500 Subject: [PATCH 2/7] Replace tabs with 8 spaces --- src/check_run.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/check_run.c b/src/check_run.c index 7e212e02..b84d2cdf 100644 --- a/src/check_run.c +++ b/src/check_run.c @@ -60,8 +60,8 @@ static void srunner_run_init(SRunner * sr, enum print_output print_mode); static void srunner_run_end(SRunner * sr, enum print_output print_mode); static void srunner_iterate_suites(SRunner * sr, const char *sname, const char *tcname, - const char *include_tags, - const char *exclude_tags, + const char *include_tags, + const char *exclude_tags, enum print_output print_mode); static void srunner_iterate_tcase_tfuns(SRunner * sr, TCase * tc); static void srunner_add_failure(SRunner * sr, TestResult * tf); @@ -162,8 +162,8 @@ static void srunner_run_end(SRunner * sr, static void srunner_iterate_suites(SRunner * sr, const char *sname, const char *tcname, - const char *include_tags, - const char *exclude_tags, + const char *include_tags, + const char *exclude_tags, enum print_output CK_ATTRIBUTE_UNUSED print_mode) { @@ -200,20 +200,20 @@ static void srunner_iterate_suites(SRunner * sr, { continue; } - if (include_tags != NULL) - { - if (!tcase_matching_tag(tc, include_tag_lst)) - { - continue; - } - } - if (exclude_tags != NULL) - { - if (tcase_matching_tag(tc, exclude_tag_lst)) - { - continue; - } - } + if (include_tags != NULL) + { + if (!tcase_matching_tag(tc, include_tag_lst)) + { + continue; + } + } + if (exclude_tags != NULL) + { + if (tcase_matching_tag(tc, exclude_tag_lst)) + { + continue; + } + } srunner_run_tcase(sr, tc); } @@ -768,8 +768,8 @@ void srunner_run_all(SRunner * sr, enum print_output print_mode) } void srunner_run_tagged(SRunner * sr, const char *sname, const char *tcname, - const char *include_tags, const char *exclude_tags, - enum print_output print_mode) + const char *include_tags, const char *exclude_tags, + enum print_output print_mode) { #if defined(HAVE_SIGACTION) && defined(HAVE_FORK) static struct sigaction sigalarm_old_action; @@ -783,11 +783,11 @@ void srunner_run_tagged(SRunner * sr, const char *sname, const char *tcname, if(!tcname) tcname = getenv("CK_RUN_CASE"); if(!sname) - sname = getenv("CK_RUN_SUITE"); + sname = getenv("CK_RUN_SUITE"); if(!include_tags) - include_tags = getenv("CK_INCLUDE_TAGS"); + include_tags = getenv("CK_INCLUDE_TAGS"); if(!exclude_tags) - exclude_tags = getenv("CK_EXCLUDE_TAGS"); + exclude_tags = getenv("CK_EXCLUDE_TAGS"); if(sr == NULL) return; @@ -811,7 +811,7 @@ void srunner_run_tagged(SRunner * sr, const char *sname, const char *tcname, #endif /* HAVE_SIGACTION && HAVE_FORK */ srunner_run_init(sr, print_mode); srunner_iterate_suites(sr, sname, tcname, include_tags, exclude_tags, - print_mode); + print_mode); srunner_run_end(sr, print_mode); #if defined(HAVE_SIGACTION) && defined(HAVE_FORK) sigaction(SIGALRM, &sigalarm_old_action, NULL); From c4f8c1cc1859a1dd4f7b1bd9e3b03bdca823bfd0 Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Fri, 17 Aug 2018 21:44:40 -0500 Subject: [PATCH 3/7] Add suite name parameter to TestResult Pass suite pointer or suite name parameters to functions which eventually create TestResult object --- src/check.c | 1 + src/check_impl.h | 1 + src/check_run.c | 90 ++++++++++++++++++++++++++++-------------------- 3 files changed, 54 insertions(+), 38 deletions(-) diff --git a/src/check.c b/src/check.c index 9f9b251c..42d5e9aa 100644 --- a/src/check.c +++ b/src/check.c @@ -531,6 +531,7 @@ static void tr_init(TestResult * tr) tr->rtype = CK_TEST_RESULT_INVALID; tr->msg = NULL; tr->file = NULL; + tr->sname = NULL; tr->tcname = NULL; tr->tname = NULL; tr->duration = -1; diff --git a/src/check_impl.h b/src/check_impl.h index f4e8c590..134a86a6 100644 --- a/src/check_impl.h +++ b/src/check_impl.h @@ -82,6 +82,7 @@ struct TestResult int line; /* Line number where the test occurred */ int iter; /* The iteration value for looping tests */ int duration; /* duration of this test in microseconds */ + const char *sname; /* Suite that generated the result */ const char *tcname; /* Test case that generated the result */ const char *tname; /* Test that generated the result */ char *msg; /* Failure message */ diff --git a/src/check_run.c b/src/check_run.c index b84d2cdf..c5a78493 100644 --- a/src/check_run.c +++ b/src/check_run.c @@ -63,29 +63,33 @@ static void srunner_iterate_suites(SRunner * sr, const char *include_tags, const char *exclude_tags, enum print_output print_mode); -static void srunner_iterate_tcase_tfuns(SRunner * sr, TCase * tc); +static void srunner_iterate_tcase_tfuns(SRunner * sr, Suite * s, TCase * tc); static void srunner_add_failure(SRunner * sr, TestResult * tf); static TestResult * srunner_run_setup(List * func_list, - enum fork_status fork_usage, const char * test_name, - const char * setup_name); -static int srunner_run_unchecked_setup(SRunner * sr, TCase * tc); -static TestResult *tcase_run_checked_setup(SRunner * sr, TCase * tc); + enum fork_status fork_usage, + const char * suite_name, + const char * test_name, + const char * setup_name); +static int srunner_run_unchecked_setup(SRunner * sr, Suite * s, TCase * tc); +static TestResult *tcase_run_checked_setup(SRunner * sr, Suite * s, TCase * tc); static void srunner_run_teardown(List * fixture_list, enum fork_status fork_usage); static void srunner_run_unchecked_teardown(SRunner * sr, TCase * tc); static void tcase_run_checked_teardown(TCase * tc); -static void srunner_run_tcase(SRunner * sr, TCase * tc); -static TestResult *tcase_run_tfun_nofork(SRunner * sr, TCase * tc, TF * tf, - int i); -static TestResult *receive_result_info_nofork(const char *tcname, +static void srunner_run_tcase(SRunner * sr, Suite * s, TCase * tc); +static TestResult *tcase_run_tfun_nofork(SRunner * sr, Suite * s, TCase * tc, + TF * tf, int i); +static TestResult *receive_result_info_nofork(const char *sname, + const char *tcname, const char *tname, int iter, int duration); static void set_nofork_info(TestResult * tr); static char *pass_msg(void); #if defined(HAVE_FORK) && HAVE_FORK==1 -static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tf, - int i); -static TestResult *receive_result_info_fork(const char *tcname, +static TestResult *tcase_run_tfun_fork(SRunner * sr, Suite * s, TCase * tc, + TF * tf, int i); +static TestResult *receive_result_info_fork(const char *sname, + const char *tcname, const char *tname, int iter, int status, int expected_signal, signed char allowed_exit_value); @@ -215,7 +219,7 @@ static void srunner_iterate_suites(SRunner * sr, } } - srunner_run_tcase(sr, tc); + srunner_run_tcase(sr, s, tc); } log_suite_end(sr, s); @@ -227,7 +231,7 @@ static void srunner_iterate_suites(SRunner * sr, check_list_free(exclude_tag_lst); } -static void srunner_iterate_tcase_tfuns(SRunner * sr, TCase * tc) +static void srunner_iterate_tcase_tfuns(SRunner * sr, Suite * s, TCase * tc) { List *tfl; TF *tfun; @@ -249,14 +253,14 @@ static void srunner_iterate_tcase_tfuns(SRunner * sr, TCase * tc) { case CK_FORK: #if defined(HAVE_FORK) && HAVE_FORK==1 - tr = tcase_run_tfun_fork(sr, tc, tfun, i); + tr = tcase_run_tfun_fork(sr, s, 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); + tr = tcase_run_tfun_nofork(sr, s, tc, tfun, i); break; case CK_FORK_GETENV: default: @@ -283,8 +287,11 @@ static void srunner_add_failure(SRunner * sr, TestResult * tr) } -static TestResult * srunner_run_setup(List * fixture_list, enum fork_status fork_usage, - const char * test_name, const char * setup_name) +static TestResult * srunner_run_setup(List * fixture_list, + enum fork_status fork_usage, + const char * suite_name, + const char * test_name, + const char * setup_name) { TestResult *tr = NULL; Fixture *setup_fixture; @@ -309,7 +316,8 @@ static TestResult * srunner_run_setup(List * fixture_list, enum fork_status fork } /* Stop the setup and return the failure in nofork mode. */ - tr = receive_result_info_nofork(test_name, setup_name, 0, -1); + tr = receive_result_info_nofork(suite_name, test_name, setup_name, + 0, -1); if(tr->rtype != CK_PASS) { break; @@ -329,13 +337,14 @@ static TestResult * srunner_run_setup(List * fixture_list, enum fork_status fork return tr; } -static int srunner_run_unchecked_setup(SRunner * sr, TCase * tc) +static int srunner_run_unchecked_setup(SRunner * sr, Suite * s, TCase * tc) { TestResult *tr = NULL; int rval = 1; set_fork_status(CK_NOFORK); - tr = srunner_run_setup(tc->unch_sflst, CK_NOFORK, tc->name, "unchecked_setup"); + tr = srunner_run_setup(tc->unch_sflst, CK_NOFORK, s->name, tc->name, + "unchecked_setup"); set_fork_status(srunner_fork_status(sr)); if(tr != NULL && tr->rtype != CK_PASS) @@ -347,10 +356,10 @@ static int srunner_run_unchecked_setup(SRunner * sr, TCase * tc) return rval; } -static TestResult *tcase_run_checked_setup(SRunner * sr, TCase * tc) +static TestResult *tcase_run_checked_setup(SRunner * sr, Suite * s, TCase * tc) { TestResult *tr = srunner_run_setup(tc->ch_sflst, srunner_fork_status(sr), - tc->name, "checked_setup"); + s->name, tc->name, "checked_setup"); return tr; } @@ -394,22 +403,22 @@ static void tcase_run_checked_teardown(TCase * tc) srunner_run_teardown(tc->ch_tflst, CK_NOFORK); } -static void srunner_run_tcase(SRunner * sr, TCase * tc) +static void srunner_run_tcase(SRunner * sr, Suite * s, TCase * tc) { - if(srunner_run_unchecked_setup(sr, tc)) + if(srunner_run_unchecked_setup(sr, s, tc)) { - srunner_iterate_tcase_tfuns(sr, tc); + srunner_iterate_tcase_tfuns(sr, s, tc); srunner_run_unchecked_teardown(sr, tc); } } -static TestResult *tcase_run_tfun_nofork(SRunner * sr, TCase * tc, TF * tfun, - int i) +static TestResult *tcase_run_tfun_nofork(SRunner * sr, Suite * s, 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); + tr = tcase_run_checked_setup(sr, s, tc); if(tr == NULL) { clock_gettime(check_get_clockid(), &ts_start); @@ -420,14 +429,15 @@ static TestResult *tcase_run_tfun_nofork(SRunner * sr, TCase * tc, TF * tfun, } clock_gettime(check_get_clockid(), &ts_end); tcase_run_checked_teardown(tc); - return receive_result_info_nofork(tc->name, tfun->ttest->name, i, - DIFF_IN_USEC(ts_start, ts_end)); + return receive_result_info_nofork(s->name, tc->name, tfun->ttest->name, + i, DIFF_IN_USEC(ts_start, ts_end)); } return tr; } -static TestResult *receive_result_info_nofork(const char *tcname, +static TestResult *receive_result_info_nofork(const char *sname, + const char *tcname, const char *tname, int iter, int duration) { @@ -440,6 +450,7 @@ static TestResult *receive_result_info_nofork(const char *tcname, } else { + tr->sname = sname; tr->tcname = tcname; tr->tname = tname; tr->iter = iter; @@ -469,8 +480,8 @@ static char *pass_msg(void) } #if defined(HAVE_FORK) && HAVE_FORK==1 -static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tfun, - int i) +static TestResult *tcase_run_tfun_fork(SRunner * sr, Suite * s, TCase * tc, + TF * tfun, int i) { pid_t pid_w; pid_t pid; @@ -489,7 +500,7 @@ static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tfun, { setpgid(0, 0); group_pid = getpgrp(); - tr = tcase_run_checked_setup(sr, tc); + tr = tcase_run_checked_setup(sr, s, tc); free(tr); clock_gettime(check_get_clockid(), &ts_start); tcase_fn_start(tfun->ttest->name, tfun->ttest->file, tfun->ttest->line); @@ -537,11 +548,13 @@ static TestResult *tcase_run_tfun_fork(SRunner * sr, TCase * tc, TF * tfun, killpg(pid, SIGKILL); /* Kill remaining processes. */ - return receive_result_info_fork(tc->name, tfun->ttest->name, i, status, - tfun->signal, tfun->allowed_exit_value); + return receive_result_info_fork(s->name, tc->name, tfun->ttest->name, i, + status, tfun->signal, + tfun->allowed_exit_value); } -static TestResult *receive_result_info_fork(const char *tcname, +static TestResult *receive_result_info_fork(const char *sname, + const char *tcname, const char *tname, int iter, int status, int expected_signal, @@ -556,6 +569,7 @@ static TestResult *receive_result_info_fork(const char *tcname, } else { + tr->sname = sname; tr->tcname = tcname; tr->tname = tname; tr->iter = iter; From 7fa65af617340ddd6256d90997d05fb7489ae939 Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Sat, 18 Aug 2018 10:52:52 -0500 Subject: [PATCH 4/7] Add suite name to default test printing format Suite name is prepended before test case now. Unit tests are also updated accordingly. --- src/check_str.c | 6 +-- tests/check_check_fixture.c | 12 ++--- tests/test_check_nofork_teardown.sh | 2 +- tests/test_output_strings | 78 ++++++++++++++--------------- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/check_str.c b/src/check_str.c index 2ae093fd..399001a7 100644 --- a/src/check_str.c +++ b/src/check_str.c @@ -39,10 +39,10 @@ char *tr_str(TestResult * tr) exact_msg = (tr->rtype == CK_ERROR) ? "(after this point) " : ""; - rstr = ck_strdup_printf("%s:%d:%s:%s:%s:%d: %s%s", + rstr = ck_strdup_printf("%s:%d:%s:%s:%s:%s:%d: %s%s", tr->file, tr->line, - tr_type_str(tr), tr->tcname, tr->tname, tr->iter, - exact_msg, tr->msg); + tr_type_str(tr), tr->sname, tr->tcname, tr->tname, + tr->iter, exact_msg, tr->msg); return rstr; } diff --git a/tests/check_check_fixture.c b/tests/check_check_fixture.c index a82dd014..d0cd6829 100644 --- a/tests/check_check_fixture.c +++ b/tests/check_check_fixture.c @@ -83,7 +83,7 @@ START_TEST(test_setup_failure_msg) { TestResult **tra; char *trm; - const char *trmexp = "check_check_fixture.c:36:S:Fix Sub:unchecked_setup:0: Test failure in fixture"; + const char *trmexp = "check_check_fixture.c:36:S:Fix Sub:Fix Sub:unchecked_setup:0: Test failure in fixture"; tra = srunner_failures(fixture_sr); trm = tr_str(tra[0]); @@ -212,7 +212,7 @@ START_TEST(test_ch_setup_fail) trm = tr_str(tr[0]); /* Search for check_check_fixture.c:150 if this fails. */ if (strstr(trm, - "check_check_fixture.c:150:S:Setup Fail:test_sub_fail:0: Failed setup") + "check_check_fixture.c:150:S:Setup Fail:Setup Fail:test_sub_fail:0: Failed setup") == 0) { snprintf(errm, sizeof(errm), "Bad failed checked setup tr msg (%s)", trm); @@ -342,7 +342,7 @@ START_TEST(test_ch_setup_sig) trm = tr_str(tr[0]); if (strstr(trm, - "check_check_fixture.c:160:S:Setup Sig:test_sub_fail:0: " + "check_check_fixture.c:160:S:Setup Sig:Setup Sig:test_sub_fail:0: " "(after this point) Received signal 8") == 0) { snprintf(errm, sizeof(errm), @@ -435,7 +435,7 @@ START_TEST(test_ch_teardown_fail) trm = tr_str(tr[0]); if (strstr(trm, - "check_check_fixture.c:155:S:Teardown Fail:test_sub_pass:0: Failed teardown") + "check_check_fixture.c:155:S:Teardown Fail:Teardown Fail:test_sub_pass:0: Failed teardown") == 0) { snprintf(errm, sizeof(errm), "Bad failed checked teardown tr msg (%s)", trm); @@ -481,7 +481,7 @@ START_TEST(test_ch_teardown_fail_nofork) trm = tr_str(tr[0]); if (strstr(trm, - "check_check_fixture.c:155:S:Teardown Fail No Fork:test_sub_pass:0: Failed teardown") + "check_check_fixture.c:155:S:Teardown Fail No Fork:Teardown Fail No Fork:test_sub_pass:0: Failed teardown") == 0) { snprintf(errm, sizeof(errm), "Bad failed checked teardown tr msg (%s)", trm); @@ -536,7 +536,7 @@ START_TEST(test_ch_teardown_sig) trm = tr_str(tr[0]); if (strstr(trm, - "check_check_fixture.c:166:S:Teardown Sig:test_sub_pass:0: " + "check_check_fixture.c:166:S:Teardown Sig:Teardown Sig:test_sub_pass:0: " "(after this point) Received signal 8") == 0) { snprintf(errm, sizeof(errm), diff --git a/tests/test_check_nofork_teardown.sh b/tests/test_check_nofork_teardown.sh index 44cf42c8..05f49768 100755 --- a/tests/test_check_nofork_teardown.sh +++ b/tests/test_check_nofork_teardown.sh @@ -4,7 +4,7 @@ expected="Running suite(s): bug-99 0%: Checks: 1, Failures: 1, Errors: 0 -${SRCDIR}check_nofork_teardown.c:56:F:tc:will_fail:0: Assertion '0' failed" +${SRCDIR}check_nofork_teardown.c:56:F:bug-99:tc:will_fail:0: Assertion '0' failed" actual=`./check_nofork_teardown${EXEEXT} | tr -d "\r"` if [ x"${expected}" = x"${actual}" ]; then diff --git a/tests/test_output_strings b/tests/test_output_strings index 21751b61..5c590bca 100644 --- a/tests/test_output_strings +++ b/tests/test_output_strings @@ -30,17 +30,17 @@ $exp_minimal_result" if [ $HAVE_FORK -eq 1 ]; then exp_normal_result=`printf "37%%: Checks: 8, Failures: 4, Errors: 1 -${SRCDIR}ex_output.c:37:F:Core:test_fail:0: Failure -${SRCDIR}ex_output.c:46:E:Core:test_exit:0: (after this point) Early exit with return value 1 -${SRCDIR}ex_output.c:72:F:Core:test_loop:0: Iteration 0 failed -${SRCDIR}ex_output.c:72:F:Core:test_loop:2: Iteration 2 failed -${SRCDIR}ex_output.c:78:F:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` +${SRCDIR}ex_output.c:37:F:S1:Core:test_fail:0: Failure +${SRCDIR}ex_output.c:46:E:S1:Core:test_exit:0: (after this point) Early exit with return value 1 +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:0: Iteration 0 failed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:2: Iteration 2 failed +${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` else exp_normal_result=`printf "42%%: Checks: 7, Failures: 4, Errors: 0 -${SRCDIR}ex_output.c:37:F:Core:test_fail:0: Failure -${SRCDIR}ex_output.c:72:F:Core:test_loop:0: Iteration 0 failed -${SRCDIR}ex_output.c:72:F:Core:test_loop:2: Iteration 2 failed -${SRCDIR}ex_output.c:78:F:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` +${SRCDIR}ex_output.c:37:F:S1:Core:test_fail:0: Failure +${SRCDIR}ex_output.c:72:F:S1:Core:test_loop:0: Iteration 0 failed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:2: Iteration 2 failed +${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` fi exp_normal="$suite_output $exp_normal_result" @@ -48,23 +48,23 @@ $exp_normal_result" if [ $HAVE_FORK -eq 1 ]; then exp_verbose_result=`printf "37%%: Checks: 8, Failures: 4, Errors: 1 -${SRCDIR}ex_output.c:31:P:Core:test_pass:0: Passed -${SRCDIR}ex_output.c:37:F:Core:test_fail:0: Failure -${SRCDIR}ex_output.c:46:E:Core:test_exit:0: (after this point) Early exit with return value 1 -${SRCDIR}ex_output.c:66:P:Core:test_pass2:0: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:0: Iteration 0 failed -${SRCDIR}ex_output.c:72:P:Core:test_loop:1: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:2: Iteration 2 failed -${SRCDIR}ex_output.c:78:F:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` +${SRCDIR}ex_output.c:31:P:S1:Core:test_pass:0: Passed +${SRCDIR}ex_output.c:37:F:S1:Core:test_fail:0: Failure +${SRCDIR}ex_output.c:46:E:S1:Core:test_exit:0: (after this point) Early exit with return value 1 +${SRCDIR}ex_output.c:66:P:S2:Core:test_pass2:0: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:0: Iteration 0 failed +${SRCDIR}ex_output.c:72:P:S2:Core:test_loop:1: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:2: Iteration 2 failed +${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` else exp_verbose_result=`printf "42%%: Checks: 7, Failures: 4, Errors: 0 -${SRCDIR}ex_output.c:31:P:Core:test_pass:0: Passed -${SRCDIR}ex_output.c:37:F:Core:test_fail:0: Failure -${SRCDIR}ex_output.c:66:P:Core:test_pass2:0: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:0: Iteration 0 failed -${SRCDIR}ex_output.c:72:P:Core:test_loop:1: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:2: Iteration 2 failed -${SRCDIR}ex_output.c:78:F:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` +${SRCDIR}ex_output.c:31:P:S1:Core:test_pass:0: Passed +${SRCDIR}ex_output.c:37:F:S1:Core:test_fail:0: Failure +${SRCDIR}ex_output.c:66:P:S2:Core:test_pass2:0: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:0: Iteration 0 failed +${SRCDIR}ex_output.c:72:P:S2:Core:test_loop:1: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:2: Iteration 2 failed +${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` fi exp_verbose="$suite_output $exp_verbose_result" @@ -126,29 +126,29 @@ fi ################## if [ $HAVE_FORK -eq 1 ]; then expected_log_log=`printf "Running suite S1 -${SRCDIR}ex_output.c:31:P:Core:test_pass:0: Passed -${SRCDIR}ex_output.c:37:F:Core:test_fail:0: Failure -${SRCDIR}ex_output.c:46:E:Core:test_exit:0: (after this point) Early exit with return value 1 +${SRCDIR}ex_output.c:31:P:S1:Core:test_pass:0: Passed +${SRCDIR}ex_output.c:37:F:S1:Core:test_fail:0: Failure +${SRCDIR}ex_output.c:46:E:S1:Core:test_exit:0: (after this point) Early exit with return value 1 Running suite S2 -${SRCDIR}ex_output.c:66:P:Core:test_pass2:0: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:0: Iteration 0 failed -${SRCDIR}ex_output.c:72:P:Core:test_loop:1: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:2: Iteration 2 failed +${SRCDIR}ex_output.c:66:P:S2:Core:test_pass2:0: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:0: Iteration 0 failed +${SRCDIR}ex_output.c:72:P:S2:Core:test_loop:1: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:2: Iteration 2 failed Running suite XML escape \" ' < > & $tab_nl_X_bs tests -${SRCDIR}ex_output.c:78:F:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message +${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message Results for all suites run: 37%%: Checks: 8, Failures: 4, Errors: 1"` else expected_log_log=`printf "Running suite S1 -${SRCDIR}ex_output.c:31:P:Core:test_pass:0: Passed -${SRCDIR}ex_output.c:37:F:Core:test_fail:0: Failure +${SRCDIR}ex_output.c:31:P:S1:Core:test_pass:0: Passed +${SRCDIR}ex_output.c:37:F:S1:Core:test_fail:0: Failure Running suite S2 -${SRCDIR}ex_output.c:66:P:Core:test_pass2:0: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:0: Iteration 0 failed -${SRCDIR}ex_output.c:72:P:Core:test_loop:1: Passed -${SRCDIR}ex_output.c:72:F:Core:test_loop:2: Iteration 2 failed +${SRCDIR}ex_output.c:66:P:S2:Core:test_pass2:0: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:0: Iteration 0 failed +${SRCDIR}ex_output.c:72:P:S2:Core:test_loop:1: Passed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:2: Iteration 2 failed Running suite XML escape \" ' < > & $tab_nl_X_bs tests -${SRCDIR}ex_output.c:78:F:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message +${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message Results for all suites run: 42%%: Checks: 7, Failures: 4, Errors: 0"` fi From fc9ddaa73113331303f94f8ea3db694d87ade04a Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Sun, 26 Aug 2018 20:14:18 -0500 Subject: [PATCH 5/7] Fix typo in test for the expected output --- tests/test_output_strings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_output_strings b/tests/test_output_strings index 5c590bca..e198e8fc 100644 --- a/tests/test_output_strings +++ b/tests/test_output_strings @@ -38,7 +38,7 @@ ${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \ else exp_normal_result=`printf "42%%: Checks: 7, Failures: 4, Errors: 0 ${SRCDIR}ex_output.c:37:F:S1:Core:test_fail:0: Failure -${SRCDIR}ex_output.c:72:F:S1:Core:test_loop:0: Iteration 0 failed +${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:0: Iteration 0 failed ${SRCDIR}ex_output.c:72:F:S2:Core:test_loop:2: Iteration 2 failed ${SRCDIR}ex_output.c:78:F:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg:0: fail \" ' < > & $tab_nl_X_bs message"` fi From e8bf9e62bd75283c7e345cdd83ae3c42d649acd0 Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Mon, 27 Aug 2018 14:19:09 -0500 Subject: [PATCH 6/7] Add suite name to TAP output --- src/check_log.c | 4 +-- tests/test_output_strings | 52 +++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/check_log.c b/src/check_log.c index c785b33c..b9e07c83 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -371,9 +371,9 @@ void tap_lfun(SRunner * sr CK_ATTRIBUTE_UNUSED, FILE * file, /* Print the test result to the tap file */ num_tests_run += 1; tr = (TestResult *)obj; - fprintf(file, "%s %d - %s:%s:%s: %s\n", + fprintf(file, "%s %d - %s:%s:%s:%s: %s\n", tr->rtype == CK_PASS ? "ok" : "not ok", num_tests_run, - tr->file, tr->tcname, tr->tname, tr->msg); + tr->file, tr->sname, tr->tcname, tr->tname, tr->msg); fflush(file); break; default: diff --git a/tests/test_output_strings b/tests/test_output_strings index e198e8fc..810d52cf 100644 --- a/tests/test_output_strings +++ b/tests/test_output_strings @@ -297,33 +297,33 @@ fi # tap output ################## if [ $HAVE_FORK -eq 1 ]; then -expected_normal_tap=`printf "ok 1 - ${SRCDIR}ex_output.c:Core:test_pass: Passed -not ok 2 - ${SRCDIR}ex_output.c:Core:test_fail: Failure -not ok 3 - ${SRCDIR}ex_output.c:Core:test_exit: Early exit with return value 1 -ok 4 - ${SRCDIR}ex_output.c:Core:test_pass2: Passed -not ok 5 - ${SRCDIR}ex_output.c:Core:test_loop: Iteration 0 failed -ok 6 - ${SRCDIR}ex_output.c:Core:test_loop: Passed -not ok 7 - ${SRCDIR}ex_output.c:Core:test_loop: Iteration 2 failed -not ok 8 - ${SRCDIR}ex_output.c:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg: fail \" ' < > & $tab_nl_X_bs message +expected_normal_tap=`printf "ok 1 - ${SRCDIR}ex_output.c:S1:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_output.c:S1:Core:test_fail: Failure +not ok 3 - ${SRCDIR}ex_output.c:S1:Core:test_exit: Early exit with return value 1 +ok 4 - ${SRCDIR}ex_output.c:S2:Core:test_pass2: Passed +not ok 5 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Iteration 0 failed +ok 6 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Passed +not ok 7 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Iteration 2 failed +not ok 8 - ${SRCDIR}ex_output.c:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg: fail \" ' < > & $tab_nl_X_bs message 1..8"` -expected_aborted_tap=`printf "ok 1 - ${SRCDIR}ex_output.c:Core:test_pass: Passed -not ok 2 - ${SRCDIR}ex_output.c:Core:test_fail: Failure -not ok 3 - ${SRCDIR}ex_output.c:Core:test_exit: Early exit with return value 1 -not ok 4 - ${SRCDIR}ex_output.c:Core:test_abort: Early exit with return value 1 -ok 5 - ${SRCDIR}ex_output.c:Core:test_pass2: Passed -not ok 6 - ${SRCDIR}ex_output.c:Core:test_loop: Iteration 0 failed -ok 7 - ${SRCDIR}ex_output.c:Core:test_loop: Passed -not ok 8 - ${SRCDIR}ex_output.c:Core:test_loop: Iteration 2 failed -not ok 9 - ${SRCDIR}ex_output.c:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg: fail \" ' < > & $tab_nl_X_bs message +expected_aborted_tap=`printf "ok 1 - ${SRCDIR}ex_output.c:S1:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_output.c:S1:Core:test_fail: Failure +not ok 3 - ${SRCDIR}ex_output.c:S1:Core:test_exit: Early exit with return value 1 +not ok 4 - ${SRCDIR}ex_output.c:S2:Core:test_abort: Early exit with return value 1 +ok 5 - ${SRCDIR}ex_output.c:S2:Core:test_pass2: Passed +not ok 6 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Iteration 0 failed +ok 7 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Passed +not ok 8 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Iteration 2 failed +not ok 9 - ${SRCDIR}ex_output.c:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg: fail \" ' < > & $tab_nl_X_bs message 1..9"` else -expected_normal_tap=`printf "ok 1 - ${SRCDIR}ex_output.c:Core:test_pass: Passed -not ok 2 - ${SRCDIR}ex_output.c:Core:test_fail: Failure -ok 3 - ${SRCDIR}ex_output.c:Core:test_pass2: Passed -not ok 4 - ${SRCDIR}ex_output.c:Core:test_loop: Iteration 0 failed -ok 5 - ${SRCDIR}ex_output.c:Core:test_loop: Passed -not ok 6 - ${SRCDIR}ex_output.c:Core:test_loop: Iteration 2 failed -not ok 7 - ${SRCDIR}ex_output.c:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg: fail \" ' < > & $tab_nl_X_bs message +expected_normal_tap=`printf "ok 1 - ${SRCDIR}ex_output.c:S1:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_output.c:S1:Core:test_fail: Failure +ok 3 - ${SRCDIR}ex_output.c:S2:Core:test_pass2: Passed +not ok 4 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Iteration 0 failed +ok 5 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Passed +not ok 6 - ${SRCDIR}ex_output.c:S2:Core:test_loop: Iteration 2 failed +not ok 7 - ${SRCDIR}ex_output.c:XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg: fail \" ' < > & $tab_nl_X_bs message 1..7"` # When fork() is unavailable, one of the tests # will invoke exit() which will terminate the @@ -331,6 +331,6 @@ not ok 7 - ${SRCDIR}ex_output.c:description \" ' < > & $tab_nl_X_bs end:test_xml # results will be incomplete, but the required # test plan will be missing, signaling that # something bad happened. -expected_aborted_tap="ok 1 - ${SRCDIR}ex_output.c:Core:test_pass: Passed -not ok 2 - ${SRCDIR}ex_output.c:Core:test_fail: Failure" +expected_aborted_tap="ok 1 - ${SRCDIR}ex_output.c:S1:Core:test_pass: Passed +not ok 2 - ${SRCDIR}ex_output.c:S1:Core:test_fail: Failure" fi From 06d1d7059865693b55bc9228ab7aa393d59b84e4 Mon Sep 17 00:00:00 2001 From: Omer Ozarslan Date: Mon, 27 Aug 2018 15:59:52 -0500 Subject: [PATCH 7/7] Add suite name to subunit output --- src/check_log.c | 7 +++-- src/check_log.h | 2 +- src/check_run.c | 2 +- tests/test_output_strings | 60 +++++++++++++++++++-------------------- 4 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/check_log.c b/src/check_log.c index b9e07c83..1153d701 100644 --- a/src/check_log.c +++ b/src/check_log.c @@ -148,11 +148,11 @@ void log_suite_end(SRunner * sr, Suite * s) srunner_send_evt(sr, s, CLEND_S); } -void log_test_start(SRunner * sr, TCase * tc, TF * tfun) +void log_test_start(SRunner * sr, Suite * s, TCase * tc, TF * tfun) { char buffer[100]; - snprintf(buffer, 99, "%s:%s", tc->name, tfun->ttest->name); + snprintf(buffer, 99, "%s:%s:%s", s->name, tc->name, tfun->ttest->name); srunner_send_evt(sr, buffer, CLSTART_T); } @@ -417,7 +417,8 @@ void subunit_lfun(SRunner * sr, FILE * file, enum print_output printmode, case CLEND_T: tr = (TestResult *)obj; { - char *name = ck_strdup_printf("%s:%s", tr->tcname, tr->tname); + char *name = ck_strdup_printf("%s:%s:%s", + tr->sname, tr->tcname, tr->tname); char *msg = tr_short_str(tr); switch (tr->rtype) diff --git a/src/check_log.h b/src/check_log.h index 7223b987..4924c383 100644 --- a/src/check_log.h +++ b/src/check_log.h @@ -26,7 +26,7 @@ void log_srunner_end(SRunner * sr); void log_suite_start(SRunner * sr, Suite * s); void log_suite_end(SRunner * sr, Suite * s); void log_test_end(SRunner * sr, TestResult * tr); -void log_test_start(SRunner * sr, TCase * tc, TF * tfun); +void log_test_start(SRunner * sr, Suite * s, TCase * tc, TF * tfun); void stdout_lfun(SRunner * sr, FILE * file, enum print_output, void *obj, enum cl_event evt); diff --git a/src/check_run.c b/src/check_run.c index c5a78493..7ca171a5 100644 --- a/src/check_run.c +++ b/src/check_run.c @@ -248,7 +248,7 @@ static void srunner_iterate_tcase_tfuns(SRunner * sr, Suite * s, TCase * tc) for(i = tfun->loop_start; i < tfun->loop_end; i++) { - log_test_start(sr, tc, tfun); + log_test_start(sr, s, tc, tfun); switch (srunner_fork_status(sr)) { case CK_FORK: diff --git a/tests/test_output_strings b/tests/test_output_strings index 810d52cf..65a8d627 100644 --- a/tests/test_output_strings +++ b/tests/test_output_strings @@ -70,53 +70,53 @@ exp_verbose="$suite_output $exp_verbose_result" if [ $HAVE_FORK -eq 1 ]; then -exp_subunit=`printf "test: Core:test_pass -success: Core:test_pass -test: Core:test_fail -failure: Core:test_fail [ +exp_subunit=`printf "test: S1:Core:test_pass +success: S1:Core:test_pass +test: S1:Core:test_fail +failure: S1:Core:test_fail [ ${SRCDIR}ex_output.c:37: Failure ] -test: Core:test_exit -error: Core:test_exit [ +test: S1:Core:test_exit +error: S1:Core:test_exit [ ${SRCDIR}ex_output.c:46: (after this point) Early exit with return value 1 ] -test: Core:test_pass2 -success: Core:test_pass2 -test: Core:test_loop -failure: Core:test_loop [ +test: S2:Core:test_pass2 +success: S2:Core:test_pass2 +test: S2:Core:test_loop +failure: S2:Core:test_loop [ ${SRCDIR}ex_output.c:72: Iteration 0 failed ] -test: Core:test_loop -success: Core:test_loop -test: Core:test_loop -failure: Core:test_loop [ +test: S2:Core:test_loop +success: S2:Core:test_loop +test: S2:Core:test_loop +failure: S2:Core:test_loop [ ${SRCDIR}ex_output.c:72: Iteration 2 failed ] -test: description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg -failure: description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg [ +test: XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg +failure: XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg [ ${SRCDIR}ex_output.c:78: fail \" ' < > & $tab_nl_X_bs message ]"` else -exp_subunit=`printf "test: Core:test_pass -success: Core:test_pass -test: Core:test_fail -failure: Core:test_fail [ +exp_subunit=`printf "test: S1:Core:test_pass +success: S1:Core:test_pass +test: S1:Core:test_fail +failure: S1:Core:test_fail [ ${SRCDIR}ex_output.c:37: Failure ] -test: Core:test_pass2 -success: Core:test_pass2 -test: Core:test_loop -failure: Core:test_loop [ +test: S2:Core:test_pass2 +success: S2:Core:test_pass2 +test: S2:Core:test_loop +failure: S2:Core:test_loop [ ${SRCDIR}ex_output.c:72: Iteration 0 failed ] -test: Core:test_loop -success: Core:test_loop -test: Core:test_loop -failure: Core:test_loop [ +test: S2:Core:test_loop +success: S2:Core:test_loop +test: S2:Core:test_loop +failure: S2:Core:test_loop [ ${SRCDIR}ex_output.c:72: Iteration 2 failed ] -test: description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg -failure: description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg [ +test: XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg +failure: XML escape \" ' < > & $tab_nl_X_bs tests:description \" ' < > & $tab_nl_X_bs end:test_xml_esc_fail_msg [ ${SRCDIR}ex_output.c:78: fail \" ' < > & $tab_nl_X_bs message ]"` fi