INN commit: trunk (7 files)

INN Commit rra at isc.org
Thu Apr 16 11:21:24 UTC 2015


    Date: Thursday, April 16, 2015 @ 04:21:24
  Author: iulius
Revision: 9824

Update to latest c-tap-harness from upstream

Major changes are:
* Local changes for INN's docs/pod.t test are now merged into
upstream.

* Add a -v command-line option that enables verbose support,
and rename the environment variable to C_TAP_VERBOSE.

* C TAP Harness now compiles cleanly with Clang with -Weverything
-Wno-padded -pedantic-errors.

Modified:
  trunk/support/getc-tap-harness
  trunk/tests/docs/pod.t
  trunk/tests/runtests.c
  trunk/tests/tap/basic.c
  trunk/tests/tap/basic.h
  trunk/tests/tap/float.c
  trunk/tests/tap/macros.h

--------------------------+
 support/getc-tap-harness |   19 ++----
 tests/docs/pod.t         |   22 ++++---
 tests/runtests.c         |  136 ++++++++++++++++++++++++++++++---------------
 tests/tap/basic.c        |   11 ++-
 tests/tap/basic.h        |    9 +-
 tests/tap/float.c        |    4 -
 tests/tap/macros.h       |    8 +-
 7 files changed, 132 insertions(+), 77 deletions(-)

Modified: support/getc-tap-harness
===================================================================
--- support/getc-tap-harness	2015-04-05 13:28:36 UTC (rev 9823)
+++ support/getc-tap-harness	2015-04-16 11:21:24 UTC (rev 9824)
@@ -60,12 +60,6 @@
 # \$Id\$\\
 #" \
                -e '5,9d' \
-               -e '/^use warnings;$/d' \
-               -e "62 i \\
-\$Test::Pod::ignore_dirs{'.libs'} = 'Libs';\\
-" \
-               -e "s/'docs'/'.'/g" \
-               -e 's/docs/root/g' \
                ${TEMP}
         chmod 755 ${TEMP}
       elif [ "$3" != "README" ]
@@ -79,7 +73,7 @@
     # Specific additions to a few files.
     if [ "$3" = "basic.c" ]
     then
-      sed -i -e "55 i \\
+      sed -i -e "57 i \\
 /* Specific to the integration of C TAP Harness in INN. */\\
 #ifndef LIBTEST_NEW_FORMAT\\
 # include \"inn/libinn.h\"\\
@@ -127,9 +121,9 @@
 }\\
 #endif\\
 " \
-             -e "150 i \\
+             -e "152 i \\
 #ifndef INN_LIBINN_H" \
-             -e "184 i \\
+             -e "186 i \\
 #endif" \
              -e 's/^ok.int /new_ok(int /g' \
              -e 's/^skip.const /new_skip(const /g' \
@@ -140,7 +134,7 @@
 
     if [ "$3" = "basic.h" ]
     then
-      sed -i -e "74 i \\
+      sed -i -e "75 i \\
 #ifndef LIBTEST_NEW_FORMAT\\
 /* Specific to the integration of C TAP Harness in INN. */\\
 void ok(int n, int success);\\
@@ -148,7 +142,8 @@
         __attribute__((__format__(printf, 2, 3)));\\
 void ok_int(int n, int wanted, int seen);\\
 void ok_string(int n, const char *wanted, const char *seen);\\
-int okv(int success, const char *format, va_list args);\\
+int okv(int success, const char *format, va_list args)\\
+        __attribute__((__format__(printf, 2, 0)));\\
 void skip(int n, const char *reason);\\
 void new_skip(const char *reason, ...)\\
         __attribute__((__format__(printf, 1, 2)));\\
@@ -165,7 +160,7 @@
 # define skip new_skip\\
 # define ok_block new_ok_block\\
 # define skip_block new_skip_block" \
-             -e "88 i \\
+             -e "90 i \\
 #endif" \
              ${TEMP}
     fi

Modified: tests/docs/pod.t
===================================================================
--- tests/docs/pod.t	2015-04-05 13:28:36 UTC (rev 9823)
+++ tests/docs/pod.t	2015-04-16 11:21:24 UTC (rev 9824)
@@ -7,7 +7,7 @@
 # This file is part of C TAP Harness.  The current version plus supporting
 # documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
 #
-# Copyright 2009, 2010, 2013, 2014 Russ Allbery <eagle at eyrie.org>
+# Copyright 2009, 2010, 2013, 2014, 2015 Russ Allbery <eagle at eyrie.org>
 #
 # Permission is hereby granted, free of charge, to any person obtaining a
 # copy of this software and associated documentation files (the "Software"),
@@ -29,6 +29,7 @@
 
 use 5.006;
 use strict;
+use warnings;
 
 use File::Spec;
 use Test::More;
@@ -55,12 +56,15 @@
 my $root = File::Spec->catpath($vol, File::Spec->catdir(@dirs), q{});
 chdir($root) or BAIL_OUT("cannot chdir to $root: $!");
 
-$Test::Pod::ignore_dirs{'.libs'} = 'Libs';
+# Add some additional exclusions, useful mostly for other programs that copy
+# this test.
+## no critic (TestingAndDebugging::ProhibitNoWarnings)
+## no critic (Variables::ProhibitPackageVars)
+{
+    no warnings 'once';
+    $Test::Pod::ignore_dirs{'.libs'} = 'libraries';
+}
+## use critic
 
-# Check spelling of everything in root if present, and any *.pod files in the
-# current directory.
-my @pod_files = glob('*.pod');
-if (-d '.') {
-    push(@pod_files, all_pod_files('.'));
-}
-all_pod_files_ok(@pod_files);
+# Check syntax of every POD file we can find.
+all_pod_files_ok(q{.});

Modified: tests/runtests.c
===================================================================
--- tests/runtests.c	2015-04-05 13:28:36 UTC (rev 9823)
+++ tests/runtests.c	2015-04-16 11:21:24 UTC (rev 9824)
@@ -60,7 +60,7 @@
  * Harness <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
  * Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
- *     2014 Russ Allbery <eagle at eyrie.org>
+ *     2014, 2015 Russ Allbery <eagle at eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -151,6 +151,12 @@
     TEST_INVALID
 };
 
+/* Really, just a boolean, but this is more self-documenting. */
+enum test_verbose {
+    CONCISE = 0,
+    VERBOSE = 1
+};
+
 /* Indicates the state of our plan. */
 enum plan_status {
     PLAN_INIT,                  /* Nothing seen yet. */
@@ -251,8 +257,10 @@
  * variadic macro support.
  */
 #if !defined(__attribute__) && !defined(__alloc_size__)
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
-#  define __alloc_size__(spec, args...) /* empty */
+# if defined(__GNUC__) && !defined(__clang__)
+#  if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+#   define __alloc_size__(spec, args...) /* empty */
+#  endif
 # endif
 #endif
 
@@ -596,13 +604,28 @@
 
 
 /*
+ * Report an invalid test number and set the appropriate flags.  Pulled into a
+ * separate function since we do this in several places.
+ */
+static void
+invalid_test_number(struct testset *ts, long n, enum test_verbose verbose)
+{
+    if (!verbose)
+        test_backspace(ts);
+    printf("ABORTED (invalid test number %ld)\n", n);
+    ts->aborted = 1;
+    ts->reported = 1;
+}
+
+
+/*
  * Read the plan line of test output, which should contain the range of test
  * numbers.  We may initialize the testset structure here if we haven't yet
  * seen a test.  Return true if initialization succeeded and the test should
  * continue, false otherwise.
  */
 static int
-test_plan(const char *line, struct testset *ts)
+test_plan(const char *line, struct testset *ts, enum test_verbose verbose)
 {
     long n;
 
@@ -659,10 +682,7 @@
      * range.
      */
     if (ts->plan == PLAN_PENDING && (unsigned long) n < ts->count) {
-        test_backspace(ts);
-        printf("ABORTED (invalid test number %lu)\n", ts->count);
-        ts->aborted = 1;
-        ts->reported = 1;
+        invalid_test_number(ts, (long) ts->count, verbose);
         return 0;
     }
 
@@ -670,8 +690,8 @@
      * Otherwise, allocated or resize the results if needed and update count,
      * and then record that we've seen a plan.
      */
-    resize_results(ts, n);
-    ts->count = n;
+    resize_results(ts, (unsigned long) n);
+    ts->count = (unsigned long) n;
     if (ts->plan == PLAN_INIT)
         ts->plan = PLAN_FIRST;
     else if (ts->plan == PLAN_PENDING)
@@ -687,7 +707,8 @@
  * reported status.
  */
 static void
-test_checkline(const char *line, struct testset *ts)
+test_checkline(const char *line, struct testset *ts,
+               enum test_verbose verbose)
 {
     enum test_status status = TEST_PASS;
     const char *bail;
@@ -706,7 +727,8 @@
             length = strlen(bail);
             if (bail[length - 1] == '\n')
                 length--;
-            test_backspace(ts);
+            if (!verbose)
+                test_backspace(ts);
             printf("ABORTED (%.*s)\n", (int) length, bail);
             ts->reported = 1;
         }
@@ -727,14 +749,15 @@
 
     /* If we haven't yet seen a plan, look for one. */
     if (ts->plan == PLAN_INIT && isdigit((unsigned char)(*line))) {
-        if (!test_plan(line, ts))
+        if (!test_plan(line, ts, verbose))
             return;
     } else if (strncmp(line, "1..", 3) == 0) {
         if (ts->plan == PLAN_PENDING) {
-            if (!test_plan(line, ts))
+            if (!test_plan(line, ts, verbose))
                 return;
         } else {
-            test_backspace(ts);
+            if (!verbose)
+                test_backspace(ts);
             puts("ABORTED (multiple plans)");
             ts->aborted = 1;
             ts->reported = 1;
@@ -753,14 +776,15 @@
     errno = 0;
     number = strtol(line, &end, 10);
     if (errno != 0 || end == line)
-        number = ts->current + 1;
-    current = number;
-    if (number <= 0 || (current > ts->count && ts->plan == PLAN_FIRST)) {
-        test_backspace(ts);
-        printf("ABORTED (invalid test number %lu)\n", current);
-        ts->aborted = 1;
-        ts->reported = 1;
+        current = ts->current + 1;
+    else if (number <= 0) {
+        invalid_test_number(ts, number, verbose);
         return;
+    } else
+        current = (unsigned long) number;
+    if (current > ts->count && ts->plan == PLAN_FIRST) {
+        invalid_test_number(ts, (long) current, verbose);
+        return;
     }
 
     /* We have a valid test result.  Tweak the results array if needed. */
@@ -788,7 +812,8 @@
 
     /* Make sure that the test number is in range and not a duplicate. */
     if (ts->results[current - 1] != TEST_INVALID) {
-        test_backspace(ts);
+        if (!verbose)
+            test_backspace(ts);
         printf("ABORTED (duplicate test number %lu)\n", current);
         ts->aborted = 1;
         ts->reported = 1;
@@ -804,13 +829,13 @@
     }
     ts->current = current;
     ts->results[current - 1] = status;
-    if (isatty(STDOUT_FILENO)) {
+    if (!verbose && isatty(STDOUT_FILENO)) {
         test_backspace(ts);
         if (ts->plan == PLAN_PENDING)
             outlen = printf("%lu/?", current);
         else
             outlen = printf("%lu/%lu", current, ts->count);
-        ts->length = (outlen >= 0) ? outlen : 0;
+        ts->length = (outlen >= 0) ? (unsigned int) outlen : 0;
         fflush(stdout);
     }
 }
@@ -826,7 +851,7 @@
  * disable this).
  */
 static unsigned int
-test_print_range(unsigned long first, unsigned long last, unsigned int chars,
+test_print_range(unsigned long first, unsigned long last, unsigned long chars,
                  unsigned int limit)
 {
     unsigned int needed = 0;
@@ -996,7 +1021,7 @@
  * false otherwise.
  */
 static int
-test_run(struct testset *ts)
+test_run(struct testset *ts, enum test_verbose verbose)
 {
     pid_t testpid, child;
     int outfd, status;
@@ -1013,12 +1038,19 @@
         sysdie("fdopen failed");
     }
 
-    /* Pass each line of output to test_checkline(). */
-    while (!ts->aborted && fgets(buffer, sizeof(buffer), output))
-        test_checkline(buffer, ts);
+    /*
+     * Pass each line of output to test_checkline(), and print the line if
+     * verbosity is requested.
+     */
+    while (!ts->aborted && fgets(buffer, sizeof(buffer), output)) {
+        if (verbose)
+            printf("%s", buffer);
+        test_checkline(buffer, ts, verbose);
+    }
     if (ferror(output) || ts->plan == PLAN_INIT)
         ts->aborted = 1;
-    test_backspace(ts);
+    if (!verbose)
+        test_backspace(ts);
 
     /*
      * Consume the rest of the test output, close the output descriptor,
@@ -1026,7 +1058,8 @@
      * for eventual output.
      */
     while (fgets(buffer, sizeof(buffer), output))
-        ;
+        if (verbose)
+            printf("%s", buffer);
     fclose(output);
     child = waitpid(testpid, &ts->status, 0);
     if (child == (pid_t) -1) {
@@ -1134,7 +1167,7 @@
 static char *
 find_test(const char *name, const char *source, const char *build)
 {
-    char *path;
+    char *path = NULL;
     const char *bases[3], *suffix, *base;
     unsigned int i, j;
     const char *suffixes[3] = { "-t", ".t", "" };
@@ -1278,11 +1311,11 @@
  * frees the test list that's passed in.
  */
 static int
-test_batch(struct testlist *tests, const char *source, const char *build)
+test_batch(struct testlist *tests, const char *source, const char *build,
+           enum test_verbose verbose)
 {
-    size_t length;
-    unsigned int i;
-    unsigned int longest = 0;
+    size_t length, i;
+    size_t longest = 0;
     unsigned int count = 0;
     struct testset *ts;
     struct timeval start, end;
@@ -1321,15 +1354,20 @@
 
         /* Print out the name of the test file. */
         fputs(ts->file, stdout);
-        for (i = strlen(ts->file); i < longest; i++)
-            putchar('.');
+        if (verbose)
+            fputs("\n\n", stdout);
+        else
+            for (i = strlen(ts->file); i < longest; i++)
+                putchar('.');
         if (isatty(STDOUT_FILENO))
             fflush(stdout);
 
         /* Run the test. */
         ts->path = find_test(ts->file, source, build);
-        succeeded = test_run(ts);
+        succeeded = test_run(ts, verbose);
         fflush(stdout);
+        if (verbose)
+            putchar('\n');
 
         /* Record cumulative statistics. */
         aborted += ts->aborted;
@@ -1431,6 +1469,7 @@
     int option;
     int status = 0;
     int single = 0;
+    enum test_verbose verbose = CONCISE;
     char *source_env = NULL;
     char *build_env = NULL;
     const char *program;
@@ -1441,7 +1480,7 @@
     struct testlist *tests;
 
     program = argv[0];
-    while ((option = getopt(argc, argv, "b:hl:os:")) != EOF) {
+    while ((option = getopt(argc, argv, "b:hl:os:v")) != EOF) {
         switch (option) {
         case 'b':
             build = optarg;
@@ -1449,7 +1488,6 @@
         case 'h':
             printf(usage_message, program, program, program, usage_extra);
             exit(0);
-            break;
         case 'l':
             list = optarg;
             break;
@@ -1459,6 +1497,9 @@
         case 's':
             source = optarg;
             break;
+        case 'v':
+            verbose = VERBOSE;
+            break;
         default:
             exit(1);
         }
@@ -1470,6 +1511,13 @@
         exit(1);
     }
 
+    /*
+     * If C_TAP_VERBOSE is set in the environment, that also turns on verbose
+     * mode.
+     */
+    if (getenv("C_TAP_VERBOSE") != NULL)
+        verbose = VERBOSE;
+
     /* Set SOURCE and BUILD environment variables. */
     if (source != NULL) {
         source_env = concat("SOURCE=", source, (const char *) 0);
@@ -1493,10 +1541,10 @@
             shortlist++;
         printf(banner, shortlist);
         tests = read_test_list(list);
-        status = test_batch(tests, source, build) ? 0 : 1;
+        status = test_batch(tests, source, build, verbose) ? 0 : 1;
     } else {
         tests = build_test_list(argv, argc);
-        status = test_batch(tests, source, build) ? 0 : 1;
+        status = test_batch(tests, source, build, verbose) ? 0 : 1;
     }
 
     /* For valgrind cleanliness, free all our memory. */

Modified: tests/tap/basic.c
===================================================================
--- tests/tap/basic.c	2015-04-05 13:28:36 UTC (rev 9823)
+++ tests/tap/basic.c	2015-04-16 11:21:24 UTC (rev 9824)
@@ -13,7 +13,8 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015
+ *     Russ Allbery <eagle at eyrie.org>
  * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2013, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -36,6 +37,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdarg.h>
@@ -242,7 +244,7 @@
     struct diag_file *file;
     fpos_t where;
     size_t length;
-    int incomplete;
+    int size, incomplete;
 
     /*
      * Walk through each file and read each line of output available.  The
@@ -266,7 +268,8 @@
         /* Continue until we get EOF or an incomplete line of data. */
         incomplete = 0;
         while (!feof(file->file) && !incomplete) {
-            if (fgets(file->buffer, file->bufsize, file->file) == NULL) {
+            size = file->bufsize > INT_MAX ? INT_MAX : (int) file->bufsize;
+            if (fgets(file->buffer, size, file->file) == NULL) {
                 if (ferror(file->file))
                     sysbail("cannot read from %s", file->name);
                 continue;
@@ -857,7 +860,7 @@
     /* Don't assume that the source string is nul-terminated. */
     for (p = s; (size_t) (p - s) < n && *p != '\0'; p++)
         ;
-    length = p - s;
+    length = (size_t) (p - s);
     copy = malloc(length + 1);
     if (p == NULL)
         sysbail("failed to strndup %lu bytes", (unsigned long) length);

Modified: tests/tap/basic.h
===================================================================
--- tests/tap/basic.h	2015-04-05 13:28:36 UTC (rev 9823)
+++ tests/tap/basic.h	2015-04-16 11:21:24 UTC (rev 9824)
@@ -5,7 +5,8 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015
+ *     Russ Allbery <eagle at eyrie.org>
  * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
@@ -78,7 +79,8 @@
         __attribute__((__format__(printf, 2, 3)));
 void ok_int(int n, int wanted, int seen);
 void ok_string(int n, const char *wanted, const char *seen);
-int okv(int success, const char *format, va_list args);
+int okv(int success, const char *format, va_list args)
+        __attribute__((__format__(printf, 2, 0)));
 void skip(int n, const char *reason);
 void new_skip(const char *reason, ...)
         __attribute__((__format__(printf, 1, 2)));
@@ -97,7 +99,8 @@
 # define skip_block new_skip_block
 int ok(int success, const char *format, ...)
     __attribute__((__format__(printf, 2, 3)));
-int okv(int success, const char *format, va_list args);
+int okv(int success, const char *format, va_list args)
+    __attribute__((__format__(printf, 2, 0)));
 void skip(const char *reason, ...)
     __attribute__((__format__(printf, 1, 2)));
 

Modified: tests/tap/float.c
===================================================================
--- tests/tap/float.c	2015-04-05 13:28:36 UTC (rev 9823)
+++ tests/tap/float.c	2015-04-16 11:21:24 UTC (rev 9824)
@@ -11,7 +11,7 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 2010, 2012, 2013, 2014 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2008, 2010, 2012, 2013, 2014, 2015 Russ Allbery <eagle at eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -68,7 +68,7 @@
     va_start(args, format);
     fflush(stderr);
     if ((isnan(wanted) && isnan(seen))
-        || (isinf(wanted) && isinf(seen) && wanted == seen)
+        || (isinf(wanted) && isinf(wanted) == isinf(seen))
         || fabs(wanted - seen) <= epsilon) {
         success = 1;
         okv(1, format, args);

Modified: tests/tap/macros.h
===================================================================
--- tests/tap/macros.h	2015-04-05 13:28:36 UTC (rev 9823)
+++ tests/tap/macros.h	2015-04-16 11:21:24 UTC (rev 9824)
@@ -9,7 +9,7 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 2012, 2013 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2008, 2012, 2013, 2015 Russ Allbery <eagle at eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -54,8 +54,10 @@
  * variadic macro support.
  */
 #if !defined(__attribute__) && !defined(__alloc_size__)
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
-#  define __alloc_size__(spec, args...) /* empty */
+# if defined(__GNUC__) && !defined(__clang__)
+#  if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+#   define __alloc_size__(spec, args...) /* empty */
+#  endif
 # endif
 #endif
 



More information about the inn-committers mailing list