GDBserver self tests
[deliverable/binutils-gdb.git] / gdb / common / selftest.h
1 /* GDB self-testing.
2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19 #ifndef SELFTEST_H
20 #define SELFTEST_H
21
22 /* A test is just a function that does some checks and throws an
23 exception if something has gone wrong. */
24
25 typedef void self_test_function (void);
26
27 namespace selftests
28 {
29
30 /* Register a new self-test. */
31
32 extern void register_test (self_test_function *function);
33
34 /* Run all the self tests. This print a message describing the number
35 of test and the number of failures. */
36
37 extern void run_tests (void);
38
39 /* Reset GDB or GDBserver's internal state. */
40 extern void reset ();
41
42 }
43
44 /* Check that VALUE is true, and, if not, throw an exception. */
45
46 #define SELF_CHECK(VALUE) \
47 do { \
48 if (!(VALUE)) \
49 error (_("self-test failed at %s:%d"), __FILE__, __LINE__); \
50 } while (0)
51
52 #endif /* SELFTEST_H */
This page took 0.03078 seconds and 4 git commands to generate.