]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/selftest.h
Fix buffer overrun parsing a corrupt tekhex binary.
[thirdparty/binutils-gdb.git] / gdb / 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 /* Register a new self-test. */
28
29 extern void register_self_test (self_test_function *function);
30
31 /* Run all the self tests. This print a message describing the number
32 of test and the number of failures. */
33
34 extern void run_self_tests (void);
35
36 /* Check that VALUE is true, and, if not, throw an exception. */
37
38 #define SELF_CHECK(VALUE) \
39 do { \
40 if (!(VALUE)) \
41 error (_("self-test failed at %s:%d"), __FILE__, __LINE__); \
42 } while (0)
43
44 #endif /* SELFTEST_H */