INN commit: trunk (6 files)
INN Commit
rra at isc.org
Mon Dec 17 08:03:23 UTC 2018
Date: Monday, December 17, 2018 @ 00:03:22
Author: iulius
Revision: 10310
Update to latest C TAP Harness upstream version
Modified:
trunk/support/getc-tap-harness
trunk/tests/docs/pod.t
trunk/tests/lib/network/server-t.c
trunk/tests/runtests.c
trunk/tests/tap/basic.c
trunk/tests/tap/basic.h
------------------------------+
support/getc-tap-harness | 4 +--
tests/docs/pod.t | 16 +++++++++++++-
tests/lib/network/server-t.c | 11 ++++++----
tests/runtests.c | 2 -
tests/tap/basic.c | 44 ++++++++++++++++++++++++++++++++---------
tests/tap/basic.h | 12 ++++++++++-
6 files changed, 69 insertions(+), 20 deletions(-)
Modified: support/getc-tap-harness
===================================================================
--- support/getc-tap-harness 2018-12-02 14:35:10 UTC (rev 10309)
+++ support/getc-tap-harness 2018-12-17 08:03:22 UTC (rev 10310)
@@ -133,9 +133,9 @@
}\\
#endif\\
" \
- -e "152 i \\
+ -e "154 i \\
#ifndef INN_LIBINN_H" \
- -e "186 i \\
+ -e "188 i \\
#endif" \
-e 's/^ok.int /new_ok(int /g' \
-e 's/^skip.const /new_skip(const /g' \
Modified: tests/docs/pod.t
===================================================================
--- tests/docs/pod.t 2018-12-02 14:35:10 UTC (rev 10309)
+++ tests/docs/pod.t 2018-12-17 08:03:22 UTC (rev 10310)
@@ -36,8 +36,20 @@
use warnings;
use File::Spec;
-use Test::More;
+# Red Hat's base perl package doesn't include Test::More (one has to install
+# the perl-core package in addition). Try to detect this and skip any Perl
+# tests if Test::More is not present.
+eval {
+ require Test::More;
+ Test::More->import();
+};
+if ($@) {
+ print "1..0 # SKIP Test::More required for test\n"
+ or croak('Cannot write to stdout');
+ exit 0;
+}
+
# Abort if C_TAP_SOURCE isn't set.
if (!$ENV{C_TAP_SOURCE}) {
BAIL_OUT('C_TAP_SOURCE environment variable not set');
@@ -45,7 +57,7 @@
# Load the Test::Pod module.
if (!eval { require Test::Pod }) {
- plan skip_all => 'Test::Pod required for testing POD';
+ plan(skip_all => 'Test::Pod required for testing POD');
}
Test::Pod->import;
Modified: tests/lib/network/server-t.c
===================================================================
--- tests/lib/network/server-t.c 2018-12-02 14:35:10 UTC (rev 10309)
+++ tests/lib/network/server-t.c 2018-12-17 08:03:22 UTC (rev 10310)
@@ -391,7 +391,7 @@
unsigned int count, i;
pid_t child;
struct sockaddr *saddr;
- int status;
+ int status, family;
/* Bind sockets for all available local addresses. */
if (!network_bind_all(SOCK_STREAM, 11119, &fds, &count))
@@ -415,6 +415,8 @@
/* Get the socket type to determine what type of client to run. */
saddr = get_sockaddr(fd);
+ family = saddr->sa_family;
+ free(saddr);
/*
* Fork off a child writer and test the server accept. If IPV6_V6ONLY
@@ -425,16 +427,18 @@
if (child < 0)
sysbail("cannot fork");
else if (child == 0) {
- if (saddr->sa_family == AF_INET) {
+ if (family == AF_INET) {
client_writer("::1", source_ipv6, false);
client_writer("127.0.0.1", source_ipv4, true);
#ifdef HAVE_INET6
- } else if (saddr->sa_family == AF_INET6) {
+ } else if (family == AF_INET6) {
# ifdef IPV6_V6ONLY
client_writer("127.0.0.1", source_ipv4, false);
# endif
client_writer("::1", source_ipv6, true);
#endif
+ } else {
+ die("unknown socket family %d", family);
}
} else {
test_server_accept(fd);
@@ -441,7 +445,6 @@
waitpid(child, &status, 0);
is_int(0, status, "client made correct connections");
}
- free(saddr);
}
network_bind_all_free(fds);
Modified: tests/runtests.c
===================================================================
--- tests/runtests.c 2018-12-02 14:35:10 UTC (rev 10309)
+++ tests/runtests.c 2018-12-17 08:03:22 UTC (rev 10310)
@@ -1322,11 +1322,9 @@
end = skip_non_whitespace(p);
if (strncmp(p, "libtool", end - p) == 0) {
use_libtool = 1;
- p = end;
} else if (strncmp(p, "valgrind", end - p) == 0) {
valgrind = getenv("C_TAP_VALGRIND");
use_valgrind = (valgrind != NULL);
- p = end;
} else {
option = xstrndup(p, end - p);
die("unknown test list option %s", option);
Modified: tests/tap/basic.c
===================================================================
--- tests/tap/basic.c 2018-12-02 14:35:10 UTC (rev 10309)
+++ tests/tap/basic.c 2018-12-17 08:03:22 UTC (rev 10310)
@@ -161,6 +161,8 @@
*/
struct cleanup_func {
test_cleanup_func func;
+ test_cleanup_func_with_data func_with_data;
+ void *data;
struct cleanup_func *next;
};
static struct cleanup_func *cleanup_funcs = NULL;
@@ -367,7 +369,13 @@
*/
primary = (_process == 0 || getpid() == _process);
while (cleanup_funcs != NULL) {
- cleanup_funcs->func(success, primary);
+ if (cleanup_funcs->func_with_data) {
+ void *data = cleanup_funcs->data;
+
+ cleanup_funcs->func_with_data(success, primary, data);
+ } else {
+ cleanup_funcs->func(success, primary);
+ }
current = cleanup_funcs;
cleanup_funcs = cleanup_funcs->next;
free(current);
@@ -939,7 +947,7 @@
;
length = (size_t) (p - s);
copy = malloc(length + 1);
- if (p == NULL)
+ if (copy == NULL)
sysbail("failed to strndup %lu bytes", (unsigned long) length);
memcpy(copy, s, length);
copy[length] = '\0';
@@ -1027,18 +1035,16 @@
free(path);
}
-
-/*
- * Register a cleanup function that is called when testing ends. All such
- * registered functions will be run by finish.
- */
-void
-test_cleanup_register(test_cleanup_func func)
+static void
+register_cleanup(test_cleanup_func func,
+ test_cleanup_func_with_data func_with_data, void *data)
{
struct cleanup_func *cleanup, **last;
cleanup = bmalloc(sizeof(struct cleanup_func));
cleanup->func = func;
+ cleanup->func_with_data = func_with_data;
+ cleanup->data = data;
cleanup->next = NULL;
last = &cleanup_funcs;
while (*last != NULL)
@@ -1045,3 +1051,23 @@
last = &(*last)->next;
*last = cleanup;
}
+
+/*
+ * Register a cleanup function that is called when testing ends. All such
+ * registered functions will be run by finish.
+ */
+void
+test_cleanup_register(test_cleanup_func func)
+{
+ register_cleanup(func, NULL, NULL);
+}
+
+/*
+ * Same as above, but also allows an opaque pointer to be passed to the cleanup
+ * function.
+ */
+void
+test_cleanup_register_with_data(test_cleanup_func_with_data func, void *data)
+{
+ register_cleanup(NULL, func, data);
+}
Modified: tests/tap/basic.h
===================================================================
--- tests/tap/basic.h 2018-12-02 14:35:10 UTC (rev 10309)
+++ tests/tap/basic.h 2018-12-17 08:03:22 UTC (rev 10310)
@@ -195,11 +195,21 @@
* The function must return void and will be passed two arguments: an int that
* will be true if the test completed successfully and false otherwise, and an
* int that will be true if the cleanup function is run in the primary process
- * (the one that called plan or plan_lazy) and false otherwise.
+ * (the one that called plan or plan_lazy) and false otherwise. If
+ * test_cleanup_register_with_data is used instead, a generic pointer can be
+ * provided and will be passed to the cleanup function as a third argument.
+ *
+ * test_cleanup_register_with_data is the better API and should have been the
+ * only API. test_cleanup_register was an API error preserved for backward
+ * cmpatibility.
*/
typedef void (*test_cleanup_func)(int, int);
+typedef void (*test_cleanup_func_with_data)(int, int, void *);
+
void test_cleanup_register(test_cleanup_func)
__attribute__((__nonnull__));
+void test_cleanup_register_with_data(test_cleanup_func_with_data, void *)
+ __attribute__((__nonnull__));
END_DECLS
More information about the inn-committers
mailing list