]> granicus.if.org Git - check/commitdiff
Merge check max msg size tests, fix comments.
authorOren Ben-Kiki <oren@ben-kiki.org>
Mon, 28 Aug 2017 04:52:31 +0000 (07:52 +0300)
committerOren Ben-Kiki <oren@ben-kiki.org>
Mon, 28 Aug 2017 04:52:31 +0000 (07:52 +0300)
tests/CMakeLists.txt
tests/Makefile.am
tests/check_env_max_msg_size.c [deleted file]
tests/check_set_max_msg_size.c
tests/test_env_max_msg_size.sh
tests/test_set_max_msg_size.sh

index a37c067e33ba0b0de2b5dbfaa39df4b862025fe9..b3d7ab7e73d6df6499dd52e973a5982dc74e1972 100644 (file)
@@ -86,10 +86,6 @@ set(CHECK_NOFORK_TEARDOWN_SOURCES check_nofork_teardown.c)
 add_executable(check_nofork_teardown ${CHECK_NOFORK_TEARDOWN_SOURCES})
 target_link_libraries(check_nofork_teardown check compat)
 
-set(CHECK_ENV_MAX_MSG_SIZE_SOURCES check_env_max_msg_size.c)
-add_executable(check_env_max_msg_size ${CHECK_ENV_MAX_MSG_SIZE_SOURCES})
-target_link_libraries(check_env_max_msg_size check compat)
-
 set(CHECK_SET_MAX_MSG_SIZE_SOURCES check_set_max_msg_size.c)
 add_executable(check_set_max_msg_size ${CHECK_SET_MAX_MSG_SIZE_SOURCES})
 target_link_libraries(check_set_max_msg_size check compat)
index 6bc2e807aef70e2959c1a99d5b8f9f50396d8164..72da9825ef40eeeb420300588bf65a916fa9f12e 100644 (file)
@@ -28,7 +28,6 @@ noinst_PROGRAMS =             \
        check_nofork            \
        check_nofork_teardown \
        check_mem_leaks         \
-       check_env_max_msg_size  \
        check_set_max_msg_size  \
        ex_output
 
@@ -79,10 +78,6 @@ check_mem_leaks_SOURCES =    \
 check_mem_leaks_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la
 check_mem_leaks_CFLAGS = -DTIMEOUT_TESTS_ENABLED=0 -DMEMORY_LEAKING_TESTS_ENABLED=0
 
-check_env_max_msg_size_SOURCES =       \
-       check_env_max_msg_size.c
-check_env_max_msg_size_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la
-
 check_set_max_msg_size_SOURCES =       \
        check_set_max_msg_size.c
 check_set_max_msg_size_LDADD = $(top_builddir)/src/libcheck.la $(top_builddir)/lib/libcompat.la
diff --git a/tests/check_env_max_msg_size.c b/tests/check_env_max_msg_size.c
deleted file mode 100644 (file)
index 8cbb142..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Check: a unit test framework for C
- * Copyright (C) 2001, 2002 Arien Malec
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- */
-
-/**
- * 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.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <check.h>
-#include "config.h"
-#include "check_check.h"
-
-START_TEST(test_env_max_msg_size)
-{
-  ck_abort_msg("40 characters of an assertion message...");
-}
-END_TEST
-
-
-static Suite *make_env_max_msg_size_suite(void)
-{
-  Suite *s = suite_create("Check Env Max Msg Size");
-
-  TCase *tc_env_max_msg_size = tcase_create("Test Env Max Msg Size");
-
-  suite_add_tcase (s, tc_env_max_msg_size);
-
-  tcase_add_test (tc_env_max_msg_size, test_env_max_msg_size);
-
-  return s;
-}
-
-int main (void)
-{
-    int n;
-    SRunner *sr;
-
-    /*
-     * Run the test suite. This is intended to trigger the "Message is too long" error.
-     * Actual success/failure is determined by examining the output.
-     */
-    check_set_max_msg_size(4096); // This will have no effect due to the environment variable.
-    sr = srunner_create(make_env_max_msg_size_suite());
-    srunner_run_all(sr, CK_NORMAL);
-    srunner_free(sr);
-    return EXIT_SUCCESS;
-}
-
index 91dde70c83526bc870317095ede1472d74e1cc30..6bb23d19f518513192bc35f6d862f63ee700a148 100644 (file)
@@ -52,16 +52,21 @@ static Suite *make_set_max_msg_size_suite(void)
   return s;
 }
 
-int main (void)
+int main (int argc, char *argv[])
 {
     int n;
     SRunner *sr;
 
+    if (argc != 2) {
+        fprintf(stderr, "usage: %s max-msg-size\n", argv[0]);
+        return EXIT_FAILURE;
+    }
+
     /*
      * Run the test suite. This is intended to trigger the "Message is too long" error.
      * Actual success/failure is determined by examining the output.
      */
-    check_set_max_msg_size(32); // This will have an effect due to no environment variable.
+    check_set_max_msg_size(atoi(argv[1]));
     sr = srunner_create(make_set_max_msg_size_suite());
     srunner_run_all(sr, CK_NORMAL);
     srunner_free(sr);
index 6990cdddc7a592dfe5f8ae3a9161cf291e3eb410..0feaed5c978a665ad823f39a18637773de4184ae 100755 (executable)
@@ -1,15 +1,17 @@
 #!/usr/bin/env sh
 
-UNIT_TEST=./check_env_max_msg_size
+UNIT_TEST=./check_set_max_msg_size
 MAX_MESSAGE_LOG_FILE=${UNIT_TEST}.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} 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
+${UNIT_TEST} 4096 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
 
 NUM_TOO_LONG_MESSAGES=$(grep "${TOO_LONG_MESSAGE}" ${MAX_MESSAGE_LOG_FILE} | wc -l)
 
index 932ce680ce559843ba7e3ad7671f0933ee1eb49f..92a5b499e671b92af8c06cae664af21de3bfb7de 100755 (executable)
@@ -6,10 +6,10 @@ TOO_LONG_MESSAGE="Message string too long"
 
 # This test reduces the maximal message size using the provided function,
 # so that the assertion message becomes too long.
+# We set the maximal size to 32, which is shorter than the message.
 
 rm -f ${MAX_MESSAGE_LOG_FILE}
-
-${UNIT_TEST} 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
+${UNIT_TEST} 32 2>&1 | tee ${MAX_MESSAGE_LOG_FILE}
 
 NUM_TOO_LONG_MESSAGES=$(grep "${TOO_LONG_MESSAGE}" ${MAX_MESSAGE_LOG_FILE} | wc -l)