INN commit: branches/2.6 (5 files)

INN Commit rra at isc.org
Thu Mar 15 21:40:48 UTC 2018


    Date: Thursday, March 15, 2018 @ 14:40:48
  Author: iulius
Revision: 10268

Update to latest C TAP Harness upstream version

Modified:
  branches/2.6/support/getc-tap-harness
  branches/2.6/tests/tap/basic.c
  branches/2.6/tests/tap/basic.h
  branches/2.6/tests/tap/float.c
  branches/2.6/tests/tap/float.h

--------------------------+
 support/getc-tap-harness |    2 -
 tests/tap/basic.c        |   78 +++++++++++++++++++++++----------------------
 tests/tap/basic.h        |   25 ++++++--------
 tests/tap/float.c        |   20 +++++------
 tests/tap/float.h        |    7 +---
 5 files changed, 65 insertions(+), 67 deletions(-)

Modified: support/getc-tap-harness
===================================================================
--- support/getc-tap-harness	2018-03-15 21:35:08 UTC (rev 10267)
+++ support/getc-tap-harness	2018-03-15 21:40:48 UTC (rev 10268)
@@ -179,7 +179,7 @@
 
     if [ "$3" = "float.c" ]
     then
-      sed -i -e "52 i \\
+      sed -i -e "51 i \\
 #ifndef LIBTEST_NEW_FORMAT\\
 /* Specific to the integration of C TAP Harness in INN. */\\
 void\\

Modified: tests/tap/basic.c
===================================================================
--- tests/tap/basic.c	2018-03-15 21:35:08 UTC (rev 10267)
+++ tests/tap/basic.c	2018-03-15 21:40:48 UTC (rev 10268)
@@ -552,22 +552,21 @@
 
 
 /*
- * Takes an expected boolean value and a seen boolean value and assumes the
- * test passes if the truth value of both match.
+ * Takes two boolean values and requires the truth value of both match.
  */
 int
-is_bool(int wanted, int seen, const char *format, ...)
+is_bool(int left, int right, const char *format, ...)
 {
     int success;
 
     fflush(stderr);
     check_diag_files();
-    success = (!!wanted == !!seen);
+    success = (!!left == !!right);
     if (success)
         printf("ok %lu", testnum++);
     else {
-        diag("wanted: %s", !!wanted ? "true" : "false");
-        diag("  seen: %s", !!seen ? "true" : "false");
+        diag(" left: %s", !!left  ? "true" : "false");
+        diag("right: %s", !!right ? "true" : "false");
         printf("not ok %lu", testnum++);
         _failed++;
     }
@@ -578,22 +577,21 @@
 
 
 /*
- * Takes an expected integer and a seen integer and assumes the test passes
- * if those two numbers match.
+ * Takes two integer values and requires they match.
  */
 int
-is_int(long wanted, long seen, const char *format, ...)
+is_int(long left, long right, const char *format, ...)
 {
     int success;
 
     fflush(stderr);
     check_diag_files();
-    success = (wanted == seen);
+    success = (left == right);
     if (success)
         printf("ok %lu", testnum++);
     else {
-        diag("wanted: %ld", wanted);
-        diag("  seen: %ld", seen);
+        diag(" left: %ld", left);
+        diag("right: %ld", right);
         printf("not ok %lu", testnum++);
         _failed++;
     }
@@ -604,26 +602,31 @@
 
 
 /*
- * Takes a string and what the string should be, and assumes the test passes
- * if those strings match (using strcmp).
+ * Takes two strings and requires they match (using strcmp).  NULL arguments
+ * are permitted and handled correctly.
  */
 int
-is_string(const char *wanted, const char *seen, const char *format, ...)
+is_string(const char *left, const char *right, const char *format, ...)
 {
     int success;
 
-    if (wanted == NULL)
-        wanted = "(null)";
-    if (seen == NULL)
-        seen = "(null)";
     fflush(stderr);
     check_diag_files();
-    success = (strcmp(wanted, seen) == 0);
+
+    /* Compare the strings, being careful of NULL. */
+    if (left == NULL)
+        success = (right == NULL);
+    else if (right == NULL)
+        success = 0;
+    else
+        success = (strcmp(left, right) == 0);
+
+    /* Report the results. */
     if (success)
         printf("ok %lu", testnum++);
     else {
-        diag("wanted: %s", wanted);
-        diag("  seen: %s", seen);
+        diag(" left: %s", left  == NULL ? "(null)" : left);
+        diag("right: %s", right == NULL ? "(null)" : right);
         printf("not ok %lu", testnum++);
         _failed++;
     }
@@ -634,22 +637,22 @@
 
 
 /*
- * Takes an expected unsigned long and a seen unsigned long and assumes the
- * test passes if the two numbers match.  Otherwise, reports them in hex.
+ * Takes two unsigned longs and requires they match.  On failure, reports them
+ * in hex.
  */
 int
-is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
+is_hex(unsigned long left, unsigned long right, const char *format, ...)
 {
     int success;
 
     fflush(stderr);
     check_diag_files();
-    success = (wanted == seen);
+    success = (left == right);
     if (success)
         printf("ok %lu", testnum++);
     else {
-        diag("wanted: %lx", (unsigned long) wanted);
-        diag("  seen: %lx", (unsigned long) seen);
+        diag(" left: %lx", (unsigned long) left);
+        diag("right: %lx", (unsigned long) right);
         printf("not ok %lu", testnum++);
         _failed++;
     }
@@ -660,12 +663,11 @@
 
 
 /*
- * Takes pointers to an expected region of memory and a seen region of memory
- * and assumes the test passes if the len bytes onwards from them match.
- * Otherwise reports any bytes which didn't match.
+ * Takes pointers to a regions of memory and requires that len bytes from each
+ * match.  Otherwise reports any bytes which didn't match.
  */
 int
-is_blob(const void *wanted, const void *seen, size_t len, const char *format,
+is_blob(const void *left, const void *right, size_t len, const char *format,
         ...)
 {
     int success;
@@ -673,17 +675,17 @@
 
     fflush(stderr);
     check_diag_files();
-    success = (memcmp(wanted, seen, len) == 0);
+    success = (memcmp(left, right, len) == 0);
     if (success)
         printf("ok %lu", testnum++);
     else {
-        const unsigned char *wanted_c = wanted;
-        const unsigned char *seen_c = seen;
+        const unsigned char *left_c  = left;
+        const unsigned char *right_c = right;
 
         for (i = 0; i < len; i++) {
-            if (wanted_c[i] != seen_c[i])
-                diag("offset %lu: wanted %02x, seen %02x", (unsigned long) i,
-                     wanted_c[i], seen_c[i]);
+            if (left_c[i] != right_c[i])
+                diag("offset %lu: left %02x, right %02x", (unsigned long) i,
+                     left_c[i], right_c[i]);
         }
         printf("not ok %lu", testnum++);
         _failed++;

Modified: tests/tap/basic.h
===================================================================
--- tests/tap/basic.h	2018-03-15 21:35:08 UTC (rev 10267)
+++ tests/tap/basic.h	2018-03-15 21:40:48 UTC (rev 10268)
@@ -5,9 +5,9 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
- *     Russ Allbery <eagle at eyrie.org>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2014
+ * Written by Russ Allbery <eagle at eyrie.org>
+ * Copyright 2009-2018 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2001-2002, 2004-2008, 2011-2012, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -117,21 +117,20 @@
 #endif
 
 /*
- * Check an expected value against a seen value.  Returns true if the test
- * passes and false if it fails.  is_bool takes an int since the bool type
- * isn't fully portable yet, but interprets both arguments for their truth
- * value, not for their numeric value.
+ * Compare two values.  Returns true if the test passes and false if it fails.
+ * is_bool takes an int since the bool type isn't fully portable yet, but
+ * interprets both arguments for their truth value, not for their numeric
+ * value.
  */
-int is_bool(int wanted, int seen, const char *format, ...)
+int is_bool(int, int, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-int is_int(long wanted, long seen, const char *format, ...)
+int is_int(long, long, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-int is_string(const char *wanted, const char *seen, const char *format, ...)
+int is_string(const char *, const char *, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-int is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
+int is_hex(unsigned long, unsigned long, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-int is_blob(const void *wanted, const void *seen, size_t, const char *format,
-            ...)
+int is_blob(const void *, const void *, size_t, const char *format, ...)
     __attribute__((__format__(printf, 4, 5)));
 
 /* Bail out with an error.  sysbail appends strerror(errno). */

Modified: tests/tap/float.c
===================================================================
--- tests/tap/float.c	2018-03-15 21:35:08 UTC (rev 10267)
+++ tests/tap/float.c	2018-03-15 21:40:48 UTC (rev 10268)
@@ -11,8 +11,7 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 2010, 2012, 2013, 2014, 2015, 2016, 2017
- *     Russ Allbery <eagle at eyrie.org>
+ * Copyright 2008, 2010, 2012-2018 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"),
@@ -49,6 +48,7 @@
 #include <tap/basic.h>
 #include <tap/float.h>
 
+/*
 #ifndef LIBTEST_NEW_FORMAT
 /* Specific to the integration of C TAP Harness in INN. */
 void
@@ -58,7 +58,6 @@
 }
 #endif
 
-/*
  * Clang 4.0.1 gets very confused by this file and produces warnings about
  * floating point implicit conversion from the isnan() and isinf() macros.
  */
@@ -68,11 +67,10 @@
 #endif
 
 /*
- * Takes an expected double and a seen double and assumes the test passes if
- * those two numbers are within delta of each other.
+ * Takes two doubles and requires they be within epsilon of each other.
  */
 int
-is_double(double wanted, double seen, double epsilon, const char *format, ...)
+is_double(double left, double right, double epsilon, const char *format, ...)
 {
     va_list args;
     int success;
@@ -79,15 +77,15 @@
 
     va_start(args, format);
     fflush(stderr);
-    if ((isnan(wanted) && isnan(seen))
-        || (isinf(wanted) && isinf(wanted) == isinf(seen))
-        || fabs(wanted - seen) <= epsilon) {
+    if ((isnan(left) && isnan(right))
+        || (isinf(left) && isinf(left) == isinf(right))
+        || fabs(left - right) <= epsilon) {
         success = 1;
         okv(1, format, args);
     } else {
         success = 0;
-        diag("wanted: %g", wanted);
-        diag("  seen: %g", seen);
+        diag(" left: %g", left);
+        diag("right: %g", right);
         okv(0, format, args);
     }
     va_end(args);

Modified: tests/tap/float.h
===================================================================
--- tests/tap/float.h	2018-03-15 21:35:08 UTC (rev 10267)
+++ tests/tap/float.h	2018-03-15 21:40:48 UTC (rev 10268)
@@ -5,7 +5,7 @@
  * This file is part of C TAP Harness.  The current version plus supporting
  * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 2010, 2012, 2014 Russ Allbery <eagle at eyrie.org>
+ * Copyright 2008, 2010, 2012, 2014, 2018 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"),
@@ -35,13 +35,12 @@
 
 BEGIN_DECLS
 
-/* Check an expected value against a seen value within epsilon. */
+/* Compare two values within epsilon. */
 #ifndef LIBTEST_NEW_FORMAT
 /* Specific to the integration of C TAP Harness in INN. */
 void ok_double(int n, double wanted, double seen);
 #endif
-int is_double(double wanted, double seen, double epsilon,
-               const char *format, ...)
+int is_double(double, double, double epsilon, const char *format, ...)
     __attribute__((__format__(printf, 4, 5)));
 
 END_DECLS



More information about the inn-committers mailing list