diff options
Diffstat (limited to 'tests/tap')
-rw-r--r-- | tests/tap/basic.c | 12 | ||||
-rw-r--r-- | tests/tap/basic.h | 8 | ||||
-rw-r--r-- | tests/tap/kerberos.c | 31 | ||||
-rw-r--r-- | tests/tap/kerberos.h | 8 | ||||
-rw-r--r-- | tests/tap/macros.h | 8 | ||||
-rw-r--r-- | tests/tap/messages.c | 4 | ||||
-rw-r--r-- | tests/tap/process.c | 9 | ||||
-rw-r--r-- | tests/tap/string.h | 2 |
8 files changed, 64 insertions, 18 deletions
diff --git a/tests/tap/basic.c b/tests/tap/basic.c index 92a749b..4f8be04 100644 --- a/tests/tap/basic.c +++ b/tests/tap/basic.c @@ -12,7 +12,8 @@ * 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 Russ Allbery <eagle@eyrie.org> + * 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 * The Board of Trustees of the Leland Stanford Junior University * @@ -105,7 +106,7 @@ static struct cleanup_func *cleanup_funcs = NULL; /* * Registered diag files. Any output found in these files will be printed out * as if it were passed to diag() before any other output we do. This allows - * background processes to log to a file and have that output interleved with + * background processes to log to a file and have that output interleaved with * the test output. */ struct diag_file { @@ -192,7 +193,7 @@ check_diag_files(void) struct diag_file *file; fpos_t where; size_t length; - int incomplete; + int size, incomplete; /* * Walk through each file and read each line of output available. The @@ -216,7 +217,8 @@ check_diag_files(void) /* Continue until we get EOF or an incomplete line of data. */ incomplete = 0; while (!feof(file->file) && !incomplete) { - if (fgets(file->buffer, file->bufsize, file->file) == NULL) { + size = file->bufsize > INT_MAX ? INT_MAX : (int) file->bufsize; + if (fgets(file->buffer, size, file->file) == NULL) { if (ferror(file->file)) sysbail("cannot read from %s", file->name); continue; @@ -807,7 +809,7 @@ bstrndup(const char *s, size_t n) /* Don't assume that the source string is nul-terminated. */ for (p = s; (size_t) (p - s) < n && *p != '\0'; p++) ; - length = p - s; + length = (size_t) (p - s); copy = malloc(length + 1); if (p == NULL) sysbail("failed to strndup %lu bytes", (unsigned long) length); diff --git a/tests/tap/basic.h b/tests/tap/basic.h index c002df9..4ecaaec 100644 --- a/tests/tap/basic.h +++ b/tests/tap/basic.h @@ -4,7 +4,8 @@ * 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 Russ Allbery <eagle@eyrie.org> + * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015 + * Russ Allbery <eagle@eyrie.org> * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2014 * The Board of Trustees of the Leland Stanford Junior University * @@ -72,7 +73,8 @@ void skip_all(const char *format, ...) */ int ok(int success, const char *format, ...) __attribute__((__format__(printf, 2, 3))); -int okv(int success, const char *format, va_list args); +int okv(int success, const char *format, va_list args) + __attribute__((__format__(printf, 2, 0))); void skip(const char *reason, ...) __attribute__((__format__(printf, 1, 2))); @@ -155,7 +157,7 @@ void test_tmpdir_free(char *path); * registered functions will be run during atexit handling (and are therefore * subject to all the same constraints and caveats as atexit functions). * - * The function must return void and will be passed two argument, an int that + * 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. diff --git a/tests/tap/kerberos.c b/tests/tap/kerberos.c index 578a858..6a5025a 100644 --- a/tests/tap/kerberos.c +++ b/tests/tap/kerberos.c @@ -55,7 +55,9 @@ * Disable the requirement that format strings be literals, since it's easier * to handle the possible patterns for kinit commands as an array. */ -#pragma GCC diagnostic ignored "-Wformat-nonliteral" +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 2) || defined(__clang__) +# pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif /* @@ -219,6 +221,8 @@ kerberos_free(void) free(config->userprinc); free(config->username); free(config->password); + free(config->pkinit_principal); + free(config->pkinit_cert); free(config); config = NULL; } @@ -351,6 +355,31 @@ kerberos_setup(enum kerberos_needs needs) test_file_path_free(path); /* + * If we have PKINIT configuration, read it and fill out the relevant + * members of our config struct. + */ + path = test_file_path("config/pkinit-principal"); + if (path != NULL) + file = fopen(path, "r"); + if (file != NULL) { + if (fgets(buffer, sizeof(buffer), file) == NULL) + bail("cannot read %s", path); + if (buffer[strlen(buffer) - 1] != '\n') + bail("no newline in %s", path); + buffer[strlen(buffer) - 1] = '\0'; + fclose(file); + test_file_path_free(path); + path = test_file_path("config/pkinit-cert"); + if (path != NULL) { + config->pkinit_principal = bstrdup(buffer); + config->pkinit_cert = bstrdup(path); + } + } + test_file_path_free(path); + if (config->pkinit_cert == NULL && (needs & TAP_KRB_NEEDS_PKINIT) != 0) + skip_all("PKINIT tests not configured"); + + /* * Register the cleanup function so that the caller doesn't have to do * explicit cleanup. */ diff --git a/tests/tap/kerberos.h b/tests/tap/kerberos.h index 8be0add..26f45f9 100644 --- a/tests/tap/kerberos.h +++ b/tests/tap/kerberos.h @@ -46,17 +46,21 @@ struct kerberos_config { char *username; /* The local (non-realm) part of principal. */ char *realm; /* The realm part of the principal. */ char *password; /* The password. */ + char *pkinit_principal; /* Principal for PKINIT authentication. */ + char *pkinit_cert; /* Path to certificates for PKINIT. */ }; /* * Whether to skip all tests (by calling skip_all) in kerberos_setup if - * certain configuration information isn't available. + * certain configuration information isn't available. "_BOTH" means that the + * tests require both keytab and password, but PKINIT is not required. */ enum kerberos_needs { TAP_KRB_NEEDS_NONE = 0x00, TAP_KRB_NEEDS_KEYTAB = 0x01, TAP_KRB_NEEDS_PASSWORD = 0x02, - TAP_KRB_NEEDS_BOTH = 0x01 | 0x02 + TAP_KRB_NEEDS_BOTH = 0x01 | 0x02, + TAP_KRB_NEEDS_PKINIT = 0x04 }; BEGIN_DECLS diff --git a/tests/tap/macros.h b/tests/tap/macros.h index 04cc420..139cff0 100644 --- a/tests/tap/macros.h +++ b/tests/tap/macros.h @@ -8,7 +8,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 2008, 2012, 2013 Russ Allbery <eagle@eyrie.org> + * Copyright 2008, 2012, 2013, 2015 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"), @@ -53,8 +53,10 @@ * variadic macro support. */ #if !defined(__attribute__) && !defined(__alloc_size__) -# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) -# define __alloc_size__(spec, args...) /* empty */ +# if defined(__GNUC__) && !defined(__clang__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) +# define __alloc_size__(spec, args...) /* empty */ +# endif # endif #endif diff --git a/tests/tap/messages.c b/tests/tap/messages.c index 45b0566..9c28789 100644 --- a/tests/tap/messages.c +++ b/tests/tap/messages.c @@ -8,7 +8,7 @@ * 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@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 * @@ -47,7 +47,7 @@ char *errors = NULL; * An error handler that appends all errors to the errors global. Used by * error_capture. */ -static void +static void __attribute__((__format__(printf, 2, 0))) message_log_buffer(int len UNUSED, const char *fmt, va_list args, int error UNUSED) { diff --git a/tests/tap/process.c b/tests/tap/process.c index 6461fb4..8c22324 100644 --- a/tests/tap/process.c +++ b/tests/tap/process.c @@ -47,8 +47,11 @@ # include <sys/select.h> #endif #include <sys/stat.h> -#include <sys/time.h> +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +#endif #include <sys/wait.h> +#include <time.h> #include <tests/tap/basic.h> #include <tests/tap/process.h> @@ -229,6 +232,10 @@ process_free(struct process *process) { struct process **prev; + /* Do nothing if called with a NULL argument. */ + if (process == NULL) + return; + /* Remove the process from the global list. */ prev = &processes; while (*prev != NULL && *prev != process) diff --git a/tests/tap/string.h b/tests/tap/string.h index cc51945..d58f75d 100644 --- a/tests/tap/string.h +++ b/tests/tap/string.h @@ -42,7 +42,7 @@ BEGIN_DECLS void basprintf(char **, const char *, ...) __attribute__((__nonnull__, __format__(printf, 2, 3))); void bvasprintf(char **, const char *, va_list) - __attribute__((__nonnull__)); + __attribute__((__nonnull__, __format__(printf, 2, 0))); END_DECLS |