From 5414ae3b90abc54deba9a235954ea1f47c310619 Mon Sep 17 00:00:00 2001 From: amalec Date: Sat, 18 Aug 2001 05:15:48 +0000 Subject: [PATCH] Bug fixes and assorted cleanup prior to release git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@74 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- check/Doxyfile | 20 ++++-- check/configure | 79 ++++++++++++------------ check/configure.in | 3 + check/debian/check.postinst.debhelper | 5 ++ check/debian/check.prerm.debhelper | 6 ++ check/debian/files | 2 +- check/doc/Makefile.in | 6 +- check/doc/tutorial.lyx | 32 +++++++++- check/rpm/Makefile.am | 2 +- check/rpm/Makefile.in | 2 +- check/rpm/check.spec | 15 ++--- check/src/check.c | 1 + check/src/check.h | 88 ++++++++++++++++++--------- check/src/check_log.c | 3 - check/src/check_msg.c | 1 + check/src/check_print.c | 4 ++ check/src/check_run.c | 2 +- check/tests/check_check_log.c | 1 + check/tests/check_check_master.c | 30 +++++++-- check/tests/check_check_msg.c | 3 +- check/tests/check_list.c | 2 +- check/tests/check_stress.c | 3 +- check/tests/ex_log_output.c | 6 +- check/tests/ex_output.c | 4 +- 24 files changed, 216 insertions(+), 104 deletions(-) diff --git a/check/Doxyfile b/check/Doxyfile index 7f548ba..ec744fb 100644 --- a/check/Doxyfile +++ b/check/Doxyfile @@ -1,10 +1,11 @@ -# Doxygen configuration generated by Doxywizard version 0.1 +# Doxyfile 0.1 + #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = Check PROJECT_NUMBER = 0.7.0 -OUTPUT_DIRECTORY = /home/amalec/check/doc/ +OUTPUT_DIRECTORY = ./doc/ OUTPUT_LANGUAGE = English EXTRACT_ALL = NO EXTRACT_PRIVATE = NO @@ -22,6 +23,7 @@ SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES CASE_SENSE_NAMES = YES +SHORT_NAMES = NO HIDE_SCOPE_NAMES = NO VERBATIM_HEADERS = YES SHOW_INCLUDE_FILES = YES @@ -50,7 +52,7 @@ WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = /home/amalec/check/src/check.h +INPUT = ./src/check.h FILE_PATTERNS = RECURSIVE = NO EXCLUDE = @@ -69,7 +71,7 @@ IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- -GENERATE_HTML = YES +GENERATE_HTML = NO HTML_OUTPUT = HTML_HEADER = HTML_FOOTER = @@ -88,7 +90,7 @@ TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- GENERATE_LATEX = YES LATEX_OUTPUT = -COMPACT_LATEX = NO +COMPACT_LATEX = YES PAPER_TYPE = letter EXTRA_PACKAGES = LATEX_HEADER = @@ -103,12 +105,18 @@ RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- -GENERATE_MAN = NO +GENERATE_MAN = YES MAN_OUTPUT = man MAN_EXTENSION = .3 +MAN_LINKS = YES +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- diff --git a/check/configure b/check/configure index 487e016..ffa7655 100755 --- a/check/configure +++ b/check/configure @@ -1169,8 +1169,11 @@ else echo "$ac_t""no" 1>&6 fi +if test -n "$GCC"; then + CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes" +fi echo $ac_n "checking for lyx with linuxdoc""... $ac_c" 1>&6 -echo "configure:1174: checking for lyx with linuxdoc" >&5 +echo "configure:1177: checking for lyx with linuxdoc" >&5 ck_lyxchkconfig="chkconfig.ltx" ck_lyxenvdir="$LYX_DIR_11x" @@ -1197,7 +1200,7 @@ fi # Extract the first word of "sgml2html", so it can be a program name with args. set dummy sgml2html; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1201: checking for $ac_word" >&5 +echo "configure:1204: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_have_sgmltools'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1237,7 +1240,7 @@ else fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1241: checking how to run the C preprocessor" >&5 +echo "configure:1244: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1252,13 +1255,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1262: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1265: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1269,13 +1272,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1279: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1282: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1286,13 +1289,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1296: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1299: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1317,12 +1320,12 @@ fi echo "$ac_t""$CPP" 1>&6 echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:1321: checking for ANSI C header files" >&5 +echo "configure:1324: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1330,7 +1333,7 @@ else #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1334: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1337: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1347,7 +1350,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1365,7 +1368,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1386,7 +1389,7 @@ if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1397,7 +1400,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF -if { (eval echo configure:1401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -1421,12 +1424,12 @@ EOF fi echo $ac_n "checking for sys/wait.h that is POSIX.1 compatible""... $ac_c" 1>&6 -echo "configure:1425: checking for sys/wait.h that is POSIX.1 compatible" >&5 +echo "configure:1428: checking for sys/wait.h that is POSIX.1 compatible" >&5 if eval "test \"`echo '$''{'ac_cv_header_sys_wait_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1442,7 +1445,7 @@ wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } EOF -if { (eval echo configure:1446: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1449: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_sys_wait_h=yes else @@ -1466,17 +1469,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1470: checking for $ac_hdr" >&5 +echo "configure:1473: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1480: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1483: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1507,12 +1510,12 @@ done echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:1511: checking for working const" >&5 +echo "configure:1514: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1568: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -1582,12 +1585,12 @@ EOF fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:1586: checking for pid_t" >&5 +echo "configure:1589: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1615,12 +1618,12 @@ EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:1619: checking for size_t" >&5 +echo "configure:1622: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1649,12 +1652,12 @@ fi echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:1653: checking for vprintf" >&5 +echo "configure:1656: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1684: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -1701,12 +1704,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:1705: checking for _doprnt" >&5 +echo "configure:1708: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1736: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -1756,12 +1759,12 @@ fi for ac_func in strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1760: checking for $ac_func" >&5 +echo "configure:1763: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else diff --git a/check/configure.in b/check/configure.in index 10899d3..3a36f5a 100644 --- a/check/configure.in +++ b/check/configure.in @@ -17,6 +17,9 @@ AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S AC_PROG_RANLIB +if test -n "$GCC"; then + CFLAGS="$CFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes" +fi CK_LYX_LINUXDOC([have_lyx="yes"],[have_lyx="no"]) AC_CHECK_PROG(have_sgmltools,sgml2html,yes) if test x"$have_sgmltools" != "xyes" -o x"$have_lyx" != "xyes" ; then diff --git a/check/debian/check.postinst.debhelper b/check/debian/check.postinst.debhelper index 38c9e0a..af24646 100644 --- a/check/debian/check.postinst.debhelper +++ b/check/debian/check.postinst.debhelper @@ -5,3 +5,8 @@ if [ "$1" = "configure" ]; then fi fi # End automatically added section +# Automatically added by dh_installdocs +if [ "$1" = configure ] && command -v install-docs >/dev/null 2>&1; then + install-docs -i /usr/share/doc-base/check-tutorial +fi +# End automatically added section diff --git a/check/debian/check.prerm.debhelper b/check/debian/check.prerm.debhelper index f67b9a4..2cd4a33 100644 --- a/check/debian/check.prerm.debhelper +++ b/check/debian/check.prerm.debhelper @@ -3,3 +3,9 @@ if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/check ]; then rm -f /usr/doc/check fi # End automatically added section +# Automatically added by dh_installdocs +if [ "$1" = remove -o "$1" = upgrade ] && \ + command -v install-docs >/dev/null 2>&1; then + install-docs -r check-tutorial +fi +# End automatically added section diff --git a/check/debian/files b/check/debian/files index b1121ff..ad2a251 100644 --- a/check/debian/files +++ b/check/debian/files @@ -1 +1 @@ -check_0.7.1-1_i386.deb devel optional +check_0.7.2-1_i386.deb devel optional diff --git a/check/doc/Makefile.in b/check/doc/Makefile.in index 563392a..e384b5c 100644 --- a/check/doc/Makefile.in +++ b/check/doc/Makefile.in @@ -73,9 +73,9 @@ SUBDIRS = money SUFFIXES = .sgml -lyx_docs = example.lyx -sgml_docs = example.sgml -html_docs = example.html example-1.html example-2.html example-3.html example-4.html +lyx_docs = tutorial.lyx +sgml_docs = tutorial.sgml +html_docs = tutorial.html tutorial-1.html tutorial-2.html tutorial-3.html tutorial-4.html EXTRA_DIST = $(lyx_docs) diff --git a/check/doc/tutorial.lyx b/check/doc/tutorial.lyx index cf0cf3a..f49e7c7 100644 --- a/check/doc/tutorial.lyx +++ b/check/doc/tutorial.lyx @@ -587,6 +587,18 @@ Most of the money_suite code should be self-explanatory. stay relatively clean and simple. \layout Standard +Unit tests are internally defined as static functions. + This means that the code to add unit tests to test cases must be in the + same compilation unit as the unit tests themselves. + This provides another reason to put the creation of the test suite in a + separate function: you may later want to keep one source file per suite; + defining a uniquely named suite creation function allows you later to define + a header file giving prototypes for all the suite creation functions, and + encapsulate the details of where and how unit tests are defined behind + those functions. + See the test program defined for Check itself for an example of this strategy. +\layout Standard + The code in main bears some explanation. We are creating a suite runner object from the suite we created in money_suite. We then run the suite, using the CRNORMAL flag to specify that we should @@ -898,12 +910,30 @@ START_TEST(test_create) END_TEST \end_deeper +\layout Standard + +There are currently some limitations to the setup/teardown functions. + They are run outside of the unit tests, and in the same address space as + the main test program. + This means two things: +\layout Enumerate + +If the setup or teardown functions signal or exit they will take down the + entire test program. +\layout Enumerate + +fail and friends can't be used within the setup/teardown functions to test + setup code. +\layout Standard + +The setup and teardown functions are always called (unless, of course, setup + brings down the whole test program :-). \layout Subsection Multiple suites run through the same SRunner \layout Standard -In a large program, it will be convenient to create mutiple suites, each +In a large program, it will be convenient to create multiple suites, each testing a module of the program. While one can create several test programs, each running one Suite, it may be convenient to create one main test program, and use it to run multiple diff --git a/check/rpm/Makefile.am b/check/rpm/Makefile.am index e4aa510..2657fd9 100644 --- a/check/rpm/Makefile.am +++ b/check/rpm/Makefile.am @@ -2,7 +2,7 @@ WD=`pwd` TOPDIRFLAGS=--define "_topdir ${WD}" RPMFLAGS= -EXTRA_DISTS=check.spec +EXTRA_DIST=check.spec SOURCE_FILE=${PACKAGE}-${VERSION}.tar.gz RPM_I386=./RPMS/i386/${PACKAGE}-$(VERSION)-1.i386.rpm diff --git a/check/rpm/Makefile.in b/check/rpm/Makefile.in index 9ff5029..7f1630a 100644 --- a/check/rpm/Makefile.in +++ b/check/rpm/Makefile.in @@ -70,7 +70,7 @@ WD = `pwd` TOPDIRFLAGS = --define "_topdir ${WD}" RPMFLAGS = -EXTRA_DISTS = check.spec +EXTRA_DIST = check.spec SOURCE_FILE = ${PACKAGE}-${VERSION}.tar.gz RPM_I386 = ./RPMS/i386/${PACKAGE}-$(VERSION)-1.i386.rpm diff --git a/check/rpm/check.spec b/check/rpm/check.spec index ae02906..e19b8f5 100644 --- a/check/rpm/check.spec +++ b/check/rpm/check.spec @@ -42,13 +42,13 @@ rm -rf ${RPM_BUILD_ROOT} %doc %{_prefix}/share/doc/%{name}-%{version}/NEWS %doc %{_prefix}/share/doc/%{name}-%{version}/README %doc %{_prefix}/share/doc/%{name}-%{version}/COPYING -%doc %{_prefix}/share/doc/%{name}-%{version}/example-1.html -%doc %{_prefix}/share/doc/%{name}-%{version}/example-2.html -%doc %{_prefix}/share/doc/%{name}-%{version}/example-3.html -%doc %{_prefix}/share/doc/%{name}-%{version}/example-4.html -%doc %{_prefix}/share/doc/%{name}-%{version}/example.html -%doc %{_prefix}/share/doc/%{name}-%{version}/example.lyx -%doc %{_prefix}/share/doc/%{name}-%{version}/example.sgml +%doc %{_prefix}/share/doc/%{name}-%{version}/tutorial.html +%doc %{_prefix}/share/doc/%{name}-%{version}/tutorial-1.html +%doc %{_prefix}/share/doc/%{name}-%{version}/tutorial-2.html +%doc %{_prefix}/share/doc/%{name}-%{version}/tutorial-3.html +%doc %{_prefix}/share/doc/%{name}-%{version}/tutorial-4.html +%doc %{_prefix}/share/doc/%{name}-%{version}/tutorial.lyx +%doc %{_prefix}/share/doc/%{name}-%{version}/tutorial.sgml %dir %{_prefix}/share/doc/%{name}-%{version}/examples %doc %{_prefix}/share/doc/%{name}-%{version}/examples/money.h %doc %{_prefix}/share/doc/%{name}-%{version}/examples/money.c @@ -61,6 +61,7 @@ rm -rf ${RPM_BUILD_ROOT} - Updated for 0.7.2 - Moved money example files to example subdirectory, and removed some confusing files +- Renamed the Tutorial files tutorial*.* * Tue Jul 30 2001 Arien Malec - Updated for 0.7.1 * Tue Jul 10 2001 Arien Malec diff --git a/check/src/check.c b/check/src/check.c index 92057a8..79607d2 100644 --- a/check/src/check.c +++ b/check/src/check.c @@ -18,6 +18,7 @@ */ #include #include +#include #include "error.h" #include "list.h" #include "check.h" diff --git a/check/src/check.h b/check/src/check.h index 086e58d..208c8ab 100644 --- a/check/src/check.h +++ b/check/src/check.h @@ -20,31 +20,52 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Comments are in Doxygen format: see http://www.stack.nl/~dimitri/doxygen/ */ + /*! \mainpage Check: a unit test framework for C -\section overview Overview -Check is a unit test framework for C. It features a simple interface for defining unit tests, putting little in the way of the developer. Tests are run in a separate address space, so Check can catch both assertion failures and code errors that cause segmentation faults or other signals. The output from unit tests can be used within source code editors and IDEs. +\section overview + +Overview Check is a unit test framework for C. It features a simple +interface for defining unit tests, putting little in the way of the +developer. Tests are run in a separate address space, so Check can +catch both assertion failures and code errors that cause segmentation +faults or other signals. The output from unit tests can be used within +source code editors and IDEs. \section quickref Quick Reference \subsection creating Creating \par -Unit tests are created with the #START_TEST/#END_TEST macro pair. The #fail_unless and #fail macros are used for creating checks within unit tests; the #mark_point macro is useful for trapping the location of signals and/or early exits. + +Unit tests are created with the #START_TEST/#END_TEST macro pair. The +#fail_unless and #fail macros are used for creating checks within unit +tests; the #mark_point macro is useful for trapping the location of +signals and/or early exits. \subsection managing Managing test cases and suites \par -Test cases are created with #tcase_create, unit tests are added with #tcase_add_test + +Test cases are created with #tcase_create, unit tests are added +with #tcase_add_test + \par -Suites are created with #suite_create, freed with #suite_free; test cases are added with #suite_add_tcase + +Suites are created with #suite_create, freed with #suite_free; test +cases are added with #suite_add_tcase \subsection running Running suites \par -Suites are run through an SRunner, which is created with #srunner_create, freed with #srunner_free. Additional suites can be added to an SRunner with #srunner_add_suite. + +Suites are run through an SRunner, which is created with +#srunner_create, freed with #srunner_free. Additional suites can be +added to an SRunner with #srunner_add_suite. \par + Use #srunner_run_all to run a suite and print results. */ @@ -69,9 +90,12 @@ enum { typedef struct Suite Suite; /*! \brief opaque type for a test case - A TCase represents a test case. - Create with #tcase_create, free with #tcase_free. - For the moment, test cases can only be run through a suite */ + +A TCase represents a test case. Create with #tcase_create, free with +#tcase_free. For the moment, test cases can only be run through a +suite +*/ + typedef struct TCase TCase; /*! type for a test function */ @@ -104,11 +128,14 @@ void suite_add_tcase (Suite *s, TCase *tc); (function version -- use this when the macro won't work */ void _tcase_add_test (TCase *tc, TFun tf, char *fname); -/*! Add fixture setup/teardown functions to a test case - Note that setup/teardown functions are not run in a separate - address space, like test functions, and so must not - exit or signal (e.g., segfault) */ -void tc_set_fixture(TCase *tc, SFun setup, SFun teardown); +/*! + +Add fixture setup/teardown functions to a test case Note that +setup/teardown functions are not run in a separate address space, like +test functions, and so must not exit or signal (e.g., segfault) + +*/ +void tcase_set_fixture(TCase *tc, SFun setup, SFun teardown); /*! Internal function to mark the start of a test function */ void tcase_fn_start (int msqid, char *fname, char *file, int line); @@ -116,7 +143,7 @@ void tcase_fn_start (int msqid, char *fname, char *file, int line); /*! Start a unit test with START_TEST(unit_name), end with END_TEST One must use braces within a START_/END_ pair to declare new variables */ #define START_TEST(__testname)\ -void __testname (int __msqid)\ +static void __testname (int __msqid)\ {\ tcase_fn_start (__msqid,""# __testname, __FILE__, __LINE__); @@ -186,7 +213,7 @@ char *tr_tcname (TestResult *tr); SRunner *srunner_create (Suite *s); /*! Adds a Suite to an SRunner */ -void *srunner_add_suite (SRunner *sr, Suite *s); +void srunner_add_suite (SRunner *sr, Suite *s); /*! Frees an SRunner */ void srunner_free (SRunner *sr); @@ -208,21 +235,26 @@ int srunner_ntests_failed (SRunner *sr); int srunner_ntests_run (SRunner *sr); /*! \brief Return an array of results for all failures - Number of failures is equal to #srunner_nfailed_tests. - Memory is alloc'ed and must be freed, but individual - TestResults must not */ - TestResult **srunner_failures (SRunner *sr); - - /*! \brief Return an array of results for all run tests - Number of failrues is equal to #srunner_ntests_run - Memory is alloc'ed and must be freed, but individual - TestResults must not */ - TestResult **srunner_results (SRunner *sr); + + Number of failures is equal to #srunner_nfailed_tests. Memory is + alloc'ed and must be freed, but individual TestResults must not */ + +TestResult **srunner_failures (SRunner *sr); + +/*! \brief Return an array of results for all run tests + +Number of failrues is equal to #srunner_ntests_run Memory is alloc'ed +and must be freed, but individual TestResults must not */ + +TestResult **srunner_results (SRunner *sr); /* Printing */ /*! Print the results contained in an SRunner - \param sr SRunner for which results are printed - \param print_mode Specification of print verbosity, constrainted to enum #print_verbosity + +\param sr SRunner for which results are printed + +\param print_mode Specification of print verbosity, constrainted to +enum #print_verbosity */ void srunner_print (SRunner *sr, int print_mode); diff --git a/check/src/check_log.c b/check/src/check_log.c index a269758..501c68c 100644 --- a/check/src/check_log.c +++ b/check/src/check_log.c @@ -100,7 +100,6 @@ void stdout_lfun (SRunner *sr, FILE *file, enum print_verbosity printmode, { TestResult *tr; Suite *s; - List *trlst; switch (evt) { case CLSTART_SR: @@ -116,7 +115,6 @@ void stdout_lfun (SRunner *sr, FILE *file, enum print_verbosity printmode, break; case CLEND_SR: if (printmode > CRSILENT) { - TestStats *ts = sr->stats; fprintf (file, "\n"); srunner_fprint (file, sr, printmode); } @@ -139,7 +137,6 @@ void lfile_lfun (SRunner *sr, FILE *file, enum print_verbosity printmode, { TestResult *tr; Suite *s; - List *trlst; switch (evt) { case CLSTART_SR: diff --git a/check/src/check_msg.c b/check/src/check_msg.c index 76247bc..b87d187 100644 --- a/check/src/check_msg.c +++ b/check/src/check_msg.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/check/src/check_print.c b/check/src/check_print.c index 031d225..31de5b9 100644 --- a/check/src/check_print.c +++ b/check/src/check_print.c @@ -22,6 +22,7 @@ #include "list.h" #include "check_impl.h" #include "check_print.h" +#include "error.h" static void srunner_fprint_summary (FILE *file, SRunner *sr, int print_mode); static void srunner_fprint_results (FILE *file, SRunner *sr, int print_mode); @@ -98,5 +99,8 @@ static char *rtype_to_string (int rtype) case CRERROR: return "E"; break; + default: + eprintf("Bad argument %d to rtype_to_string", rtype); + return NULL; } } diff --git a/check/src/check_run.c b/check/src/check_run.c index 58bd2d5..6a2462f 100644 --- a/check/src/check_run.c +++ b/check/src/check_run.c @@ -58,7 +58,7 @@ SRunner *srunner_create (Suite *s) return sr; } -void *srunner_add_suite (SRunner *sr, Suite *s) +void srunner_add_suite (SRunner *sr, Suite *s) { list_add_end(sr->slst, s); } diff --git a/check/tests/check_check_log.c b/check/tests/check_check_log.c index ae55533..4e01473 100644 --- a/check/tests/check_check_log.c +++ b/check/tests/check_check_log.c @@ -1,6 +1,7 @@ #include #include #include +#include "check_check.h" START_TEST(test_set_log) diff --git a/check/tests/check_check_master.c b/check/tests/check_check_master.c index e91a2d5..eb34def 100644 --- a/check/tests/check_check_master.c +++ b/check/tests/check_check_master.c @@ -1,4 +1,5 @@ #include +#include #include #include "check_check.h" @@ -109,10 +110,27 @@ END_TEST START_TEST(test_check_failure_tcnames) { int i; + char *tcnamearr[] = { + "Simple Tests", + "Simple Tests", + "Simple Tests", + "Simple Tests", + "Signal Tests", + "Signal Tests", + "Signal Tests", + "Limit Tests", + "Limit Tests", + "Core"}; + for (i = 0; i < sub_nfailed; i++) { - - fail_unless (strcmp(tr_tcname(tr_fail_array[i]), "Check Servant") == 0, - "Bad test case name"); + char *tcname; + tcname = tr_tcname(tr_all_array[i]); + if (strcmp (tcname, tcnamearr[i]) != 0) { + char *emsg = malloc (CMAXMSG); + snprintf (emsg, CMAXMSG,"Expected %s, got %s", tcnamearr[i], tcname); + fail (emsg); + free (emsg); + } } } END_TEST @@ -169,7 +187,7 @@ START_TEST(test_check_all_ftypes) END_TEST int test_fixture_val = 0; -void test_fixture_setup (void) +static void test_fixture_setup (void) { test_fixture_val = 1; } @@ -182,7 +200,7 @@ START_TEST(test_setup) } END_TEST -void test_fixture_teardown (void) +static void test_fixture_teardown (void) { test_fixture_val = 3; } @@ -211,6 +229,7 @@ Suite *make_master_suite (void) tcase_add_test (tc_core, test_check_failure_ftypes); tcase_add_test (tc_core, test_check_failure_lnos); tcase_add_test (tc_core, test_check_failure_lfiles); + tcase_add_test (tc_core, test_check_failure_tcnames); tcase_add_test (tc_core, test_check_all_msgs); tcase_add_test (tc_core, test_check_all_ftypes); tcase_set_fixture(tc_fixture, test_fixture_setup, test_fixture_teardown); @@ -229,7 +248,6 @@ Suite *make_master_suite (void) void setup (void) { - char *msg; Suite *s = make_sub_suite(); SRunner *sr = srunner_create(s); srunner_add_suite(sr, make_sub2_suite()); diff --git a/check/tests/check_check_msg.c b/check/tests/check_check_msg.c index 6af79d6..070756b 100644 --- a/check/tests/check_check_msg.c +++ b/check/tests/check_check_msg.c @@ -1,9 +1,10 @@ #include #include #include "check_msg.h" +#include "check_check.h" int msq; -void msg_setup (void) +static void msg_setup (void) { /* Note that we are really sharing the same msq as check itself, since all msqs created by diff --git a/check/tests/check_list.c b/check/tests/check_list.c index ed4fef3..61978b3 100644 --- a/check/tests/check_list.c +++ b/check/tests/check_list.c @@ -2,7 +2,7 @@ #include #include "list.h" #include "check.h" - +#include "check_check.h" START_TEST(test_create) { diff --git a/check/tests/check_stress.c b/check/tests/check_stress.c index e554513..cd7b587 100644 --- a/check/tests/check_stress.c +++ b/check/tests/check_stress.c @@ -1,5 +1,6 @@ #include #include +#include #include @@ -20,7 +21,7 @@ START_TEST(test_fail) END_TEST -void run (int num_iters) +static void run (int num_iters) { int i; s = suite_create ("Stress"); diff --git a/check/tests/ex_log_output.c b/check/tests/ex_log_output.c index 4f9430a..f21289d 100644 --- a/check/tests/ex_log_output.c +++ b/check/tests/ex_log_output.c @@ -26,7 +26,7 @@ START_TEST(test_pass2) } END_TEST -Suite *make_s1_suite (void) +static Suite *make_s1_suite (void) { Suite *s; TCase *tc; @@ -41,7 +41,7 @@ Suite *make_s1_suite (void) return s; } -Suite *make_s2_suite (void) +static Suite *make_s2_suite (void) { Suite *s; TCase *tc; @@ -54,7 +54,7 @@ Suite *make_s2_suite (void) return s; } -void run_tests (int printmode) +static void run_tests (int printmode) { SRunner *sr; diff --git a/check/tests/ex_output.c b/check/tests/ex_output.c index 9d0b1ab..a95957b 100644 --- a/check/tests/ex_output.c +++ b/check/tests/ex_output.c @@ -20,7 +20,7 @@ START_TEST(test_exit) } END_TEST -Suite *make_suite (void) +static Suite *make_suite (void) { Suite *s; TCase *tc; @@ -35,7 +35,7 @@ Suite *make_suite (void) return s; } -void run_tests (int printmode) +static void run_tests (int printmode) { SRunner *sr; Suite *s; -- 2.40.0