INN commit: trunk (10 files)
INN Commit
rra at isc.org
Sun Sep 7 14:13:32 UTC 2014
Date: Sunday, September 7, 2014 @ 07:13:32
Author: iulius
Revision: 9686
Sync message handling utilities for the TAP protocol with upstream version
Add tap/messages.c and tap/messages.h to test message handling. Update our test suite to use these files instead of the hack done during the synchronization of C TAP Harness (with support/getc-tap-harness).
Also fix a typo in MANIFEST (fdflag-t.c was mispelled) and a missing dependency in tests/Makefile for nnrpd/auth-ext.t.
Added:
trunk/tests/tap/messages.c
trunk/tests/tap/messages.h
Modified:
trunk/MANIFEST
trunk/support/getc-tap-harness
trunk/tests/Makefile
trunk/tests/lib/confparse-t.c
trunk/tests/lib/innconf-t.c
trunk/tests/nnrpd/auth-ext-t.c
trunk/tests/tap/basic.c
trunk/tests/tap/basic.h
--------------------------+
MANIFEST | 4 +
support/getc-tap-harness | 63 ------------------------------
tests/Makefile | 21 ++++++----
tests/lib/confparse-t.c | 1
tests/lib/innconf-t.c | 1
tests/nnrpd/auth-ext-t.c | 1
tests/tap/basic.c | 53 -------------------------
tests/tap/basic.h | 10 ----
tests/tap/messages.c | 94 +++++++++++++++++++++++++++++++++++++++++++++
tests/tap/messages.h | 52 ++++++++++++++++++++++++
10 files changed, 165 insertions(+), 135 deletions(-)
Modified: MANIFEST
===================================================================
--- MANIFEST 2014-09-07 11:10:41 UTC (rev 9685)
+++ MANIFEST 2014-09-07 14:13:32 UTC (rev 9686)
@@ -878,7 +878,7 @@
tests/lib/date-t.c Tests for lib/date.c
tests/lib/dispatch-t.c Tests for lib/dispatch.c
tests/lib/fakewrite.c Helper functions for xwrite tests
-tests/lib/fdflag-t-c Tests for lib/fdflag.c
+tests/lib/fdflag-t.c Tests for lib/fdflag.c
tests/lib/getaddrinfo-t.c Tests for lib/getaddrinfo.c
tests/lib/getnameinfo-t.c Tests for lib/getnameinfo.c
tests/lib/hash-t.c Tests for lib/hash.c
@@ -929,6 +929,8 @@
tests/tap/float.h Header file for floating point routines
tests/tap/libtap.sh Helper shell library for writing tests
tests/tap/macros.h Helpful macros for TAP header files
+tests/tap/messages.c Message handling utilities for TAP
+tests/tap/messages.h Header file for message handling
tests/tap/process.c Subprocess manipulation utilities for TAP
tests/tap/process.h Header file for subprocess manipulation
tests/tap/string.c String utilities for the TAP protocol
Modified: support/getc-tap-harness
===================================================================
--- support/getc-tap-harness 2014-09-07 11:10:41 UTC (rev 9685)
+++ support/getc-tap-harness 2014-09-07 14:13:32 UTC (rev 9686)
@@ -66,7 +66,6 @@
sed -i -e "55 i \\
/* Specific to the integration of C TAP Harness in INN. */\\
#ifndef LIBTEST_NEW_FORMAT\\
-# include \"inn/messages.h\"\\
# include \"inn/libinn.h\"\\
\\
void\\
@@ -110,58 +109,6 @@
{\\
is_string(wanted, seen, NULL);\\
}\\
-\\
-/* A global buffer into which message_log_buffer stores error messages. */\\
-char *errors = NULL;\\
-\\
-/*\\
- * An error handler that appends all errors to the errors global. Used by\\
- * error_capture.\\
- */\\
-static void\\
-message_log_buffer(int len, const char *fmt, va_list args, int error UNUSED)\\
-{\\
- char *message;\\
-\\
- message = xmalloc(len + 1);\\
- vsnprintf(message, len + 1, fmt, args);\\
- if (errors == NULL) {\\
- errors = concat(message, \"\\\n\", (char *) 0);\\
- } else {\\
- char *new_errors;\\
-\\
- new_errors = concat(errors, message, \"\\\n\", (char *) 0);\\
- free(errors);\\
- errors = new_errors;\\
- }\\
- free(message);\\
-}\\
-\\
-/*\\
- * Turn on the capturing of errors. Errors will be stored in the global\\
- * errors variable where they can be checked by the test suite. Capturing is\\
- * turned off with errors_uncapture.\\
- */\\
-void\\
-errors_capture(void)\\
-{\\
- if (errors != NULL) {\\
- free(errors);\\
- errors = NULL;\\
- }\\
- message_handlers_warn(1, message_log_buffer);\\
- message_handlers_notice(1, message_log_buffer);\\
-}\\
-\\
-/*\\
- * Turn off the capturing of errors again.\\
- */\\
-void\\
-errors_uncapture(void)\\
-{\\
- message_handlers_warn(1, message_log_stderr);\\
- message_handlers_notice(1, message_log_stdout);\\
-}\\
#endif\\
" \
-e "150 i \\
@@ -197,16 +144,6 @@
__attribute__((__format__(printf, 2, 3)));\\
\\
void test_init(int count);\\
-\\
-/* A global buffer into which errors_capture stores errors. */\\
-extern char *errors;\\
-\\
-/* Turn on capturing of errors with errors_capture. Errors reported by warn\\
- * will be stored in the global errors variable. Turn this off again with\\
- * errors_uncapture. Caller is responsible for freeing errors when done.\\
- */\\
-void errors_capture(void);\\
-void errors_uncapture(void);\\
#else\\
# define ok new_ok\\
# define skip new_skip\\
Modified: tests/Makefile
===================================================================
--- tests/Makefile 2014-09-07 11:10:41 UTC (rev 9685)
+++ tests/Makefile 2014-09-07 14:13:32 UTC (rev 9686)
@@ -97,8 +97,9 @@
lib/conffile.t: lib/conffile-t.o tap/basic.o $(LIBINN)
$(LINK) lib/conffile-t.o tap/basic.o $(LIBINN)
-lib/confparse.t: lib/confparse-t.o tap/basic.o tap/float.o $(LIBINN)
- $(LINK) $(LIBM_LDFLAGS) lib/confparse-t.o tap/basic.o tap/float.o $(LIBINN)
+lib/confparse.t: lib/confparse-t.o tap/basic.o tap/float.o tap/messages.o tap/string.o $(LIBINN)
+ $(LINK) $(LIBM_LDFLAGS) lib/confparse-t.o tap/basic.o tap/float.o \
+ tap/messages.o tap/string.o $(LIBINN)
lib/date.t: lib/date-t.o tap/basic.o $(LIBINN)
$(LINK) lib/date-t.o tap/basic.o $(LIBINN)
@@ -150,8 +151,9 @@
lib/inet_ntop.t: lib/inet_ntop.o lib/inet_ntop-t.o tap/basic.o $(LIBINN)
$(LINK) lib/inet_ntop.o lib/inet_ntop-t.o tap/basic.o $(LIBINN)
-lib/innconf.t: lib/innconf-t.o tap/basic.o $(LIBINN)
- $(LINK) lib/innconf-t.o tap/basic.o $(LIBINN) $(LIBS)
+lib/innconf.t: lib/innconf-t.o tap/basic.o tap/messages.o tap/string.o $(LIBINN)
+ $(LINK) lib/innconf-t.o tap/basic.o tap/messages.o \
+ tap/string.o $(LIBINN) $(LIBS)
lib/list.t: lib/list-t.o tap/basic.o $(LIBINN)
$(LINK) lib/list-t.o tap/basic.o $(LIBINN) $(LIBS)
@@ -166,7 +168,8 @@
$(LINK) lib/memcmp.o lib/memcmp-t.o tap/basic.o $(LIBINN)
lib/messages.t: lib/messages-t.o tap/basic.o tap/process.o tap/string.o $(LIBINN)
- $(LINK) lib/messages-t.o tap/basic.o tap/process.o tap/string.o $(LIBINN)
+ $(LINK) lib/messages-t.o tap/basic.o tap/process.o tap/string.o \
+ $(LIBINN)
lib/mkstemp.o: ../lib/mkstemp.c
$(CC) $(CFLAGS) -DTESTING -c -o $@ ../lib/mkstemp.c
@@ -241,10 +244,12 @@
$(CC) $(CFLAGS) -DTESTING -c -o $@ ../lib/xwrite.c
lib/xwrite.t: lib/xwrite-t.o lib/xwrite.o lib/fakewrite.o tap/basic.o $(LIBINN)
- $(LINK) lib/xwrite-t.o lib/xwrite.o lib/fakewrite.o tap/basic.o $(LIBINN)
+ $(LINK) lib/xwrite-t.o lib/xwrite.o lib/fakewrite.o tap/basic.o \
+ $(LIBINN)
-nnrpd/auth-ext.t: nnrpd/auth-ext-t.o ../nnrpd/auth-ext.o $(LIBINN)
- $(LINK) nnrpd/auth-ext-t.o ../nnrpd/auth-ext.o tap/basic.o $(LIBINN)
+nnrpd/auth-ext.t: nnrpd/auth-ext-t.o ../nnrpd/auth-ext.o tap/basic.o tap/messages.o tap/string.o $(LIBINN)
+ $(LINK) nnrpd/auth-ext-t.o ../nnrpd/auth-ext.o tap/basic.o \
+ tap/messages.o tap/string.o $(LIBINN)
overview/api.t: overview/api-t.o tap/basic.o $(STORAGEDEPS)
$(LINK) overview/api-t.o tap/basic.o $(STORAGELIBS) $(LIBS)
Modified: tests/lib/confparse-t.c
===================================================================
--- tests/lib/confparse-t.c 2014-09-07 11:10:41 UTC (rev 9685)
+++ tests/lib/confparse-t.c 2014-09-07 14:13:32 UTC (rev 9686)
@@ -10,6 +10,7 @@
#include "inn/libinn.h"
#include "tap/basic.h"
#include "tap/float.h"
+#include "tap/messages.h"
/* Given a FILE *, read from that file, putting the results into a newly
allocated buffer, until encountering a line consisting solely of "===".
Modified: tests/lib/innconf-t.c
===================================================================
--- tests/lib/innconf-t.c 2014-09-07 11:10:41 UTC (rev 9685)
+++ tests/lib/innconf-t.c 2014-09-07 14:13:32 UTC (rev 9686)
@@ -7,6 +7,7 @@
#include "inn/innconf.h"
#include "inn/messages.h"
#include "tap/basic.h"
+#include "tap/messages.h"
/* We will have strings, integers, bools and lists. */
static const char grep[] =
Modified: tests/nnrpd/auth-ext-t.c
===================================================================
--- tests/nnrpd/auth-ext-t.c 2014-09-07 11:10:41 UTC (rev 9685)
+++ tests/nnrpd/auth-ext-t.c 2014-09-07 14:13:32 UTC (rev 9686)
@@ -6,6 +6,7 @@
#include "inn/messages.h"
#include "tap/basic.h"
+#include "tap/messages.h"
#include "../../nnrpd/nnrpd.h"
Modified: tests/tap/basic.c
===================================================================
--- tests/tap/basic.c 2014-09-07 11:10:41 UTC (rev 9685)
+++ tests/tap/basic.c 2014-09-07 14:13:32 UTC (rev 9686)
@@ -54,7 +54,6 @@
/* Specific to the integration of C TAP Harness in INN. */
#ifndef LIBTEST_NEW_FORMAT
-# include "inn/messages.h"
# include "inn/libinn.h"
void
@@ -98,58 +97,6 @@
{
is_string(wanted, seen, NULL);
}
-
-/* A global buffer into which message_log_buffer stores error messages. */
-char *errors = NULL;
-
-/*
- * An error handler that appends all errors to the errors global. Used by
- * error_capture.
- */
-static void
-message_log_buffer(int len, const char *fmt, va_list args, int error UNUSED)
-{
- char *message;
-
- message = xmalloc(len + 1);
- vsnprintf(message, len + 1, fmt, args);
- if (errors == NULL) {
- errors = concat(message, "\n", (char *) 0);
- } else {
- char *new_errors;
-
- new_errors = concat(errors, message, "\n", (char *) 0);
- free(errors);
- errors = new_errors;
- }
- free(message);
-}
-
-/*
- * Turn on the capturing of errors. Errors will be stored in the global
- * errors variable where they can be checked by the test suite. Capturing is
- * turned off with errors_uncapture.
- */
-void
-errors_capture(void)
-{
- if (errors != NULL) {
- free(errors);
- errors = NULL;
- }
- message_handlers_warn(1, message_log_buffer);
- message_handlers_notice(1, message_log_buffer);
-}
-
-/*
- * Turn off the capturing of errors again.
- */
-void
-errors_uncapture(void)
-{
- message_handlers_warn(1, message_log_stderr);
- message_handlers_notice(1, message_log_stdout);
-}
#endif
/* Windows provides mkdir and rmdir under different names. */
Modified: tests/tap/basic.h
===================================================================
--- tests/tap/basic.h 2014-09-07 11:10:41 UTC (rev 9685)
+++ tests/tap/basic.h 2014-09-07 14:13:32 UTC (rev 9686)
@@ -90,16 +90,6 @@
__attribute__((__format__(printf, 2, 3)));
void test_init(int count);
-
-/* A global buffer into which errors_capture stores errors. */
-extern char *errors;
-
-/* Turn on capturing of errors with errors_capture. Errors reported by warn
- * will be stored in the global errors variable. Turn this off again with
- * errors_uncapture. Caller is responsible for freeing errors when done.
- */
-void errors_capture(void);
-void errors_uncapture(void);
#else
# define ok new_ok
# define skip new_skip
Added: tests/tap/messages.c
===================================================================
--- tests/tap/messages.c (rev 0)
+++ tests/tap/messages.c 2014-09-07 14:13:32 UTC (rev 9686)
@@ -0,0 +1,94 @@
+/* $Id$
+ *
+ * Utility functions to test message handling.
+ *
+ * These functions set up a message handler to trap warn and notice output
+ * into a buffer that can be inspected later, allowing testing of error
+ * 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/>.
+ *
+ * Copyright 2002, 2004, 2005 Russ Allbery <eagle at 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
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * 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.
+ */
+
+#include "config.h"
+#include "clibrary.h"
+
+#include "tap/macros.h"
+#include "tap/messages.h"
+#include "tap/string.h"
+#include "inn/messages.h"
+
+/* A global buffer into which message_log_buffer stores error messages. */
+char *errors = NULL;
+
+
+/*
+ * An error handler that appends all errors to the errors global. Used by
+ * error_capture.
+ */
+static void
+message_log_buffer(int len UNUSED, const char *fmt, va_list args,
+ int error UNUSED)
+{
+ char *message;
+
+ bvasprintf(&message, fmt, args);
+ if (errors == NULL)
+ basprintf(&errors, "%s\n", message);
+ else {
+ char *new_errors;
+
+ basprintf(&new_errors, "%s%s\n", errors, message);
+ free(errors);
+ errors = new_errors;
+ }
+ free(message);
+}
+
+
+/*
+ * Turn on the capturing of errors. Errors will be stored in the global
+ * errors variable where they can be checked by the test suite. Capturing is
+ * turned off with errors_uncapture.
+ */
+void
+errors_capture(void)
+{
+ free(errors);
+ errors = NULL;
+ message_handlers_warn(1, message_log_buffer);
+ message_handlers_notice(1, message_log_buffer);
+}
+
+
+/*
+ * Turn off the capturing of errors again.
+ */
+void
+errors_uncapture(void)
+{
+ message_handlers_warn(1, message_log_stderr);
+ message_handlers_notice(1, message_log_stdout);
+}
Property changes on: trunk/tests/tap/messages.c
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: tests/tap/messages.h
===================================================================
--- tests/tap/messages.h (rev 0)
+++ tests/tap/messages.h 2014-09-07 14:13:32 UTC (rev 9686)
@@ -0,0 +1,52 @@
+/* $Id$
+ *
+ * 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/>.
+ *
+ * Copyright 2002 Russ Allbery <eagle at eyrie.org>
+ * 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
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * 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.
+ */
+
+#ifndef TAP_MESSAGES_H
+#define TAP_MESSAGES_H 1
+
+#include "config.h"
+#include "tap/macros.h"
+
+/* A global buffer into which errors_capture stores errors. */
+extern char *errors;
+
+BEGIN_DECLS
+
+/*
+ * Turn on capturing of errors with errors_capture. Errors reported by warn
+ * will be stored in the global errors variable. Turn this off again with
+ * errors_uncapture. Caller is responsible for freeing errors when done.
+ */
+void errors_capture(void);
+void errors_uncapture(void);
+
+END_DECLS
+
+#endif /* !TAP_MESSAGES_H */
Property changes on: trunk/tests/tap/messages.h
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
More information about the inn-committers
mailing list