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)
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+
#include "check.h"
#include "check_error.h"
#include "check_list.h"
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
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
*/
/**
- * 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>
+++ /dev/null
-#!/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
#!/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,
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