diff options
author | Russ Allbery <eagle@eyrie.org> | 2020-05-17 17:05:30 -0700 |
---|---|---|
committer | Russ Allbery <eagle@eyrie.org> | 2020-05-17 17:05:30 -0700 |
commit | c138111a3c27863308b6552a5527a9e821a3dc11 (patch) | |
tree | fe3c16462bf0213708f20d251a63e5b9bbf2d23f /tests/tap/basic.h | |
parent | ccfbd34d597318215b979338c4cb5d7e4a3f0d6f (diff) |
Update to rra-c-util 8.2 and C TAP Harness 4.7
Update to rra-c-util 8.2:
* Implement explicit_bzero with memset if it is not available.
* Reformat all C source using clang-format 10.
* Work around Test::Strict not skipping .git directories.
* Fix warnings with perltidy 20190601 and Perl::Critic 1.134.
* Fix warnings with Clang 10, GCC 10, and the Clang static analyzer.
Update to C TAP Harness 4.7:
* Fix warnings with GCC 10.
* Reformat all C source using clang-format 10.
* Fixed malloc error checking in bstrndup.
Diffstat (limited to 'tests/tap/basic.h')
-rw-r--r-- | tests/tap/basic.h | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/tests/tap/basic.h b/tests/tap/basic.h index 3f46e4f..45f15f2 100644 --- a/tests/tap/basic.h +++ b/tests/tap/basic.h @@ -5,7 +5,7 @@ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>. * * Written by Russ Allbery <eagle@eyrie.org> - * Copyright 2009-2018 Russ Allbery <eagle@eyrie.org> + * Copyright 2009-2019 Russ Allbery <eagle@eyrie.org> * Copyright 2001-2002, 2004-2008, 2011-2012, 2014 * The Board of Trustees of the Leland Stanford Junior University * @@ -33,9 +33,9 @@ #ifndef TAP_BASIC_H #define TAP_BASIC_H 1 +#include <stdarg.h> /* va_list */ +#include <stddef.h> /* size_t */ #include <tests/tap/macros.h> -#include <stdarg.h> /* va_list */ -#include <stddef.h> /* size_t */ /* * Used for iterating through arrays. ARRAY_SIZE returns the number of @@ -43,8 +43,8 @@ * ARRAY_END returns a pointer to the element past the end (ISO C99 makes it * legal to refer to such a pointer as long as it's never dereferenced). */ -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#define ARRAY_END(array) (&(array)[ARRAY_SIZE(array)]) +#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) +#define ARRAY_END(array) (&(array)[ARRAY_SIZE(array)]) BEGIN_DECLS @@ -77,8 +77,7 @@ int ok(int success, const char *format, ...) __attribute__((__format__(printf, 2, 3))); 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))); +void skip(const char *reason, ...) __attribute__((__format__(printf, 1, 2))); /* * Report the same status on, or skip, the next count tests. ok_block() @@ -125,10 +124,8 @@ int sysdiag(const char *format, ...) * diag(). Nul characters are not supported in these files and will result in * truncated output. */ -void diag_file_add(const char *file) - __attribute__((__nonnull__)); -void diag_file_remove(const char *file) - __attribute__((__nonnull__)); +void diag_file_add(const char *file) __attribute__((__nonnull__)); +void diag_file_remove(const char *file) __attribute__((__nonnull__)); /* Allocate memory, reporting a fatal error with bail on failure. */ void *bcalloc(size_t, size_t) @@ -145,6 +142,14 @@ char *bstrndup(const char *, size_t) __attribute__((__malloc__, __nonnull__, __warn_unused_result__)); /* + * Macros that cast the return value from b* memory functions, making them + * usable in C++ code and providing some additional type safety. + */ +#define bcalloc_type(n, type) ((type *) bcalloc((n), sizeof(type))) +#define breallocarray_type(p, n, type) \ + ((type *) breallocarray((p), (n), sizeof(type))) + +/* * 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(). */ @@ -156,8 +161,7 @@ void test_file_path_free(char *path); * 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__)); +char *test_tmpdir(void) __attribute__((__malloc__, __warn_unused_result__)); void test_tmpdir_free(char *path); /* @@ -168,10 +172,19 @@ void test_tmpdir_free(char *path); * 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); -void test_cleanup_register(test_cleanup_func) +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 |