aboutsummaryrefslogtreecommitdiff
path: root/tests/tap
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tap')
-rw-r--r--tests/tap/basic.c136
-rw-r--r--tests/tap/basic.h34
-rw-r--r--tests/tap/kerberos.c35
-rw-r--r--tests/tap/kerberos.h15
-rw-r--r--tests/tap/kerberos.sh10
-rw-r--r--tests/tap/libtap.sh28
-rw-r--r--tests/tap/macros.h4
-rw-r--r--tests/tap/messages.c9
-rw-r--r--tests/tap/messages.h7
-rw-r--r--tests/tap/perl/Test/RRA.pm57
-rw-r--r--tests/tap/perl/Test/RRA/Automake.pm191
-rw-r--r--tests/tap/perl/Test/RRA/Config.pm36
-rw-r--r--tests/tap/perl/Test/RRA/ModuleVersion.pm10
-rw-r--r--tests/tap/process.c16
-rw-r--r--tests/tap/process.h6
-rw-r--r--tests/tap/remctl.sh9
-rw-r--r--tests/tap/string.c6
-rw-r--r--tests/tap/string.h6
18 files changed, 439 insertions, 176 deletions
diff --git a/tests/tap/basic.c b/tests/tap/basic.c
index 4f8be04..8624839 100644
--- a/tests/tap/basic.c
+++ b/tests/tap/basic.c
@@ -10,11 +10,11 @@
* up the TAP output format, or finding things in the test environment.
*
* 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/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015
- * Russ Allbery <eagle@eyrie.org>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2013, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2018 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2001-2002, 2004-2008, 2011-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -34,6 +34,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <errno.h>
@@ -128,8 +130,7 @@ static struct diag_file *diag_files = NULL;
do { \
if (format != NULL) { \
va_list args; \
- if (prefix != NULL) \
- printf("%s", prefix); \
+ printf("%s", prefix); \
va_start(args, format); \
vprintf(format, args); \
va_end(args); \
@@ -489,22 +490,81 @@ skip_block(unsigned long count, const char *reason, ...)
/*
- * Takes an expected integer and a seen integer and assumes the test passes
- * if those two numbers match.
+ * Takes two boolean values and requires the truth value of both match.
+ */
+int
+is_bool(int left, int right, const char *format, ...)
+{
+ int success;
+
+ fflush(stderr);
+ check_diag_files();
+ success = (!!left == !!right);
+ if (success)
+ printf("ok %lu", testnum++);
+ else {
+ diag(" left: %s", !!left ? "true" : "false");
+ diag("right: %s", !!right ? "true" : "false");
+ printf("not ok %lu", testnum++);
+ _failed++;
+ }
+ PRINT_DESC(" - ", format);
+ putchar('\n');
+ return success;
+}
+
+
+/*
+ * Takes two integer values and requires they match.
+ */
+int
+is_int(long left, long right, const char *format, ...)
+{
+ int success;
+
+ fflush(stderr);
+ check_diag_files();
+ success = (left == right);
+ if (success)
+ printf("ok %lu", testnum++);
+ else {
+ diag(" left: %ld", left);
+ diag("right: %ld", right);
+ printf("not ok %lu", testnum++);
+ _failed++;
+ }
+ PRINT_DESC(" - ", format);
+ putchar('\n');
+ return success;
+}
+
+
+/*
+ * Takes two strings and requires they match (using strcmp). NULL arguments
+ * are permitted and handled correctly.
*/
int
-is_int(long wanted, long seen, const char *format, ...)
+is_string(const char *left, const char *right, const char *format, ...)
{
int success;
fflush(stderr);
check_diag_files();
- success = (wanted == seen);
+
+ /* 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: %ld", wanted);
- diag(" seen: %ld", seen);
+ diag(" left: %s", left == NULL ? "(null)" : left);
+ diag("right: %s", right == NULL ? "(null)" : right);
printf("not ok %lu", testnum++);
_failed++;
}
@@ -515,26 +575,22 @@ is_int(long wanted, long seen, const char *format, ...)
/*
- * Takes a string and what the string should be, and assumes the test passes
- * if those strings match (using strcmp).
+ * Takes two unsigned longs and requires they match. On failure, reports them
+ * in hex.
*/
int
-is_string(const char *wanted, const char *seen, const char *format, ...)
+is_hex(unsigned long left, unsigned long 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);
+ success = (left == right);
if (success)
printf("ok %lu", testnum++);
else {
- diag("wanted: %s", wanted);
- diag(" seen: %s", seen);
+ diag(" left: %lx", (unsigned long) left);
+ diag("right: %lx", (unsigned long) right);
printf("not ok %lu", testnum++);
_failed++;
}
@@ -545,22 +601,30 @@ is_string(const char *wanted, const char *seen, const char *format, ...)
/*
- * 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 pointers to a regions of memory and requires that len bytes from each
+ * match. Otherwise reports any bytes which didn't match.
*/
int
-is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
+is_blob(const void *left, const void *right, size_t len, const char *format,
+ ...)
{
int success;
+ size_t i;
fflush(stderr);
check_diag_files();
- success = (wanted == seen);
+ success = (memcmp(left, right, len) == 0);
if (success)
printf("ok %lu", testnum++);
else {
- diag("wanted: %lx", (unsigned long) wanted);
- diag(" seen: %lx", (unsigned long) seen);
+ const unsigned char *left_c = left;
+ const unsigned char *right_c = right;
+
+ for (i = 0; i < len; 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++;
}
@@ -769,6 +833,8 @@ breallocarray(void *p, size_t n, size_t size)
{
if (n > 0 && UINT_MAX / n <= size)
bail("reallocarray too large");
+ if (n == 0)
+ n = 1;
p = realloc(p, n * size);
if (p == NULL)
sysbail("failed to realloc %lu bytes", (unsigned long) (n * size));
@@ -820,17 +886,17 @@ bstrndup(const char *s, size_t n)
/*
- * Locate a test file. Given the partial path to a file, look under BUILD and
- * then SOURCE for the file and return the full path to the file. Returns
- * NULL if the file doesn't exist. A non-NULL return should be freed with
- * test_file_path_free().
+ * Locate a test file. Given the partial path to a file, look under
+ * C_TAP_BUILD and then C_TAP_SOURCE for the file and return the full path to
+ * the file. Returns NULL if the file doesn't exist. A non-NULL return
+ * should be freed with test_file_path_free().
*/
char *
test_file_path(const char *file)
{
char *base;
char *path = NULL;
- const char *envs[] = { "BUILD", "SOURCE", NULL };
+ const char *envs[] = { "C_TAP_BUILD", "C_TAP_SOURCE", NULL };
int i;
for (i = 0; envs[i] != NULL; i++) {
@@ -860,7 +926,7 @@ test_file_path_free(char *path)
/*
- * Create a temporary directory, tmp, under BUILD if set and the current
+ * Create a temporary directory, tmp, under C_TAP_BUILD if set and the current
* directory if it does not. Returns the path to the temporary directory in
* newly allocated memory, and calls bail on any failure. The return value
* should be freed with test_tmpdir_free.
@@ -875,7 +941,7 @@ test_tmpdir(void)
const char *build;
char *path = NULL;
- build = getenv("BUILD");
+ build = getenv("C_TAP_BUILD");
if (build == NULL)
build = ".";
path = concat(build, "/tmp", (const char *) 0);
diff --git a/tests/tap/basic.h b/tests/tap/basic.h
index 4ecaaec..3f46e4f 100644
--- a/tests/tap/basic.h
+++ b/tests/tap/basic.h
@@ -2,11 +2,11 @@
* Basic utility routines for the TAP protocol.
*
* 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/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015
- * Russ Allbery <eagle@eyrie.org>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2018 Russ Allbery <eagle@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
@@ -26,6 +26,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_BASIC_H
@@ -88,15 +90,21 @@ void skip_block(unsigned long count, const char *reason, ...)
__attribute__((__format__(printf, 2, 3)));
/*
- * Check an expected value against a seen value. Returns true if the test
- * passes and false if it fails.
+ * 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_int(long wanted, long seen, const char *format, ...)
+int is_bool(int, int, const char *format, ...)
+ __attribute__((__format__(printf, 3, 4)));
+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 *, const void *, size_t, const char *format, ...)
+ __attribute__((__format__(printf, 4, 5)));
/* Bail out with an error. sysbail appends strerror(errno). */
void bail(const char *format, ...)
@@ -137,16 +145,16 @@ char *bstrndup(const char *, size_t)
__attribute__((__malloc__, __nonnull__, __warn_unused_result__));
/*
- * Find a test file under BUILD or SOURCE, returning the full path. The
- * returned path should be freed with test_file_path_free().
+ * Find a test file under C_TAP_BUILD or C_TAP_SOURCE, returning the full
+ * path. The returned path should be freed with test_file_path_free().
*/
char *test_file_path(const char *file)
__attribute__((__malloc__, __nonnull__, __warn_unused_result__));
void test_file_path_free(char *path);
/*
- * Create a temporary directory relative to BUILD and return the path. The
- * returned path should be freed with test_tmpdir_free.
+ * Create a temporary directory relative to C_TAP_BUILD and return the path.
+ * The returned path should be freed with test_tmpdir_free().
*/
char *test_tmpdir(void)
__attribute__((__malloc__, __warn_unused_result__));
diff --git a/tests/tap/kerberos.c b/tests/tap/kerberos.c
index 6a5025a..89a36a3 100644
--- a/tests/tap/kerberos.c
+++ b/tests/tap/kerberos.c
@@ -12,10 +12,11 @@
* are available.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014
+ * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2007, 2009-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,6 +36,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -361,7 +364,7 @@ kerberos_setup(enum kerberos_needs needs)
path = test_file_path("config/pkinit-principal");
if (path != NULL)
file = fopen(path, "r");
- if (file != NULL) {
+ if (path != NULL && file != NULL) {
if (fgets(buffer, sizeof(buffer), file) == NULL)
bail("cannot read %s", path);
if (buffer[strlen(buffer) - 1] != '\n')
@@ -457,17 +460,19 @@ kerberos_generate_conf(const char *realm)
/*
- * Report a Kerberos error and bail out.
+ * Report a Kerberos error and bail out. Takes a long instead of a
+ * krb5_error_code because it can also handle a kadm5_ret_t (which may be a
+ * different size).
*/
void
-bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...)
+bail_krb5(krb5_context ctx, long code, const char *format, ...)
{
const char *k5_msg = NULL;
char *message;
va_list args;
if (ctx != NULL)
- k5_msg = krb5_get_error_message(ctx, code);
+ k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code);
va_start(args, format);
bvasprintf(&message, format, args);
va_end(args);
@@ -479,17 +484,19 @@ bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...)
/*
- * Report a Kerberos error as a diagnostic to stderr.
+ * Report a Kerberos error as a diagnostic to stderr. Takes a long instead of
+ * a krb5_error_code because it can also handle a kadm5_ret_t (which may be a
+ * different size).
*/
void
-diag_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...)
+diag_krb5(krb5_context ctx, long code, const char *format, ...)
{
const char *k5_msg = NULL;
char *message;
va_list args;
if (ctx != NULL)
- k5_msg = krb5_get_error_message(ctx, code);
+ k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code);
va_start(args, format);
bvasprintf(&message, format, args);
va_end(args);
@@ -524,14 +531,12 @@ kerberos_keytab_principal(krb5_context ctx, const char *path)
if (status != 0)
bail_krb5(ctx, status, "error reading %s", path);
status = krb5_kt_next_entry(ctx, keytab, &entry, &cursor);
- if (status == 0) {
- status = krb5_copy_principal(ctx, entry.principal, &princ);
- if (status != 0)
- bail_krb5(ctx, status, "error copying principal from %s", path);
- krb5_kt_free_entry(ctx, &entry);
- }
if (status != 0)
bail("no principal found in keytab file %s", path);
+ status = krb5_copy_principal(ctx, entry.principal, &princ);
+ if (status != 0)
+ bail_krb5(ctx, status, "error copying principal from %s", path);
+ krb5_kt_free_entry(ctx, &entry);
krb5_kt_end_seq_get(ctx, keytab, &cursor);
krb5_kt_close(ctx, keytab);
return princ;
diff --git a/tests/tap/kerberos.h b/tests/tap/kerberos.h
index 26f45f9..c256822 100644
--- a/tests/tap/kerberos.h
+++ b/tests/tap/kerberos.h
@@ -2,10 +2,11 @@
* Utility functions for tests that use Kerberos.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2011, 2012, 2013, 2014
+ * Copyright 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2007, 2009, 2011-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +26,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_KERBEROS_H
@@ -107,12 +110,12 @@ void kerberos_cleanup_conf(void);
#ifdef HAVE_KRB5
/* Bail out with an error, appending the Kerberos error message. */
-void bail_krb5(krb5_context, krb5_error_code, const char *format, ...)
- __attribute__((__noreturn__, __nonnull__, __format__(printf, 3, 4)));
+void bail_krb5(krb5_context, long, const char *format, ...)
+ __attribute__((__noreturn__, __nonnull__(3), __format__(printf, 3, 4)));
/* Report a diagnostic with Kerberos error to stderr prefixed with #. */
-void diag_krb5(krb5_context, krb5_error_code, const char *format, ...)
- __attribute__((__nonnull__, __format__(printf, 3, 4)));
+void diag_krb5(krb5_context, long, const char *format, ...)
+ __attribute__((__nonnull__(3), __format__(printf, 3, 4)));
/*
* Given a Kerberos context and the path to a keytab, retrieve the principal
diff --git a/tests/tap/kerberos.sh b/tests/tap/kerberos.sh
index e970ae5..13b540d 100644
--- a/tests/tap/kerberos.sh
+++ b/tests/tap/kerberos.sh
@@ -6,10 +6,11 @@
# Bourne shell. Instead, all private variables are prefixed with "tap_".
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2009, 2010, 2011, 2012
+# Copyright 2016 Russ Allbery <eagle@eyrie.org>
+# Copyright 2009-2012
# The Board of Trustees of the Leland Stanford Junior University
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,9 +30,10 @@
# 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.
+#
+# SPDX-License-Identifier: MIT
-# We use test_tmpdir.
-. "${SOURCE}/tap/libtap.sh"
+. "${C_TAP_SOURCE}/tap/libtap.sh"
# Set up Kerberos, including the ticket cache environment variable. Bail out
# if not successful, return 0 if successful, and return 1 if Kerberos is not
diff --git a/tests/tap/libtap.sh b/tests/tap/libtap.sh
index 9731032..38181d9 100644
--- a/tests/tap/libtap.sh
+++ b/tests/tap/libtap.sh
@@ -7,10 +7,10 @@
#
# This file provides a TAP-compatible shell function library useful for
# writing test cases. It is part of C TAP Harness, which can be found at
-# <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+# <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
-# Copyright 2009, 2010, 2011, 2012 Russ Allbery <eagle@eyrie.org>
+# Copyright 2009, 2010, 2011, 2012, 2016 Russ Allbery <eagle@eyrie.org>
# Copyright 2006, 2007, 2008, 2013
# The Board of Trustees of the Leland Stanford Junior University
#
@@ -31,6 +31,8 @@
# 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.
+#
+# SPDX-License-Identifier: MIT
# Print out the number of test cases we expect to run.
plan () {
@@ -212,32 +214,32 @@ diag () {
echo '#' "$@"
}
-# Search for the given file first in $BUILD and then in $SOURCE and echo the
-# path where the file was found, or the empty string if the file wasn't
-# found.
+# Search for the given file first in $C_TAP_BUILD and then in $C_TAP_SOURCE
+# and echo the path where the file was found, or the empty string if the file
+# wasn't found.
#
# This macro uses puts, so don't run it using backticks inside double quotes
# or bizarre quoting behavior will happen with Solaris sh.
test_file_path () {
- if [ -n "$BUILD" ] && [ -f "$BUILD/$1" ] ; then
- puts "$BUILD/$1"
- elif [ -n "$SOURCE" ] && [ -f "$SOURCE/$1" ] ; then
- puts "$SOURCE/$1"
+ if [ -n "$C_TAP_BUILD" ] && [ -f "$C_TAP_BUILD/$1" ] ; then
+ puts "$C_TAP_BUILD/$1"
+ elif [ -n "$C_TAP_SOURCE" ] && [ -f "$C_TAP_SOURCE/$1" ] ; then
+ puts "$C_TAP_SOURCE/$1"
else
echo ''
fi
}
-# Create $BUILD/tmp for use by tests for storing temporary files and return
-# the path (via standard output).
+# Create $C_TAP_BUILD/tmp for use by tests for storing temporary files and
+# return the path (via standard output).
#
# This macro uses puts, so don't run it using backticks inside double quotes
# or bizarre quoting behavior will happen with Solaris sh.
test_tmpdir () {
- if [ -z "$BUILD" ] ; then
+ if [ -z "$C_TAP_BUILD" ] ; then
tap_tmpdir="./tmp"
else
- tap_tmpdir="$BUILD"/tmp
+ tap_tmpdir="$C_TAP_BUILD"/tmp
fi
if [ ! -d "$tap_tmpdir" ] ; then
mkdir "$tap_tmpdir" || bail "Error creating $tap_tmpdir"
diff --git a/tests/tap/macros.h b/tests/tap/macros.h
index 139cff0..32ed815 100644
--- a/tests/tap/macros.h
+++ b/tests/tap/macros.h
@@ -6,7 +6,7 @@
* everyone can pull them in.
*
* 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/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
* Copyright 2008, 2012, 2013, 2015 Russ Allbery <eagle@eyrie.org>
*
@@ -27,6 +27,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_MACROS_H
diff --git a/tests/tap/messages.c b/tests/tap/messages.c
index 9c28789..a720ec7 100644
--- a/tests/tap/messages.c
+++ b/tests/tap/messages.c
@@ -6,10 +6,11 @@
* handling.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2002, 2004, 2005, 2015 Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009, 2012, 2014
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2002, 2004-2005, 2015 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2006-2007, 2009, 2012, 2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -29,6 +30,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
diff --git a/tests/tap/messages.h b/tests/tap/messages.h
index 985b9cd..3076113 100644
--- a/tests/tap/messages.h
+++ b/tests/tap/messages.h
@@ -2,10 +2,11 @@
* Utility functions to test message handling.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
+ * Written by Russ Allbery <eagle@eyrie.org>
* Copyright 2002 Russ Allbery <eagle@eyrie.org>
- * Copyright 2006, 2007, 2009
+ * Copyright 2006-2007, 2009
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +26,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_MESSAGES_H
diff --git a/tests/tap/perl/Test/RRA.pm b/tests/tap/perl/Test/RRA.pm
index 8608e31..807508c 100644
--- a/tests/tap/perl/Test/RRA.pm
+++ b/tests/tap/perl/Test/RRA.pm
@@ -5,6 +5,8 @@
# by both C packages with Automake and by stand-alone Perl modules. See
# Test::RRA::Automake for additional functions specifically for C Automake
# distributions.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA;
@@ -13,6 +15,7 @@ use strict;
use warnings;
use Exporter;
+use File::Temp;
use Test::More;
# For Perl 5.006 compatibility.
@@ -26,12 +29,56 @@ our (@EXPORT_OK, @ISA, $VERSION);
# consistency is good).
BEGIN {
@ISA = qw(Exporter);
- @EXPORT_OK = qw(skip_unless_author skip_unless_automated use_prereq);
+ @EXPORT_OK = qw(
+ is_file_contents skip_unless_author skip_unless_automated use_prereq
+ );
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '5.10';
+ $VERSION = '7.02';
+}
+
+# Compare a string to the contents of a file, similar to the standard is()
+# function, but to show the line-based unified diff between them if they
+# differ.
+#
+# $got - The output that we received
+# $expected - The path to the file containing the expected output
+# $message - The message to use when reporting the test results
+#
+# Returns: undef
+# Throws: Exception on failure to read or write files or run diff
+sub is_file_contents {
+ my ($got, $expected, $message) = @_;
+
+ # If they're equal, this is simple.
+ open(my $fh, '<', $expected) or BAIL_OUT("Cannot open $expected: $!\n");
+ my $data = do { local $/ = undef; <$fh> };
+ close($fh) or BAIL_OUT("Cannot close $expected: $!\n");
+ if ($got eq $data) {
+ is($got, $data, $message);
+ return;
+ }
+
+ # Otherwise, we show a diff, but only if we have IPC::System::Simple.
+ eval { require IPC::System::Simple };
+ if ($@) {
+ ok(0, $message);
+ return;
+ }
+
+ # They're not equal. Write out what we got so that we can run diff.
+ my $tmp = File::Temp->new();
+ my $tmpname = $tmp->filename;
+ print {$tmp} $got or BAIL_OUT("Cannot write to $tmpname: $!\n");
+ my @command = ('diff', '-u', $expected, $tmpname);
+ my $diff = IPC::System::Simple::capturex([0 .. 1], @command);
+ diag($diff);
+
+ # Remove the temporary file and report failure.
+ ok(0, $message);
+ return;
}
# Skip this test unless author tests are requested. Takes a short description
@@ -225,10 +272,14 @@ SOFTWARE.
Test::More(3), Test::RRA::Automake(3), Test::RRA::Config(3)
This module is maintained in the rra-c-util package. The current version is
-available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
The functions to control when tests are run use environment variables defined
by the L<Lancaster
Consensus|https://github.com/Perl-Toolchain-Gang/toolchain-site/blob/master/lancaster-consensus.md>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/perl/Test/RRA/Automake.pm b/tests/tap/perl/Test/RRA/Automake.pm
index c6399ec..e4db56c 100644
--- a/tests/tap/perl/Test/RRA/Automake.pm
+++ b/tests/tap/perl/Test/RRA/Automake.pm
@@ -7,8 +7,11 @@
# require closely following the conventions implemented by the rra-c-util
# utility collection.
#
-# All the functions here assume that BUILD and SOURCE are set in the
-# environment. This is normally done via the C TAP Harness runtests wrapper.
+# All the functions here assume that C_TAP_BUILD and C_TAP_SOURCE are set in
+# the environment. This is normally done via the C TAP Harness runtests
+# wrapper.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA::Automake;
@@ -20,6 +23,7 @@ use warnings;
## no critic (ClassHierarchies::ProhibitExplicitISA)
use Exporter;
+use File::Find qw(find);
use File::Spec;
use Test::More;
use Test::RRA::Config qw($LIBRARY_PATH);
@@ -34,9 +38,9 @@ BEGIN {
$PERL_BLIB_ARCH = File::Spec->catdir(qw(perl blib arch));
$PERL_BLIB_LIB = File::Spec->catdir(qw(perl blib lib));
- # If BUILD is set, we can come up with better values.
- if (defined($ENV{BUILD})) {
- my ($vol, $dirs) = File::Spec->splitpath($ENV{BUILD}, 1);
+ # If C_TAP_BUILD is set, we can come up with better values.
+ if (defined($ENV{C_TAP_BUILD})) {
+ my ($vol, $dirs) = File::Spec->splitpath($ENV{C_TAP_BUILD}, 1);
my @dirs = File::Spec->splitdir($dirs);
pop(@dirs);
$PERL_BLIB_ARCH = File::Spec->catdir(@dirs, qw(perl blib arch));
@@ -57,47 +61,95 @@ our (@EXPORT_OK, @ISA, $VERSION);
# consistency is good).
BEGIN {
@ISA = qw(Exporter);
- @EXPORT_OK = qw(automake_setup perl_dirs test_file_path test_tmpdir);
+ @EXPORT_OK = qw(
+ all_files automake_setup perl_dirs test_file_path test_tmpdir
+ );
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '5.10';
+ $VERSION = '7.02';
}
-# Perl directories to skip globally for perl_dirs. We ignore the perl
-# directory if it exists since, in my packages, it is treated as a Perl module
-# distribution and has its own standalone test suite.
-my @GLOBAL_SKIP = qw(.git _build perl);
+# Directories to skip globally when looking for all files, or for directories
+# that could contain Perl files.
+my @GLOBAL_SKIP = qw(
+ .git _build autom4te.cache build-aux perl/_build perl/blib
+);
+
+# Additional paths to skip when building a list of all files in the
+# distribution. This primarily skips build artifacts that aren't interesting
+# to any of the tests. These match any path component.
+my @FILES_SKIP = qw(
+ .deps .dirstamp .libs aclocal.m4 config.h config.h.in config.h.in~ config.log
+ config.status configure
+);
# The temporary directory created by test_tmpdir, if any. If this is set,
# attempt to remove the directory stored here on program exit (but ignore
# failure to do so).
my $TMPDIR;
+# Returns a list of all files in the distribution.
+#
+# Returns: List of files
+sub all_files {
+ my @files;
+
+ # Turn the skip lists into hashes for ease of querying.
+ my %skip = map { $_ => 1 } @GLOBAL_SKIP;
+ my %files_skip = map { $_ => 1 } @FILES_SKIP;
+
+ # Wanted function for find. Prune anything matching either of the skip
+ # lists, or *.lo files, and then add all regular files to the list.
+ my $wanted = sub {
+ my $file = $_;
+ my $path = $File::Find::name;
+ $path =~ s{ \A [.]/ }{}xms;
+ if ($skip{$path} || $files_skip{$file} || $file =~ m{ [.] lo \z }xms) {
+ $File::Find::prune = 1;
+ return;
+ }
+ if (-f $file) {
+ push(@files, $path);
+ }
+ };
+
+ # Do the recursive search and return the results.
+ find($wanted, q{.});
+ return @files;
+}
+
# Perform initial test setup for running a Perl test in an Automake package.
-# This verifies that BUILD and SOURCE are set and then changes directory to
-# the SOURCE directory by default. Sets LD_LIBRARY_PATH if the $LIBRARY_PATH
-# configuration option is set. Calls BAIL_OUT if BUILD or SOURCE are missing
-# or if anything else fails.
+# This verifies that C_TAP_BUILD and C_TAP_SOURCE are set and then changes
+# directory to the C_TAP_SOURCE directory by default. Sets LD_LIBRARY_PATH if
+# the $LIBRARY_PATH configuration option is set. Calls BAIL_OUT if
+# C_TAP_BUILD or C_TAP_SOURCE are missing or if anything else fails.
#
# $args_ref - Reference to a hash of arguments to configure behavior:
-# chdir_build - If set to a true value, changes to BUILD instead of SOURCE
+# chdir_build - If set to a true value, changes to C_TAP_BUILD instead of
+# C_TAP_SOURCE
#
# Returns: undef
sub automake_setup {
my ($args_ref) = @_;
- # Bail if BUILD or SOURCE are not set.
- if (!$ENV{BUILD}) {
- BAIL_OUT('BUILD not defined (run under runtests)');
+ # Bail if C_TAP_BUILD or C_TAP_SOURCE are not set.
+ if (!$ENV{C_TAP_BUILD}) {
+ BAIL_OUT('C_TAP_BUILD not defined (run under runtests)');
}
- if (!$ENV{SOURCE}) {
- BAIL_OUT('SOURCE not defined (run under runtests)');
+ if (!$ENV{C_TAP_SOURCE}) {
+ BAIL_OUT('C_TAP_SOURCE not defined (run under runtests)');
}
- # BUILD or SOURCE will be the test directory. Change to the parent.
- my $start = $args_ref->{chdir_build} ? $ENV{BUILD} : $ENV{SOURCE};
+ # C_TAP_BUILD or C_TAP_SOURCE will be the test directory. Change to the
+ # parent.
+ my $start;
+ if ($args_ref->{chdir_build}) {
+ $start = $ENV{C_TAP_BUILD};
+ } else {
+ $start = $ENV{C_TAP_SOURCE};
+ }
my ($vol, $dirs) = File::Spec->splitpath($start, 1);
my @dirs = File::Spec->splitdir($dirs);
pop(@dirs);
@@ -116,8 +168,9 @@ sub automake_setup {
my $root = File::Spec->catpath($vol, File::Spec->catdir(@dirs), q{});
chdir($root) or BAIL_OUT("cannot chdir to $root: $!");
- # If BUILD is a subdirectory of SOURCE, add it to the global ignore list.
- my ($buildvol, $builddirs) = File::Spec->splitpath($ENV{BUILD}, 1);
+ # If C_TAP_BUILD is a subdirectory of C_TAP_SOURCE, add it to the global
+ # ignore list.
+ my ($buildvol, $builddirs) = File::Spec->splitpath($ENV{C_TAP_BUILD}, 1);
my @builddirs = File::Spec->splitdir($builddirs);
pop(@builddirs);
if ($buildvol eq $vol && @builddirs == @dirs + 1) {
@@ -162,9 +215,11 @@ sub automake_setup {
sub perl_dirs {
my ($args_ref) = @_;
- # Add the global skip list.
+ # Add the global skip list. We also ignore the perl directory if it
+ # exists since, in my packages, it is treated as a Perl module
+ # distribution and has its own standalone test suite.
my @skip = $args_ref->{skip} ? @{ $args_ref->{skip} } : ();
- push(@skip, @GLOBAL_SKIP);
+ push(@skip, @GLOBAL_SKIP, 'perl');
# Separate directories to skip under tests from top-level directories.
my @skip_tests = grep { m{ \A tests/ }xms } @skip;
@@ -206,9 +261,9 @@ sub perl_dirs {
return @dirs;
}
-# Find a configuration file for the test suite. Searches relative to BUILD
-# first and then SOURCE and returns whichever is found first. Calls BAIL_OUT
-# if the file could not be found.
+# Find a configuration file for the test suite. Searches relative to
+# C_TAP_BUILD first and then C_TAP_SOURCE and returns whichever is found
+# first. Calls BAIL_OUT if the file could not be found.
#
# $file - Partial path to the file
#
@@ -216,7 +271,7 @@ sub perl_dirs {
sub test_file_path {
my ($file) = @_;
BASE:
- for my $base ($ENV{BUILD}, $ENV{SOURCE}) {
+ for my $base ($ENV{C_TAP_BUILD}, $ENV{C_TAP_SOURCE}) {
next if !defined($base);
if (-f "$base/$file") {
return "$base/$file";
@@ -236,11 +291,16 @@ sub test_tmpdir {
my $path;
# If we already figured out what directory to use, reuse the same path.
- # Otherwise, create a directory relative to BUILD if set.
+ # Otherwise, create a directory relative to C_TAP_BUILD if set.
if (defined($TMPDIR)) {
$path = $TMPDIR;
} else {
- my $base = defined($ENV{BUILD}) ? $ENV{BUILD} : File::Spec->curdir;
+ my $base;
+ if (defined($ENV{C_TAP_BUILD})) {
+ $base = $ENV{C_TAP_BUILD};
+ } else {
+ $base = File::Spec->curdir;
+ }
$path = File::Spec->catdir($base, 'tmp');
}
@@ -297,11 +357,11 @@ layout of a package that uses rra-c-util and C TAP Harness for the test
structure.
Loading this module will also add the directories C<perl/blib/arch> and
-C<perl/blib/lib> to the Perl library search path, relative to BUILD if that
-environment variable is set. This is harmless for C Automake projects that
-don't contain an embedded Perl module, and for those projects that do, this
-will allow subsequent C<use> calls to find modules that are built as part of
-the package build process.
+C<perl/blib/lib> to the Perl library search path, relative to C_TAP_BUILD if
+that environment variable is set. This is harmless for C Automake projects
+that don't contain an embedded Perl module, and for those projects that do,
+this will allow subsequent C<use> calls to find modules that are built as part
+of the package build process.
The automake_setup() function should be called before calling any other
functions provided by this module.
@@ -314,11 +374,20 @@ BAIL_OUT (from Test::More).
=over 4
+=item all_files()
+
+Returns a list of all "interesting" files in the distribution that a test
+suite may want to look at. This excludes various products of the build system,
+the build directory if it's under the source directory, and a few other
+uninteresting directories like F<.git>. The returned paths will be paths
+relative to the root of the package.
+
=item automake_setup([ARGS])
-Verifies that the BUILD and SOURCE environment variables are set and then
-changes directory to the top of the source tree (which is one directory up
-from the SOURCE path, since SOURCE points to the top of the tests directory).
+Verifies that the C_TAP_BUILD and C_TAP_SOURCE environment variables are set
+and then changes directory to the top of the source tree (which is one
+directory up from the C_TAP_SOURCE path, since C_TAP_SOURCE points to the top
+of the tests directory).
If ARGS is given, it should be a reference to a hash of configuration options.
Only one option is supported: C<chdir_build>. If it is set to a true value,
@@ -343,30 +412,46 @@ C<tests/> that should be skipped.
Given FILE, which should be a relative path, locates that file relative to the
test directory in either the source or build tree. FILE will be checked for
-relative to the environment variable BUILD first, and then relative to SOURCE.
-test_file_path() returns the full path to FILE or calls BAIL_OUT if FILE could
-not be found.
+relative to the environment variable C_TAP_BUILD first, and then relative to
+C_TAP_SOURCE. test_file_path() returns the full path to FILE or calls
+BAIL_OUT if FILE could not be found.
=item test_tmpdir()
Create a temporary directory for tests to use for transient files and return
-the path to that directory. The directory is created relative to the BUILD
-environment variable, which must be set. Permissions on the directory are set
-using the current umask. test_tmpdir() returns the full path to the temporary
-directory or calls BAIL_OUT if it could not be created.
+the path to that directory. The directory is created relative to the
+C_TAP_BUILD environment variable, which must be set. Permissions on the
+directory are set using the current umask. test_tmpdir() returns the full
+path to the temporary directory or calls BAIL_OUT if it could not be created.
The directory is automatically removed if possible on program exit. Failure
to remove the directory on exit is reported with diag() and otherwise ignored.
=back
+=head1 ENVIRONMENT
+
+=over 4
+
+=item C_TAP_BUILD
+
+The root of the tests directory in Automake build directory for this package,
+used to find files as documented above.
+
+=item C_TAP_SOURCE
+
+The root of the tests directory in the source tree for this package, used to
+find files as documented above.
+
+=back
+
=head1 AUTHOR
Russ Allbery <eagle@eyrie.org>
=head1 COPYRIGHT AND LICENSE
-Copyright 2014, 2015 Russ Allbery <eagle@eyrie.org>
+Copyright 2014, 2015, 2018 Russ Allbery <eagle@eyrie.org>
Copyright 2013 The Board of Trustees of the Leland Stanford Junior University
@@ -393,9 +478,13 @@ SOFTWARE.
Test::More(3), Test::RRA(3), Test::RRA::Config(3)
This module is maintained in the rra-c-util package. The current version is
-available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
The C TAP Harness test driver and libraries for TAP-based C testing are
-available from L<http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+available from L<https://www.eyrie.org/~eagle/software/c-tap-harness/>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/perl/Test/RRA/Config.pm b/tests/tap/perl/Test/RRA/Config.pm
index a5b0d0d..7cb0916 100644
--- a/tests/tap/perl/Test/RRA/Config.pm
+++ b/tests/tap/perl/Test/RRA/Config.pm
@@ -4,6 +4,8 @@
# configuration file to store some package-specific data. This module loads
# that configuration and provides the namespace for the configuration
# settings.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA::Config;
@@ -34,16 +36,16 @@ BEGIN {
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '5.10';
+ $VERSION = '7.02';
}
-# If BUILD or SOURCE are set in the environment, look for data/perl.conf under
-# those paths for a C Automake package. Otherwise, look in t/data/perl.conf
-# for a standalone Perl module or tests/data/perl.conf for Perl tests embedded
-# in a larger distribution. Don't use Test::RRA::Automake since it may not
-# exist.
+# If C_TAP_BUILD or C_TAP_SOURCE are set in the environment, look for
+# data/perl.conf under those paths for a C Automake package. Otherwise, look
+# in t/data/perl.conf for a standalone Perl module or tests/data/perl.conf for
+# Perl tests embedded in a larger distribution. Don't use Test::RRA::Automake
+# since it may not exist.
our $PATH;
-for my $base ($ENV{BUILD}, $ENV{SOURCE}, 't', 'tests') {
+for my $base ($ENV{C_TAP_BUILD}, $ENV{C_TAP_SOURCE}, './t', './tests') {
next if !defined($base);
my $path = "$base/data/perl.conf";
if (-r $path) {
@@ -70,7 +72,7 @@ our @STRICT_PREREQ;
# Load the configuration.
if (!do($PATH)) {
my $error = $@ || $! || 'loading file did not return true';
- BAIL_OUT("cannot load data/perl.conf: $error");
+ BAIL_OUT("cannot load $PATH: $error");
}
1;
@@ -98,10 +100,10 @@ for both C Automake packages and stand-alone Perl modules.
Test::RRA::Config looks for a file named F<data/perl.conf> relative to the
root of the test directory. That root is taken from the environment variables
-BUILD or SOURCE (in that order) if set, which will be the case for C Automake
-packages using C TAP Harness. If neither is set, it expects the root of the
-test directory to be a directory named F<t> relative to the current directory,
-which will be the case for stand-alone Perl modules.
+C_TAP_BUILD or C_TAP_SOURCE (in that order) if set, which will be the case for
+C Automake packages using C TAP Harness. If neither is set, it expects the
+root of the test directory to be a directory named F<t> relative to the
+current directory, which will be the case for stand-alone Perl modules.
The following variables are supported:
@@ -185,6 +187,8 @@ Russ Allbery <eagle@eyrie.org>
=head1 COPYRIGHT AND LICENSE
+Copyright 2015, 2016 Russ Allbery <eagle@eyrie.org>
+
Copyright 2013, 2014 The Board of Trustees of the Leland Stanford Junior
University
@@ -212,9 +216,13 @@ perlcritic(1), Test::MinimumVersion(3), Test::RRA(3), Test::RRA::Automake(3),
Test::Strict(3)
This module is maintained in the rra-c-util package. The current version is
-available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
The C TAP Harness test driver and libraries for TAP-based C testing are
-available from L<http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+available from L<https://www.eyrie.org/~eagle/software/c-tap-harness/>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/perl/Test/RRA/ModuleVersion.pm b/tests/tap/perl/Test/RRA/ModuleVersion.pm
index f02877a..49acac4 100644
--- a/tests/tap/perl/Test/RRA/ModuleVersion.pm
+++ b/tests/tap/perl/Test/RRA/ModuleVersion.pm
@@ -3,6 +3,8 @@
# This module contains the common code for testing and updating Perl module
# versions for consistency within a Perl module distribution and within a
# larger package that contains both Perl modules and other code.
+#
+# SPDX-License-Identifier: MIT
package Test::RRA::ModuleVersion;
@@ -31,7 +33,7 @@ BEGIN {
# This version should match the corresponding rra-c-util release, but with
# two digits for the minor version, including a leading zero if necessary,
# so that it will sort properly.
- $VERSION = '5.10';
+ $VERSION = '7.02';
}
# A regular expression matching the version string for a module using the
@@ -290,6 +292,10 @@ SOFTWARE.
Test::More(3), Test::RRA::Config(3)
This module is maintained in the rra-c-util package. The current version
-is available from L<http://www.eyrie.org/~eagle/software/rra-c-util/>.
+is available from L<https://www.eyrie.org/~eagle/software/rra-c-util/>.
=cut
+
+# Local Variables:
+# copyright-at-end-flag: t
+# End:
diff --git a/tests/tap/process.c b/tests/tap/process.c
index 8c22324..d9e94d8 100644
--- a/tests/tap/process.c
+++ b/tests/tap/process.c
@@ -11,11 +11,11 @@
* mkstemp.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2002, 2004, 2005, 2013 Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2011, 2013, 2014
+ * Copyright 2002, 2004-2005, 2013, 2016-2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2011, 2013-2014
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -35,6 +35,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
@@ -134,6 +136,8 @@ run_child_function(test_function_type function, void *data, int *status,
count = 0;
do {
ret = read(fds[0], buf + count, buflen - count - 1);
+ if (SSIZE_MAX - count <= ret)
+ bail("maximum output size exceeded in run_child_function");
if (ret > 0)
count += ret;
if (count >= buflen - 1) {
@@ -141,7 +145,7 @@ run_child_function(test_function_type function, void *data, int *status,
buf = brealloc(buf, buflen);
}
} while (ret > 0);
- buf[count < 0 ? 0 : count] = '\0';
+ buf[count] = '\0';
if (waitpid(child, &rval, 0) == (pid_t) -1)
sysbail("waitpid failed");
close(fds[0]);
@@ -364,7 +368,7 @@ process_stop_all(int success UNUSED, int primary)
* Read the PID of a process from a file. This is necessary when running
* under fakeroot to get the actual PID of the remctld process.
*/
-static long
+static pid_t
read_pidfile(const char *path)
{
FILE *file;
@@ -380,7 +384,7 @@ read_pidfile(const char *path)
pid = strtol(buffer, NULL, 10);
if (pid <= 0)
bail("cannot read PID from %s", path);
- return pid;
+ return (pid_t) pid;
}
diff --git a/tests/tap/process.h b/tests/tap/process.h
index 8137d5d..da21ad3 100644
--- a/tests/tap/process.h
+++ b/tests/tap/process.h
@@ -2,10 +2,10 @@
* Utility functions for tests that use subprocesses.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
* Written by Russ Allbery <eagle@eyrie.org>
- * Copyright 2009, 2010, 2013
+ * Copyright 2009-2010, 2013
* The Board of Trustees of the Leland Stanford Junior University
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,6 +25,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_PROCESS_H
diff --git a/tests/tap/remctl.sh b/tests/tap/remctl.sh
index 0a511a0..e39b88f 100644
--- a/tests/tap/remctl.sh
+++ b/tests/tap/remctl.sh
@@ -6,9 +6,10 @@
# Bourne shell. Instead, all private variables are prefixed with "tap_".
#
# The canonical version of this file is maintained in the rra-c-util package,
-# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle@eyrie.org>
+# Copyright 2016 Russ Allbery <eagle@eyrie.org>
# Copyright 2009, 2012
# The Board of Trustees of the Leland Stanford Junior University
#
@@ -29,6 +30,10 @@
# 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.
+#
+# SPDX-License-Identifier: MIT
+
+. "${C_TAP_SOURCE}/tap/libtap.sh"
# Start remctld. Takes the path to remctld, which may be found via configure,
# and the path to the configuration file.
@@ -45,7 +50,7 @@ remctld_start () {
( "$VALGRIND" --log-file=valgrind.%p --leak-check=full "$1" -m \
-p 14373 -s "$tap_principal" -P "$tap_pidfile" -f "$2" -d -S -F \
-k "$tap_keytab" &)
- [ -f "$BUILD/data/remctld.pid" ] || sleep 5
+ [ -f "$tap_pidfile" ] || sleep 5
else
( "$1" -m -p 14373 -s "$tap_principal" -P "$tap_pidfile" -f "$2" \
-d -S -F -k "$tap_keytab" &)
diff --git a/tests/tap/string.c b/tests/tap/string.c
index 6ed7e68..71cf571 100644
--- a/tests/tap/string.c
+++ b/tests/tap/string.c
@@ -5,9 +5,9 @@
* because they rely on additional portability code from rra-c-util.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2011, 2012 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012 Russ Allbery <eagle@eyrie.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#include <config.h>
diff --git a/tests/tap/string.h b/tests/tap/string.h
index d58f75d..a520210 100644
--- a/tests/tap/string.h
+++ b/tests/tap/string.h
@@ -5,9 +5,9 @@
* because they rely on additional portability code from rra-c-util.
*
* The canonical version of this file is maintained in the rra-c-util package,
- * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
+ * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2011, 2012 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2011-2012 Russ Allbery <eagle@eyrie.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -26,6 +26,8 @@
* 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.
+ *
+ * SPDX-License-Identifier: MIT
*/
#ifndef TAP_STRING_H