]> granicus.if.org Git - check/commitdiff
Add test for logging to stdout
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 27 Jan 2014 03:18:33 +0000 (03:18 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Mon, 27 Jan 2014 03:18:33 +0000 (03:18 +0000)
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
tests/test_output.sh

index fba3e686c8cf15e9b095eb642d2f8d54448a7734..e86ce93f465394bc1f62cb0b13d375cb9daab49f 100644 (file)
@@ -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();
index 282756115119bb5699bbb25fe0a60936657d5b97..22ef717cb5a5bfdb695ef304c6cf4be7209fa216 100755 (executable)
@@ -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 \<duration\> | grep -v \<datetime\> | grep -v \<path\>`
+xml_env_stdout=`CK_XML_LOG_FILE_NAME="-" ./ex_output${EXEEXT} CK_SILENT STDOUT NORMAL      | tr -d "\r" | grep -v \<duration\> | grep -v \<datetime\> | grep -v \<path\>`
+
 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)"