]> git.ipfire.org Git - thirdparty/glibc.git/blob - support/check.h
Add SYSV message queue test
[thirdparty/glibc.git] / support / check.h
1 /* Functionality for reporting test results.
2 Copyright (C) 2016 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19 #ifndef SUPPORT_CHECK_H
20 #define SUPPORT_CHECK_H
21
22 #include <sys/cdefs.h>
23
24 __BEGIN_DECLS
25
26 /* Print failure message to standard output and return 1. */
27 #define FAIL_RET(...) \
28 return support_print_failure_impl (__FILE__, __LINE__, __VA_ARGS__)
29
30 /* Print failure message and terminate the process with STATUS. */
31 #define FAIL_EXIT(status, ...) \
32 support_exit_failure_impl (status, __FILE__, __LINE__, __VA_ARGS__)
33
34 /* Print failure message and terminate with exit status 1. */
35 #define FAIL_EXIT1(...) \
36 support_exit_failure_impl (1, __FILE__, __LINE__, __VA_ARGS__)
37
38 /* Print failure message and terminate with as unsupported test (exit
39 status of 77). */
40 #define FAIL_UNSUPPORTED(...) \
41 support_exit_failure_impl (77, __FILE__, __LINE__, __VA_ARGS__)
42
43 /* Record a test failure (but continue executing) if EXPR evaluates to
44 false. */
45 #define TEST_VERIFY(expr) \
46 ({ \
47 if (expr) \
48 ; \
49 else \
50 support_test_verify_impl (-1, __FILE__, __LINE__, #expr); \
51 })
52
53 /* Record a test failure and exit if EXPR evaluates to false. */
54 #define TEST_VERIFY_EXIT(expr) \
55 ({ \
56 if (expr) \
57 ; \
58 else \
59 support_test_verify_impl (1, __FILE__, __LINE__, #expr); \
60 })
61
62 int support_print_failure_impl (const char *file, int line,
63 const char *format, ...)
64 __attribute__ ((nonnull (1), format (printf, 3, 4)));
65 void support_exit_failure_impl (int exit_status,
66 const char *file, int line,
67 const char *format, ...)
68 __attribute__ ((noreturn, nonnull (2), format (printf, 4, 5)));
69 void support_test_verify_impl (int status, const char *file, int line,
70 const char *expr);
71
72 /* Record a test failure. This function returns and does not
73 terminate the process. The failure counter is stored in a shared
74 memory mapping, so that failures reported in child processes are
75 visible to the parent process and test driver. This function
76 depends on initialization by an ELF constructor, so it can only be
77 invoked after the test driver has run. Note that this function
78 does not support reporting failures from a DSO. */
79 void support_record_failure (void);
80
81 /* Internal function called by the test driver. */
82 int support_report_failure (int status)
83 __attribute__ ((weak, warn_unused_result));
84
85 /* Internal function used to test the failure recording framework. */
86 void support_record_failure_reset (void);
87
88 __END_DECLS
89
90 #endif /* SUPPORT_CHECK_H */