aboutsummaryrefslogtreecommitdiff
path: root/tests/util/messages-t.c
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2008-04-24 02:02:49 +0000
committerRuss Allbery <rra@stanford.edu>2008-04-24 02:02:49 +0000
commit92ff7f21ad0b167f8d742a9d7b5f93704a57619c (patch)
tree7adae5f227b6463e07d5cd0f1dab82b7f1c6be47 /tests/util/messages-t.c
parent34c58f9471b3df4fa8b719b3c3534940ba5cfe1b (diff)
Major coding style cleanup. Updated all shared code from my other
projects. The configure option requesting AFS kaserver support (and thus building kasetkey) is now --with-kaserver instead of --with-afs. If KRB5_CONFIG was explicitly set in the environment, don't use a different krb5-config based on --with-krb4 or --with-krb5. If krb5-config isn't executable, don't use it. This allows one to force library probing by setting KRB5_CONFIG to point to a nonexistent file. Sanity-check the results of krb5-config before proceeding and error out in configure if they don't work. Stop setting Stanford-specific compile-time defaults for the wallet server and port.
Diffstat (limited to 'tests/util/messages-t.c')
-rw-r--r--tests/util/messages-t.c90
1 files changed, 54 insertions, 36 deletions
diff --git a/tests/util/messages-t.c b/tests/util/messages-t.c
index ef58737..434ef56 100644
--- a/tests/util/messages-t.c
+++ b/tests/util/messages-t.c
@@ -1,28 +1,30 @@
-/* $Id$ */
-/* Test suite for error handling routines. */
-
-/* Copyright (c) 2004, 2005, 2006
- by Internet Systems Consortium, Inc. ("ISC")
- Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
- 2002, 2003 by The Internet Software Consortium and Rich Salz
-
- This code is derived from software contributed to the Internet Software
- Consortium by Rich Salz.
-
- Permission to use, copy, modify, and distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
- SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+/* $Id$
+ *
+ * Test suite for error handling routines.
+ *
+ * Copyright 2004, 2005, 2006
+ * by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+ * 2003 by The Internet Software Consortium and Rich Salz
+ *
+ * This code is derived from software contributed to the Internet Software
+ * Consortium by Rich Salz.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
#include <config.h>
-#include <system.h>
+#include <portable/system.h>
#include <errno.h>
#include <fcntl.h>
@@ -32,14 +34,17 @@
#include <tests/libtest.h>
#include <util/util.h>
-#define END (char *) 0
+#define END (char *) 0
/* Test function type. */
typedef void (*test_function_t)(void);
-/* Fork and execute the provided function, connecting stdout and stderr to a
- pipe. Captures the output into the provided buffer and returns the exit
- status as a waitpid status value. */
+
+/*
+ * Fork and execute the provided function, connecting stdout and stderr to a
+ * pipe. Captures the output into the provided buffer and returns the exit
+ * status as a waitpid status value.
+ */
static int
run_test(test_function_t function, char *buf, size_t buflen)
{
@@ -70,8 +75,10 @@ run_test(test_function_t function, char *buf, size_t buflen)
fflush(stdout);
_exit(0);
} else {
- /* In the parent; close the extra file descriptor, read the output
- if any, and then collect the exit status. */
+ /*
+ * In the parent; close the extra file descriptor, read the output if
+ * any, and then collect the exit status.
+ */
close(fds[1]);
count = 0;
do {
@@ -86,7 +93,10 @@ run_test(test_function_t function, char *buf, size_t buflen)
return rval;
}
-/* Test functions. */
+
+/*
+ * Test functions.
+ */
static void test1(void) { warn("warning"); }
static void test2(void) { die("fatal"); }
static void test3(void) { errno = EPERM; syswarn("permissions"); }
@@ -192,8 +202,11 @@ static void test24(void) {
notice("third");
}
-/* Given the test number, intended exit status and message, and the function
- to run, print ok or not ok. */
+
+/*
+ * Given the test number, intended exit status and message, and the function
+ * to run, print ok or not ok.
+ */
static void
test_error(int n, int status, const char *output, test_function_t function)
{
@@ -214,9 +227,11 @@ test_error(int n, int status, const char *output, test_function_t function)
printf("%sok %d\n", succeeded ? "" : "not ", n);
}
-/* Given the test number, intended status, intended message sans the
- appended strerror output, errno, and the function to run, print ok or not
- ok. */
+
+/*
+ * Given the test number, intended status, intended message sans the appended
+ * strerror output, errno, and the function to run, print ok or not ok.
+ */
static void
test_strerror(int n, int status, const char *output, int error,
test_function_t function)
@@ -228,7 +243,10 @@ test_strerror(int n, int status, const char *output, int error,
free(full_output);
}
-/* Run the tests. */
+
+/*
+ * Run the tests.
+ */
int
main(void)
{