]> granicus.if.org Git - check/commitdiff
Merge test scripts as well, fixed comments.
authorOren Ben-Kiki <oren@ben-kiki.org>
Tue, 29 Aug 2017 04:47:31 +0000 (07:47 +0300)
committerOren Ben-Kiki <oren@ben-kiki.org>
Tue, 29 Aug 2017 04:47:31 +0000 (07:47 +0300)
CMakeLists.txt
src/check_pack.c
tests/Makefile.am
tests/check_set_max_msg_size.c
tests/test_env_max_msg_size.sh [deleted file]
tests/test_set_max_msg_size.sh

index 453b9ee18d4b6949a78a12e483d5ea1b648fc969..0d66a5d6fb2d73d91ef25a42832ffbe00094fa81 100644 (file)
@@ -361,9 +361,6 @@ if (CHECK_ENABLE_TESTS)
     add_test(NAME test_check_nofork_teardown.sh
       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
       COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_check_nofork_teardown.sh)
-    add_test(NAME test_env_max_msg_size.sh
-      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
-      COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_env_max_msg_size.sh)
     add_test(NAME test_set_max_msg_size.sh
       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests
       COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_set_max_msg_size.sh)
index c1b77f298c98bc8f5b1d7bfd6a2acb374be4419f..6512fefcf1cb692dd01da443e760b307fddd2482 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
+
 #include "check.h"
 #include "check_error.h"
 #include "check_list.h"
index 72da9825ef40eeeb420300588bf65a916fa9f12e..46162882fedc29286d1b3dd4c587aab6b0d0bd31 100644 (file)
@@ -8,7 +8,6 @@ TESTS = \
        test_check_nofork_teardown.sh    \
        test_xml_output.sh      \
        test_log_output.sh      \
-       test_env_max_msg_size.sh        \
        test_set_max_msg_size.sh        \
        test_tap_output.sh
 
@@ -31,7 +30,7 @@ noinst_PROGRAMS =             \
        check_set_max_msg_size  \
        ex_output
 
-EXTRA_DIST = test_output.sh test_check_nofork.sh test_check_nofork_teardown.sh test_log_output.sh test_vars.in test_xml_output.sh test_tap_output.sh test_mem_leaks.sh test_output_strings test_env_max_msg_size.sh test_set_max_msg_size.sh
+EXTRA_DIST = test_output.sh test_check_nofork.sh test_check_nofork_teardown.sh test_log_output.sh test_vars.in test_xml_output.sh test_tap_output.sh test_mem_leaks.sh test_output_strings test_set_max_msg_size.sh
 
 if NO_TIMEOUT_TESTS
 check_check_CFLAGS = -DTIMEOUT_TESTS_ENABLED=0
index 6bb23d19f518513192bc35f6d862f63ee700a148..25c33f65a4409782359ba1e428326552c9767216 100644 (file)
  */
 
 /**
- * The purpose of this test is to be used by valgrind to check for
- * memory leaks. Each public API that check exports is used at
- * least once. Tests which use non-public API, or leak intentionally,
- * are not included here.
+ * The purpose of this test is to reduce the maximal assertion message size
+ * in order to trigger the "Message string too long" error.
  */
 
 #include <stdlib.h>
diff --git a/tests/test_env_max_msg_size.sh b/tests/test_env_max_msg_size.sh
deleted file mode 100755 (executable)
index 97c21e9..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env sh
-
-UNIT_TEST=./check_set_max_msg_size
-MAX_MESSAGE_LOG_FILE=${UNIT_TEST}.env.output
-TOO_LONG_MESSAGE="Message string too long"
-
-# This test reduces the maximal message size using the environment variable,
-# so that the assertion message becomes too long.
-# Setting the maximal size to 4K via the check_set_max_msg_size function will be ignored
-# due to setting the environment variable to 32, which is shorter than the message.
-
-rm -f ${MAX_MESSAGE_LOG_FILE}
-export CK_MAX_MSG_SIZE=32
-${UNIT_TEST} 4096 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
-
-NUM_TOO_LONG_MESSAGES=$(grep "${TOO_LONG_MESSAGE}" ${MAX_MESSAGE_LOG_FILE} | wc -l)
-
-if test ${NUM_TOO_LONG_MESSAGES} -gt 0; then
-    echo "Maximal message size was reduced."
-    rm -f ${MAX_MESSAGE_LOG_FILE}
-    exit 0
-else
-    echo "ERROR: Maximal message size was not reduced."
-    echo "Test output was preserved in ${MAX_MESSAGE_LOG_FILE}"
-    exit 1
-fi
index 830fb12e24f64694f0c22574889cd6af5058fbbe..84a1ef6d9f4450a13479a9909cdb411d852ba463 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env sh
 
 UNIT_TEST=./check_set_max_msg_size
-MAX_MESSAGE_LOG_FILE=${UNIT_TEST}.set.output
+MAX_MESSAGE_LOG_FILE=${UNIT_TEST}.output
 TOO_LONG_MESSAGE="Message string too long"
 
 # This test reduces the maximal message size using the provided function,
@@ -14,11 +14,27 @@ ${UNIT_TEST} 32 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
 NUM_TOO_LONG_MESSAGES=$(grep "${TOO_LONG_MESSAGE}" ${MAX_MESSAGE_LOG_FILE} | wc -l)
 
 if test ${NUM_TOO_LONG_MESSAGES} -gt 0; then
-    echo "Maximal message size was reduced."
+    echo "Maximal message size was reduced by function call."
     rm -f ${MAX_MESSAGE_LOG_FILE}
-    exit 0
 else
-    echo "ERROR: Maximal message size was not reduced."
+    echo "ERROR: Maximal message size was not reduced by function call."
     echo "Test output was preserved in ${MAX_MESSAGE_LOG_FILE}"
     exit 1
 fi
+
+rm -f ${MAX_MESSAGE_LOG_FILE}
+export CK_MAX_MSG_SIZE=32
+${UNIT_TEST} 4096 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
+
+NUM_TOO_LONG_MESSAGES=$(grep "${TOO_LONG_MESSAGE}" ${MAX_MESSAGE_LOG_FILE} | wc -l)
+
+if test ${NUM_TOO_LONG_MESSAGES} -gt 0; then
+    echo "Maximal message size was reduced by environment variable."
+else
+    echo "ERROR: Maximal message size was not reduced by environment variable."
+    echo "Test output was preserved in ${MAX_MESSAGE_LOG_FILE}"
+    exit 1
+fi
+
+rm -f ${MAX_MESSAGE_LOG_FILE}
+exit 0