Blame tests/test_set_max_msg_size.sh

Packit 0b5880
#!/usr/bin/env sh
Packit 0b5880
Packit 0b5880
UNIT_TEST=./check_set_max_msg_size
Packit 0b5880
MAX_MESSAGE_LOG_FILE=${UNIT_TEST}.output
Packit 0b5880
TOO_LONG_MESSAGE="Message string too long"
Packit 0b5880
Packit 0b5880
# This test reduces the maximal message size using the provided function,
Packit 0b5880
# so that the assertion message becomes too long.
Packit 0b5880
# We set the maximal size to 32, which is shorter than the message.
Packit 0b5880
Packit 0b5880
rm -f ${MAX_MESSAGE_LOG_FILE}
Packit 0b5880
${UNIT_TEST} 32 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
Packit 0b5880
Packit 0b5880
NUM_TOO_LONG_MESSAGES=$(grep "${TOO_LONG_MESSAGE}" ${MAX_MESSAGE_LOG_FILE} | wc -l)
Packit 0b5880
Packit 0b5880
if test ${NUM_TOO_LONG_MESSAGES} -gt 0; then
Packit 0b5880
    echo "Maximal message size was reduced by function call."
Packit 0b5880
    rm -f ${MAX_MESSAGE_LOG_FILE}
Packit 0b5880
else
Packit 0b5880
    echo "ERROR: Maximal message size was not reduced by function call."
Packit 0b5880
    echo "Test output was preserved in ${MAX_MESSAGE_LOG_FILE}"
Packit 0b5880
    exit 1
Packit 0b5880
fi
Packit 0b5880
Packit 0b5880
rm -f ${MAX_MESSAGE_LOG_FILE}
Packit 0b5880
export CK_MAX_MSG_SIZE=32
Packit 0b5880
${UNIT_TEST} 4096 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
Packit 0b5880
Packit 0b5880
NUM_TOO_LONG_MESSAGES=$(grep "${TOO_LONG_MESSAGE}" ${MAX_MESSAGE_LOG_FILE} | wc -l)
Packit 0b5880
Packit 0b5880
if test ${NUM_TOO_LONG_MESSAGES} -gt 0; then
Packit 0b5880
    echo "Maximal message size was reduced by environment variable."
Packit 0b5880
else
Packit 0b5880
    echo "ERROR: Maximal message size was not reduced by environment variable."
Packit 0b5880
    echo "Test output was preserved in ${MAX_MESSAGE_LOG_FILE}"
Packit 0b5880
    exit 1
Packit 0b5880
fi
Packit 0b5880
Packit 0b5880
rm -f ${MAX_MESSAGE_LOG_FILE}
Packit 0b5880
exit 0