From 99e139a3a602790298e5a39992bee4ddfcd37c0a Mon Sep 17 00:00:00 2001 From: brarcher Date: Mon, 27 Jan 2014 03:18:33 +0000 Subject: [PATCH] Add test for logging to stdout This checks that both setting "-" with the related environment and with the srummer_set_*() call both result in printing the logging data to stdout. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@1080 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- tests/ex_output.c | 18 +++++++++++++++++- tests/test_output.sh | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/tests/ex_output.c b/tests/ex_output.c index fba3e68..e86ce93 100644 --- a/tests/ex_output.c +++ b/tests/ex_output.c @@ -116,10 +116,14 @@ static void print_usage(void) #if ENABLE_SUBUNIT printf (" | CK_SUBUNIT"); #endif - printf (") (STDOUT | STDOUT_DUMP | LOG | TAP | XML) (NORMAL | EXIT_TEST)\n"); + printf (")\n"); + printf(" (STDOUT | STDOUT_DUMP | LOG | LOG_STDOUT | TAP | TAP_STDOUT | XML | XML_STDOUT)\n"); + printf(" (NORMAL | EXIT_TEST)\n"); printf(" If CK_ENV is used, the environment variable CK_VERBOSITY can be set to\n"); printf(" one of these: silent, minimal, or verbose. If it is not set to these, or\n"); printf(" if CK_VERBOSITY is not set, then CK_NORMAL will be used\n"); + printf(" If testing the CK_[LOG|TAP_LOG|XML_LOG]_FILE_NAME env var and setting it to '-',\n"); + printf(" then use the following mode: CK_SILENT STDOUT [NORMAL|EXIT_TEST].\n"); } static void run_tests (int printmode, char * log_type, int include_exit_test) @@ -147,14 +151,26 @@ static void run_tests (int printmode, char * log_type, int include_exit_test) { srunner_set_log(sr, "test.log"); } + else if(strcmp(log_type, "LOG_STDOUT") == 0) + { + srunner_set_log(sr, "-"); + } else if(strcmp(log_type, "TAP") == 0) { srunner_set_tap(sr, "test.tap"); } + else if(strcmp(log_type, "TAP_STDOUT") == 0) + { + srunner_set_tap(sr, "-"); + } else if(strcmp(log_type, "XML") == 0) { srunner_set_xml(sr, "test.xml"); } + else if(strcmp(log_type, "XML_STDOUT") == 0) + { + srunner_set_xml(sr, "-"); + } else { print_usage(); diff --git a/tests/test_output.sh b/tests/test_output.sh index 2827561..22ef717 100755 --- a/tests/test_output.sh +++ b/tests/test_output.sh @@ -53,6 +53,13 @@ act_subunit=`./ex_output${EXEEXT} CK_SUBUNIT STDOUT NORMAL | tr -d "\r"` act_subunit_dump_env=`CK_VERBOSITY=subunit ./ex_output${EXEEXT} CK_SUBUNIT STDOUT_DUMP NORMAL | tr -d "\r"` fi +log_stdout=` ./ex_output${EXEEXT} CK_SILENT LOG_STDOUT NORMAL` +log_env_stdout=`CK_LOG_FILE_NAME="-" ./ex_output${EXEEXT} CK_SILENT STDOUT NORMAL` +tap_stdout=` ./ex_output${EXEEXT} CK_SILENT TAP_STDOUT NORMAL` +tap_env_stdout=`CK_TAP_LOG_FILE_NAME="-" ./ex_output${EXEEXT} CK_SILENT STDOUT NORMAL` +xml_stdout=` ./ex_output${EXEEXT} CK_SILENT XML_STDOUT NORMAL | tr -d "\r" | grep -v \ | grep -v \ | grep -v \` +xml_env_stdout=`CK_XML_LOG_FILE_NAME="-" ./ex_output${EXEEXT} CK_SILENT STDOUT NORMAL | tr -d "\r" | grep -v \ | grep -v \ | grep -v \` + test_output ( ) { if [ "x${1}" != "x${2}" ]; then echo "Problem with ex_output${EXEEXT} ${3}"; @@ -81,6 +88,13 @@ test_output "$exp_minimal_dump" "$act_minimal_dump_env" "CK_ENV STDOUT_DUMP NORM test_output "$exp_normal_dump" "$act_normal_dump_env" "CK_ENV STDOUT_DUMP NORMAL (for normal)" test_output "$exp_verbose_dump" "$act_verbose_dump_env" "CK_ENV STDOUT_DUMP NORMAL (for verbose)" +test_output "${expected_log_log}" "${log_stdout}" "CK_SILENT LOG_STDOUT NORMAL" +test_output "${expected_log_log}" "${log_env_stdout}" "CK_SILENT STDOUT NORMAL (with log env = '-')" +test_output "${expected_xml}" "${xml_stdout}" "CK_SILENT XML_STDOUT NORMAL" +test_output "${expected_xml}" "${xml_env_stdout}" "CK_SILENT STDOUT NORMAL (with xml env = '-')" +test_output "${expected_normal_tap}" "${tap_stdout}" "CK_SILENT TAP_STDOUT NORMAL" +test_output "${expected_normal_tap}" "${tap_env_stdout}" "CK_SILENT STDOUT NORMAL (with tap env = '-')" + if test 1 -eq $ENABLE_SUBUNIT; then test_output "$exp_subunit" "$act_subunit" "CK_SUBUNIT STDOUT NORMAL"; test_output "$exp_subunit_dump" "$act_subunit_dump_env" "CK_ENV STDOUT_DUMP NORMAL (for subunit)" -- 2.40.0