From: Oren Ben-Kiki Date: Tue, 29 Aug 2017 04:47:31 +0000 (+0300) Subject: Merge test scripts as well, fixed comments. X-Git-Tag: 0.12.0~3^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a9d595fe8712d21e27e4a584f9417ac08b730cd;p=check Merge test scripts as well, fixed comments. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 453b9ee..0d66a5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/check_pack.c b/src/check_pack.c index c1b77f2..6512fef 100644 --- a/src/check_pack.c +++ b/src/check_pack.c @@ -23,6 +23,7 @@ #include #include #include + #include "check.h" #include "check_error.h" #include "check_list.h" diff --git a/tests/Makefile.am b/tests/Makefile.am index 72da982..4616288 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/check_set_max_msg_size.c b/tests/check_set_max_msg_size.c index 6bb23d1..25c33f6 100644 --- a/tests/check_set_max_msg_size.c +++ b/tests/check_set_max_msg_size.c @@ -19,10 +19,8 @@ */ /** - * 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 diff --git a/tests/test_env_max_msg_size.sh b/tests/test_env_max_msg_size.sh deleted file mode 100755 index 97c21e9..0000000 --- a/tests/test_env_max_msg_size.sh +++ /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 diff --git a/tests/test_set_max_msg_size.sh b/tests/test_set_max_msg_size.sh index 830fb12..84a1ef6 100755 --- a/tests/test_set_max_msg_size.sh +++ b/tests/test_set_max_msg_size.sh @@ -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