INN commit: trunk (5 files)

INN Commit rra at isc.org
Tue Jul 12 12:59:21 UTC 2011


    Date: Tuesday, July 12, 2011 @ 05:59:21
  Author: iulius
Revision: 9243

synchronize the test suite with C TAP Harness 1.7

Modified:
  trunk/doc/pod/hacking.pod
  trunk/tests/libtest.c
  trunk/tests/libtest.h
  trunk/tests/libtest.sh
  trunk/tests/runtests.c

---------------------+
 doc/pod/hacking.pod |   20 ++++++++++++
 tests/libtest.c     |   58 +++++++++++++++++++++--------------
 tests/libtest.h     |   82 +++++++++++++++++++++++++++++++++-----------------
 tests/libtest.sh    |    3 +
 tests/runtests.c    |   78 ++++++++++++++++++++++++++++++++++++-----------
 5 files changed, 173 insertions(+), 68 deletions(-)

Modified: doc/pod/hacking.pod
===================================================================
--- doc/pod/hacking.pod	2011-07-12 12:58:00 UTC (rev 9242)
+++ doc/pod/hacking.pod	2011-07-12 12:59:21 UTC (rev 9243)
@@ -609,12 +609,32 @@
 
 =item 1.
 
+Update the files shipped with INN, and that are maintained by external
+projects.
+
+=over 2
+
+=item *
+
 Make sure that F<support/config.guess>, F<support/config.sub>,
 F<support/install-sh>, F<support/ltmain.sh> and libtool m4 files
 (F<libtool.m4>, F<ltoptions.m4>, F<ltsugar.m4>, F<ltversion.m4>
 and F<lt~obsolete.m4>) are the latest versions.  See the instructions
 in L<"Configuring and Portability"> for details on how to update these files.
 
+=item *
+
+Make sure that the latest version of C TAP Harness
+is used for the test suite.  It is available from
+L<http://www.eyrie.org/~eagle/software/c-tap-harness/>.  The file
+F<runtests.c> should be updated.  F<libtest.c>, F<libtest.h> and
+F<libtest.sh> come from F<tap/basic.c>, F<tap/basic.h> and F<tap/libtap.sh>
+respectively.  Parts specific to INN should be kept during an update
+(especially sections relative to LIBTEST_NEW_FORMAT because the test suite
+has not yet been updated to use the new format of C TAP Harness).
+
+=back
+
 =item 2.
 
 Make sure that F<samples/control.ctl> and F<samples/nocem.ctl> are in sync

Modified: tests/libtest.c
===================================================================
--- tests/libtest.c	2011-07-12 12:58:00 UTC (rev 9242)
+++ tests/libtest.c	2011-07-12 12:59:21 UTC (rev 9243)
@@ -14,38 +14,52 @@
  * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
  * Copyright 2009, 2010 Russ Allbery <rra at stanford.edu>
- * Copyright 2006, 2007, 2008
- *     Board of Trustees, Leland Stanford Jr. University
- * Copyright (c) 2004, 2005, 2006
- *     by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- *     2002, 2003 by The Internet Software Consortium and Rich Salz
+ * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * This code is derived from software contributed to the Internet Software
- * Consortium by Rich Salz.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
-#include "config.h"
-#include "clibrary.h"
+/* Required for isnan() and isinf(). */
+#ifndef _XOPEN_SOURCE
+# define _XOPEN_SOURCE 600
+#endif
 
-#include "inn/messages.h"
-#include "inn/libinn.h"
 #include <errno.h>
 #include <math.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
 #include "libtest.h"
 
+/* Specific to the integration of C TAP Harness in INN. */
+#ifndef LIBTEST_NEW_FORMAT
+# include "inn/messages.h"
+# include "inn/libinn.h"
+#endif
+
 /*
  * The test count.  Always contains the number that will be used for the next
  * test status.

Modified: tests/libtest.h
===================================================================
--- tests/libtest.h	2011-07-12 12:58:00 UTC (rev 9242)
+++ tests/libtest.h	2011-07-12 12:59:21 UTC (rev 9243)
@@ -6,40 +6,68 @@
  * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
  * Copyright 2009, 2010 Russ Allbery <rra at stanford.edu>
- * Copyright 2006, 2007, 2008
- *     Board of Trustees, Leland Stanford Jr. University
- * Copyright (c) 2004, 2005, 2006
- *     by Internet Systems Consortium, Inc. ("ISC")
- * Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- *     2002, 2003 by The Internet Software Consortium and Rich Salz
+ * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008
+ *     The Board of Trustees of the Leland Stanford Junior University
  *
- * This code is derived from software contributed to the Internet Software
- * Consortium by Rich Salz.
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
  *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
  */
 
-#ifndef LIBTEST_H
-#define LIBTEST_H 1
+#ifndef TAP_BASIC_H
+#define TAP_BASIC_H 1
 
-/* These inclusions contain va_list, pid_t, __attribute__, BEGIN_DECLS,
- * END_DECLS, ARRAY_SIZE and ARRAY_END.  All used by C TAP Harness.
+#include <stdarg.h>             /* va_list */
+#include <sys/types.h>          /* pid_t */
+
+/*
+ * __attribute__ is available in gcc 2.5 and later, but only with gcc 2.7
+ * could you use the __format__ form of the attributes, which is what we use
+ * (to avoid confusion with other macros).
  */
-#include "config.h"
-#include "clibrary.h"
-                           
-#include <inn/defines.h>
+#ifndef __attribute__
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#  define __attribute__(spec)   /* empty */
+# endif
+#endif
 
+/*
+ * BEGIN_DECLS is used at the beginning of declarations so that C++
+ * compilers don't mangle their names.  END_DECLS is used at the end.
+ */
+#undef BEGIN_DECLS
+#undef END_DECLS
+#ifdef __cplusplus
+# define BEGIN_DECLS    extern "C" {
+# define END_DECLS      }
+#else
+# define BEGIN_DECLS    /* empty */
+# define END_DECLS      /* empty */
+#endif
+
+/*
+ * Used for iterating through arrays.  ARRAY_SIZE returns the number of
+ * elements in the array (useful for a < upper bound in a for loop) and
+ * ARRAY_END returns a pointer to the element past the end (ISO C99 makes it
+ * legal to refer to such a pointer as long as it's never dereferenced).
+ */
+#define ARRAY_SIZE(array)       (sizeof(array) / sizeof((array)[0]))
+#define ARRAY_END(array)        (&(array)[ARRAY_SIZE(array)])
+
 BEGIN_DECLS
 
 /*
@@ -142,4 +170,4 @@
 
 END_DECLS
 
-#endif /* LIBTEST_H */
+#endif /* TAP_BASIC_H */

Modified: tests/libtest.sh
===================================================================
--- tests/libtest.sh	2011-07-12 12:58:00 UTC (rev 9242)
+++ tests/libtest.sh	2011-07-12 12:59:21 UTC (rev 9243)
@@ -8,7 +8,8 @@
 #
 # Written by Russ Allbery <rra at stanford.edu>
 # Copyright 2009, 2010 Russ Allbery <rra at stanford.edu>
-# Copyright 2006, 2007, 2008 Board of Trustees, Leland Stanford Jr. University
+# Copyright 2006, 2007, 2008
+#     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
 # of this software and associated documentation files (the "Software"), to

Modified: tests/runtests.c
===================================================================
--- tests/runtests.c	2011-07-12 12:58:00 UTC (rev 9242)
+++ tests/runtests.c	2011-07-12 12:59:21 UTC (rev 9243)
@@ -7,16 +7,19 @@
  * added to the INN tree should also be reported to the above author if
  * necessary.
  *
+ * Based on C TAP Harness 1.7 (2011-04-28).
+ *
  * Usage:
  *
- *      runtests <test-list>
+ *      runtests [-b <build-dir>] [-s <source-dir>] <test-list>
+ *      runtests -o [-b <build-dir>] [-s <source-dir>] <test>
  *
- * Expects a list of executables located in the given file, one line per
- * executable.  For each one, runs it as part of a test suite, reporting
- * results.  Test output should start with a line containing the number of
- * tests (numbered from 1 to this number), optionally preceded by "1..",
- * although that line may be given anywhere in the output.  Each additional
- * line should be in the following format:
+ * In the first case, expects a list of executables located in the given file,
+ * one line per executable.  For each one, runs it as part of a test suite,
+ * reporting results.  Test output should start with a line containing the
+ * number of tests (numbered from 1 to this number), optionally preceded by
+ * "1..", although that line may be given anywhere in the output.  Each
+ * additional line should be in the following format:
  *
  *      ok <number>
  *      not ok <number>
@@ -45,11 +48,21 @@
  * This is a subset of TAP as documented in Test::Harness::TAP or
  * TAP::Parser::Grammar, which comes with Perl.
  *
+ * If the -o option is given, instead run a single test and display all of its
+ * output.  This is intended for use with failing tests so that the person
+ * running the test suite can get more details about what failed.
+ *
+ * If built with the C preprocessor symbols SOURCE and BUILD defined, C TAP
+ * Harness will export those values in the environment so that tests can find
+ * the source and build directory and will look for tests under both
+ * directories.  These paths can also be set with the -b and -s command-line
+ * options, which will override anything set at build time.
+ *
  * Any bug reports, bug fixes, and improvements are very much welcome and
  * should be sent to the e-mail address below.  This program is part of C TAP
  * Harness <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010
+ * Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011
  *     Russ Allbery <rra at stanford.edu>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -76,20 +89,28 @@
 # define _XOPEN_SOURCE 500
 #endif
 
-#include "config.h"
-#include "clibrary.h"
-#include "portable/wait.h"
-#include "portable/time.h"
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
 #include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <time.h>
+#include <unistd.h>
 
 /* sys/time.h must be included before sys/resource.h on some platforms. */
 #include <sys/resource.h>
 
-/* WCOREDUMP delt with by "portable/wait.h". */
+/* AIX doesn't have WCOREDUMP. */
+#ifndef WCOREDUMP
+# define WCOREDUMP(status)      ((unsigned)(status) & 0x80)
+#endif
 
 /*
  * The source and build versions of the tests directory.  This is used to set
@@ -152,6 +173,23 @@
 };
 
 /*
+ * Usage message.  Should be used as a printf format with two arguments: the
+ * path to runtests, given twice.
+ */
+static const char usage_message[] = "\
+Usage: %s [-b <build-dir>] [-s <source-dir>] <test-list>\n\
+       %s -o [-b <build-dir>] [-s <source-dir>] <test>\n\
+\n\
+Options:\n\
+    -b <build-dir>      Set the build directory to <build-dir>\n\
+    -o                  Run a single test rather than a list of tests\n\
+    -s <source-dir>     Set the source directory to <source-dir>\n\
+\n\
+runtests normally runs each test listed in a file whose path is given as\n\
+its command-line argument.  With the -o option, it instead runs a single\n\
+test and shows its complete output.\n";
+
+/*
  * Header used for test output.  %s is replaced by the file name of the list
  * of tests.
  */
@@ -1088,11 +1126,15 @@
     const char *source = SOURCE;
     const char *build = BUILD;
 
-    while ((option = getopt(argc, argv, "b:os:")) != EOF) {
+    while ((option = getopt(argc, argv, "b:hos:")) != EOF) {
         switch (option) {
         case 'b':
             build = optarg;
             break;
+        case 'h':
+            printf(usage_message, argv[0], argv[0]);
+            exit(0);
+            break;
         case 'o':
             single = 1;
             break;
@@ -1103,12 +1145,12 @@
             exit(1);
         }
     }
+    if (argc - optind != 1) {
+        fprintf(stderr, usage_message, argv[0], argv[0]);
+        exit(1);
+    }
     argc -= optind;
     argv += optind;
-    if (argc != 1) {
-        fprintf(stderr, "Usage: runtests <test-list>\n");
-        exit(1);
-    }
 
     if (source != NULL) {
         setting = xmalloc(strlen("SOURCE=") + strlen(source) + 1);




More information about the inn-committers mailing list