INN commit: trunk/tests (8 files)
INN Commit
rra at isc.org
Sun Jan 31 13:10:58 UTC 2016
Date: Sunday, January 31, 2016 @ 05:10:58
Author: iulius
Revision: 9983
Update to latest C TAP Harness upstream version
Modified:
trunk/tests/Makefile
trunk/tests/README
trunk/tests/docs/pod.t
trunk/tests/lib/xmalloc.t
trunk/tests/runtests.c
trunk/tests/tap/basic.c
trunk/tests/tap/basic.h
trunk/tests/tap/libtap.sh
---------------+
Makefile | 2 +-
README | 28 +++++++++++++++-------------
docs/pod.t | 12 ++++++------
lib/xmalloc.t | 6 +++---
runtests.c | 55 +++++++++++++++++++++++++++++++++++++------------------
tap/basic.c | 16 ++++++++--------
tap/basic.h | 10 +++++-----
tap/libtap.sh | 24 ++++++++++++------------
8 files changed, 87 insertions(+), 66 deletions(-)
Modified: Makefile
===================================================================
--- Makefile 2016-01-24 00:58:52 UTC (rev 9982)
+++ Makefile 2016-01-31 13:10:58 UTC (rev 9983)
@@ -3,7 +3,7 @@
include ../Makefile.global
top = ..
-RUNTESTS_CFLAGS = -DSOURCE='"$(abs_builddir)/tests"' -DBUILD='"$(abs_builddir)/tests"'
+RUNTESTS_CFLAGS = -DC_TAP_SOURCE='"$(abs_builddir)/tests"' -DC_TAP_BUILD='"$(abs_builddir)/tests"'
CFLAGS = $(GCFLAGS) $(BDB_CPPFLAGS) $(DBM_CPPFLAGS) $(PERL_CPPFLAGS) $(PYTHON_CPPFLAGS) $(SSL_CPPFLAGS) $(SASL_CPPFLAGS) $(KRB5_CPPFLAGS) $(RUNTESTS_CFLAGS) -I.
## On some platforms, linking with libm is needed as the test suite uses
Modified: README
===================================================================
--- README 2016-01-24 00:58:52 UTC (rev 9982)
+++ README 2016-01-31 13:10:58 UTC (rev 9983)
@@ -70,18 +70,20 @@
One of the special features of C TAP Harness is the environment that
it sets up for your test cases. If your test program is called under
- the runtests driver, the environment variables SOURCE and BUILD will
- be set to the top of the test directory in the source tree and the top
- of the build tree, respectively. You can use those environment
- variables to locate additional test data, programs and libraries built
- as part of your software build, and other supporting information
- needed by tests.
+ the runtests driver, the environment variables C_TAP_SOURCE and
+ C_TAP_BUILD will be set to the top of the test directory in the source
+ tree and the top of the build tree, respectively. You can use those
+ environment variables to locate additional test data, programs and
+ libraries built as part of your software build, and other supporting
+ information needed by tests.
The C and shell TAP libraries support a test_file_path() function,
which looks for a file under the build tree and then under the source
- tree, using the BUILD and SOURCE environment variables, and return the
- full path to the file. This can be used to locate supporting data
- files.
+ tree, using the C_TAP_BUILD and C_TAP_SOURCE environment variables,
+ and return the full path to the file. This can be used to locate
+ supporting data files. They also support a test_tmpdir() function
+ that returns a directory that can be used for temporary files during
+ tests.
Perl
@@ -190,7 +192,7 @@
your test suite area. It can then be loaded by tests written in shell
using the environment set up by runtests with:
- . "$SOURCE"/tap/libtap.sh
+ . "$C_TAP_SOURCE"/tap/libtap.sh
Here is a complete test case written in shell which produces the same
output as the TAP sample above:
@@ -197,8 +199,8 @@
#!/bin/sh
- . "$SOURCE"/tap/libtap.sh
- cd "$BUILD"
+ . "$C_TAP_SOURCE"/tap/libtap.sh
+ cd "$C_TAP_BUILD"
plan 4
ok 'the first test' true
@@ -240,7 +242,7 @@
This file is part of the documentation of C TAP Harness, which can be
found at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
- Copyright 2010 Russ Allbery <eagle at eyrie.org>
+ Copyright 2010, 2016 Russ Allbery <eagle at eyrie.org>
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
Modified: docs/pod.t
===================================================================
--- docs/pod.t 2016-01-24 00:58:52 UTC (rev 9982)
+++ docs/pod.t 2016-01-31 13:10:58 UTC (rev 9983)
@@ -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, 2015 Russ Allbery <eagle at eyrie.org>
+# Copyright 2009, 2010, 2013, 2014, 2015, 2016 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"),
@@ -34,9 +34,9 @@
use File::Spec;
use Test::More;
-# Abort if SOURCE isn't set.
-if (!$ENV{SOURCE}) {
- BAIL_OUT('SOURCE environment variable not set');
+# Abort if C_TAP_SOURCE isn't set.
+if (!$ENV{C_TAP_SOURCE}) {
+ BAIL_OUT('C_TAP_SOURCE environment variable not set');
}
# Load the Test::Pod module.
@@ -45,8 +45,8 @@
}
Test::Pod->import;
-# SOURCE will be the test directory. Change to the parent.
-my ($vol, $dirs) = File::Spec->splitpath($ENV{SOURCE}, 1);
+# C_TAP_SOURCE will be the test directory. Change to the parent.
+my ($vol, $dirs) = File::Spec->splitpath($ENV{C_TAP_SOURCE}, 1);
my @dirs = File::Spec->splitdir($dirs);
pop(@dirs);
if ($dirs[-1] eq File::Spec->updir) {
Modified: lib/xmalloc.t
===================================================================
--- lib/xmalloc.t 2016-01-24 00:58:52 UTC (rev 9982)
+++ lib/xmalloc.t 2016-01-31 13:10:58 UTC (rev 9983)
@@ -8,7 +8,7 @@
# which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>.
#
# Written by Russ Allbery <eagle at eyrie.org>
-# Copyright 2000, 2001, 2006, 2014 Russ Allbery <eagle at eyrie.org>
+# Copyright 2000, 2001, 2006, 2014, 2016 Russ Allbery <eagle at eyrie.org>
# Copyright 2008, 2009, 2010, 2012
# The Board of Trustees of the Leland Stanford Junior University
#
@@ -30,8 +30,8 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
-. "$SOURCE/tap/libtap.sh"
-cd "$BUILD/lib"
+. "$C_TAP_SOURCE/tap/libtap.sh"
+cd "$C_TAP_BUILD/lib"
# Run an xmalloc test. Takes the description, the expectd exit status, the
# output, and the arguments.
Modified: runtests.c
===================================================================
--- runtests.c 2016-01-24 00:58:52 UTC (rev 9982)
+++ runtests.c 2016-01-31 13:10:58 UTC (rev 9983)
@@ -49,11 +49,11 @@
* 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.
+ * If built with the C preprocessor symbols C_TAP_SOURCE and C_TAP_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.
*
* If the -v option is given, or the C_TAP_VERBOSE environment variable is set,
* display the full output of each test as it runs rather than showing a
@@ -64,7 +64,7 @@
* Harness <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
* Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
- * 2014, 2015 Russ Allbery <eagle at eyrie.org>
+ * 2014, 2015, 2016 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"),
@@ -136,15 +136,17 @@
/*
* The source and build versions of the tests directory. This is used to set
- * the SOURCE and BUILD environment variables and find test programs, if set.
- * Normally, this should be set as part of the build process to the test
- * subdirectories of $(abs_top_srcdir) and $(abs_top_builddir) respectively.
+ * the C_TAP_SOURCE and C_TAP_BUILD environment variables (and the SOURCE and
+ * BUILD environment variables set for backward compatibility) and find test
+ * programs, if set. Normally, this should be set as part of the build
+ * process to the test subdirectories of $(abs_top_srcdir) and
+ * $(abs_top_builddir) respectively.
*/
-#ifndef SOURCE
-# define SOURCE NULL
+#ifndef C_TAP_SOURCE
+# define C_TAP_SOURCE NULL
#endif
-#ifndef BUILD
-# define BUILD NULL
+#ifndef C_TAP_BUILD
+# define C_TAP_BUILD NULL
#endif
/* Test status codes. */
@@ -1480,8 +1482,9 @@
/*
- * Main routine. Set the SOURCE and BUILD environment variables and then,
- * given a file listing tests, run each test listed.
+ * Main routine. Set the C_TAP_SOURCE, C_TAP_BUILD, SOURCE, and BUILD
+ * environment variables and then, given a file listing tests, run each test
+ * listed.
*/
int
main(int argc, char *argv[])
@@ -1490,13 +1493,15 @@
int status = 0;
int single = 0;
enum test_verbose verbose = CONCISE;
+ char *c_tap_source_env = NULL;
+ char *c_tap_build_env = NULL;
char *source_env = NULL;
char *build_env = NULL;
const char *program;
const char *shortlist;
const char *list = NULL;
- const char *source = SOURCE;
- const char *build = BUILD;
+ const char *source = C_TAP_SOURCE;
+ const char *build = C_TAP_BUILD;
struct testlist *tests;
program = argv[0];
@@ -1538,13 +1543,23 @@
if (getenv("C_TAP_VERBOSE") != NULL)
verbose = VERBOSE;
- /* Set SOURCE and BUILD environment variables. */
+ /*
+ * Set C_TAP_SOURCE and C_TAP_BUILD environment variables. Also set
+ * SOURCE and BUILD for backward compatibility, although we're trying to
+ * migrate to the ones with a C_TAP_* prefix.
+ */
if (source != NULL) {
+ c_tap_source_env = concat("C_TAP_SOURCE=", source, (const char *) 0);
+ if (putenv(c_tap_source_env) != 0)
+ sysdie("cannot set C_TAP_SOURCE in the environment");
source_env = concat("SOURCE=", source, (const char *) 0);
if (putenv(source_env) != 0)
sysdie("cannot set SOURCE in the environment");
}
if (build != NULL) {
+ c_tap_build_env = concat("C_TAP_BUILD=", build, (const char *) 0);
+ if (putenv(c_tap_build_env) != 0)
+ sysdie("cannot set C_TAP_BUILD in the environment");
build_env = concat("BUILD=", build, (const char *) 0);
if (putenv(build_env) != 0)
sysdie("cannot set BUILD in the environment");
@@ -1569,11 +1584,15 @@
/* For valgrind cleanliness, free all our memory. */
if (source_env != NULL) {
+ putenv((char *) "C_TAP_SOURCE=");
putenv((char *) "SOURCE=");
+ free(c_tap_source_env);
free(source_env);
}
if (build_env != NULL) {
+ putenv((char *) "C_TAP_BUILD=");
putenv((char *) "BUILD=");
+ free(c_tap_build_env);
free(build_env);
}
exit(status);
Modified: tap/basic.c
===================================================================
--- tap/basic.c 2016-01-24 00:58:52 UTC (rev 9982)
+++ tap/basic.c 2016-01-31 13:10:58 UTC (rev 9983)
@@ -13,7 +13,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, 2011, 2012, 2013, 2014, 2015
+ * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
* 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
@@ -874,10 +874,10 @@
/*
- * 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)
@@ -884,7 +884,7 @@
{
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++) {
@@ -914,7 +914,7 @@
/*
- * 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.
@@ -929,7 +929,7 @@
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);
Modified: tap/basic.h
===================================================================
--- tap/basic.h 2016-01-24 00:58:52 UTC (rev 9982)
+++ tap/basic.h 2016-01-31 13:10:58 UTC (rev 9983)
@@ -5,7 +5,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, 2011, 2012, 2013, 2014, 2015
+ * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
* 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
@@ -164,8 +164,8 @@
__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__));
@@ -172,8 +172,8 @@
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__));
Modified: tap/libtap.sh
===================================================================
--- tap/libtap.sh 2016-01-24 00:58:52 UTC (rev 9982)
+++ tap/libtap.sh 2016-01-31 13:10:58 UTC (rev 9983)
@@ -12,7 +12,7 @@
# <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
#
# Written by Russ Allbery <eagle at eyrie.org>
-# Copyright 2009, 2010, 2011, 2012 Russ Allbery <eagle at eyrie.org>
+# Copyright 2009, 2010, 2011, 2012, 2016 Russ Allbery <eagle at eyrie.org>
# Copyright 2006, 2007, 2008, 2013
# The Board of Trustees of the Leland Stanford Junior University
#
@@ -214,32 +214,32 @@
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"
More information about the inn-committers
mailing list