Apache HTTPD
minicheck.h
Go to the documentation of this file.
1/* Miniature re-implementation of the "check" library.
2
3 This is intended to support just enough of check to run the Expat
4 tests. This interface is based entirely on the portion of the
5 check library being used.
6
7 This is *source* compatible, but not necessary *link* compatible.
8 __ __ _
9 ___\ \/ /_ __ __ _| |_
10 / _ \\ /| '_ \ / _` | __|
11 | __// \| |_) | (_| | |_
12 \___/_/\_\ .__/ \__,_|\__|
13 |_| XML parser
14
15 Copyright (c) 2004-2006 Fred L. Drake, Jr. <[email protected]>
16 Copyright (c) 2006-2012 Karl Waclawek <[email protected]>
17 Copyright (c) 2016-2024 Sebastian Pipping <[email protected]>
18 Copyright (c) 2022 Rhodri James <[email protected]>
19 Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <[email protected]>
20 Licensed under the MIT license:
21
22 Permission is hereby granted, free of charge, to any person obtaining
23 a copy of this software and associated documentation files (the
24 "Software"), to deal in the Software without restriction, including
25 without limitation the rights to use, copy, modify, merge, publish,
26 distribute, sublicense, and/or sell copies of the Software, and to permit
27 persons to whom the Software is furnished to do so, subject to the
28 following conditions:
29
30 The above copyright notice and this permission notice shall be included
31 in all copies or substantial portions of the Software.
32
33 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
35 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
36 NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
37 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
38 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
39 USE OR OTHER DEALINGS IN THE SOFTWARE.
40*/
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#ifndef XML_MINICHECK_H
47# define XML_MINICHECK_H
48
49# define CK_NOFORK 0
50# define CK_FORK 1
51
52# define CK_SILENT 0
53# define CK_NORMAL 1
54# define CK_VERBOSE 2
55
56/* Workaround for Microsoft's compiler and Tru64 Unix systems where the
57 C compiler has a working __func__, but the C++ compiler only has a
58 working __FUNCTION__. This could be fixed in configure.in, but it's
59 not worth it right now. */
60# if defined(_MSC_VER) || (defined(__osf__) && defined(__cplusplus))
61# define __func__ __FUNCTION__
62# endif
63
64/* PRINTF_LIKE has two effects:
65 1. Make clang's -Wformat-nonliteral stop warning about non-literal format
66 strings in annotated functions' code.
67 2. Make both clang and gcc's -Wformat-nonliteral warn about *callers* of
68 the annotated function that use a non-literal format string.
69*/
70# if defined(__GNUC__)
71# define PRINTF_LIKE(fmtpos, argspos) \
72 __attribute__((format(printf, fmtpos, argspos)))
73# else
74# define PRINTF_LIKE(fmtpos, argspos)
75# endif
76
77# define START_TEST(testname) \
78 static void testname(void) { \
79 _check_set_test_info(__func__, __FILE__, __LINE__); \
80 {
81# define END_TEST \
82 } \
83 }
84
85void PRINTF_LIKE(1, 2) set_subtest(char const *fmt, ...);
86
87# define fail(msg) _fail(__FILE__, __LINE__, msg)
88# define assert_true(cond) \
89 do { \
90 if (! (cond)) { \
91 _fail(__FILE__, __LINE__, "check failed: " #cond); \
92 } \
93 } while (0)
94
95typedef void (*tcase_setup_function)(void);
96typedef void (*tcase_teardown_function)(void);
97typedef void (*tcase_test_function)(void);
98
99typedef struct SRunner SRunner;
100typedef struct Suite Suite;
101typedef struct TCase TCase;
102
108
109struct Suite {
110 const char *name;
112};
113
123
124/* Internal helper. */
125void _check_set_test_info(char const *function, char const *filename,
126 int lineno);
127
128/*
129 * Prototypes for the actual implementation.
130 */
131
132# if defined(__GNUC__)
134# endif
135void
136_fail(const char *file, int line, const char *msg);
137Suite *suite_create(const char *name);
138TCase *tcase_create(const char *name);
139void suite_add_tcase(Suite *suite, TCase *tc);
141 tcase_teardown_function teardown);
144void srunner_run_all(SRunner *runner, const char *context, int verbosity);
148
149#endif /* XML_MINICHECK_H */
150
151#ifdef __cplusplus
152}
153#endif
apr_md5_ctx_t * context
Definition util_md5.h:58
apr_size_t size
const char apr_file_t * file
apr_vformatter_buff_t const char * fmt
Definition apr_lib.h:175
const char apr_status_t(*) apr_pool_t *poo __attribute__)((nonnull(2, 4)))
Definition apr_pools.h:567
apr_size_t const char * filename
Definition apr_shm.h:72
void tcase_add_test(TCase *tc, tcase_test_function test)
Definition minicheck.c:92
#define PRINTF_LIKE(fmtpos, argspos)
Definition minicheck.h:74
Suite * suite_create(const char *name)
Definition minicheck.c:56
void(* tcase_test_function)(void)
Definition minicheck.h:97
void srunner_summarize(SRunner *runner, int verbosity)
Definition minicheck.c:236
void _check_set_test_info(char const *function, char const *filename, int lineno)
Definition minicheck.c:149
void _fail(const char *file, int line, const char *msg)
Definition minicheck.c:247
void suite_add_tcase(Suite *suite, TCase *tc)
Definition minicheck.c:74
void srunner_run_all(SRunner *runner, const char *context, int verbosity)
Definition minicheck.c:192
SRunner * srunner_create(Suite *suite)
Definition minicheck.c:132
void set_subtest(char const *fmt,...)
Definition minicheck.c:157
void tcase_add_checked_fixture(TCase *tc, tcase_setup_function setup, tcase_teardown_function teardown)
Definition minicheck.c:84
void(* tcase_teardown_function)(void)
Definition minicheck.h:96
int srunner_ntests_failed(SRunner *runner)
Definition minicheck.c:262
void srunner_free(SRunner *runner)
Definition minicheck.c:268
void(* tcase_setup_function)(void)
Definition minicheck.h:95
TCase * tcase_create(const char *name)
Definition minicheck.c:65
char * name
int nchecks
Definition minicheck.h:105
Suite * suite
Definition minicheck.h:104
int nfailures
Definition minicheck.h:106
TCase * tests
Definition minicheck.h:111
const char * name
Definition minicheck.h:110
tcase_test_function * tests
Definition minicheck.h:118
const char * name
Definition minicheck.h:115
TCase * next_tcase
Definition minicheck.h:121
int ntests
Definition minicheck.h:119
int allocated
Definition minicheck.h:120
tcase_setup_function setup
Definition minicheck.h:116
tcase_teardown_function teardown
Definition minicheck.h:117