]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/selftest.h
Remove some GDB specific stuff from selftest.c
[thirdparty/binutils-gdb.git] / gdb / selftest.h
CommitLineData
dcd1f979 1/* GDB self-testing.
61baf725 2 Copyright (C) 2016-2017 Free Software Foundation, Inc.
dcd1f979
TT
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
25typedef void self_test_function (void);
26
7649770c
YQ
27namespace selftests
28{
29
dcd1f979
TT
30/* Register a new self-test. */
31
7649770c 32extern void register_test (self_test_function *function);
dcd1f979
TT
33
34/* Run all the self tests. This print a message describing the number
35 of test and the number of failures. */
36
7649770c
YQ
37extern void run_tests (void);
38
39}
dcd1f979
TT
40
41/* Check that VALUE is true, and, if not, throw an exception. */
42
43#define SELF_CHECK(VALUE) \
44 do { \
45 if (!(VALUE)) \
46 error (_("self-test failed at %s:%d"), __FILE__, __LINE__); \
47 } while (0)
48
49#endif /* SELFTEST_H */