From: brarcher Date: Mon, 23 Sep 2013 13:07:01 +0000 (+0000) Subject: modify test_log_output.sh to compare output based on HAVE_FORK X-Git-Tag: 0.10.0~432 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f580655885e8aae7823baf11658d80797a6c141;p=check modify test_log_output.sh to compare output based on HAVE_FORK When run in Windows, the output differs slightly from when it is run under *NIX due to line endings. *NIX uses \n, whereas Windows uses \r\n. To account for this, printf is used to generate the Windows expected string. Additionally, the test_exit test was removed, as it is not valid if fork is unavailable. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@782 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- diff --git a/NEWS b/NEWS index f26561d..3e0dd23 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ In development: - check_check_export - test_output.sh - test_check_nofork.sh + - test_log_output.sh * On systems without timer_settimer, use setitimer (if available) to get subsecond unit test timeouts. If setitimer is unavailable, fallback diff --git a/tests/ex_log_output.c b/tests/ex_log_output.c index 5eccdbb..c5411ee 100644 --- a/tests/ex_log_output.c +++ b/tests/ex_log_output.c @@ -17,11 +17,17 @@ START_TEST(test_fail) } END_TEST +/* + * This test will fail without fork, as it will result in the + * unit test runniner exiting early. + */ +#if defined(HAVE_FORK) START_TEST(test_exit) { exit(1); } END_TEST +#endif /* HAVE_FORK */ START_TEST(test_pass2) { @@ -39,7 +45,9 @@ static Suite *make_s1_suite (void) suite_add_tcase(s, tc); tcase_add_test (tc, test_pass); tcase_add_test (tc, test_fail); +#if defined(HAVE_FORK) tcase_add_test (tc, test_exit); +#endif /* HAVE_FORK */ return s; } diff --git a/tests/test_log_output.sh b/tests/test_log_output.sh index 9316f95..94fb2bb 100755 --- a/tests/test_log_output.sh +++ b/tests/test_log_output.sh @@ -1,22 +1,34 @@ #!/bin/sh -. ./test_vars +# For this test script, it is assumed that HAVE_FORK=0 implies +# running in a Windows environment. That means not only are +# fork-related tests not run, but also line endings are important. +# In *NIX environments line endings are \n, but in Windows they +# are expected to be \r\n. For this reason, HAVE_FORK=0 uses +# printf to generate the comparison strings, so the line endings +# can be controlled. -if [ "${srcdir}" = "." ]; then - lsrc="" -else - lsrc="${srcdir}/" -fi +. ./test_vars +if [ $HAVE_FORK -eq 1 ]; then expected="Running suite S1 -${lsrc}ex_log_output.c:10:P:Core:test_pass:0: Passed -${lsrc}ex_log_output.c:16:F:Core:test_fail:0: Failure -${lsrc}ex_log_output.c:20:E:Core:test_exit:0: (after this point) Early exit with return value 1 +ex_log_output.c:10:P:Core:test_pass:0: Passed +ex_log_output.c:16:F:Core:test_fail:0: Failure +ex_log_output.c:25:E:Core:test_exit:0: (after this point) Early exit with return value 1 Running suite S2 -${lsrc}ex_log_output.c:28:P:Core:test_pass2:0: Passed +ex_log_output.c:34:P:Core:test_pass2:0: Passed Results for all suites run: 50%: Checks: 4, Failures: 1, Errors: 1" - +else +expected=`printf "Running suite S1\r +ex_log_output.c:10:P:Core:test_pass:0: Passed\r +ex_log_output.c:16:F:Core:test_fail:0: Failure\r +Running suite S2\r +ex_log_output.c:34:P:Core:test_pass2:0: Passed\r +Results for all suites run:\r +66%%: Checks: 3, Failures: 1, Errors: 0\r +"` +fi test_log_output ( ) {