1*38fd1498Szrj /* Implementation of selftests.
2*38fd1498Szrj Copyright (C) 2015-2018 Free Software Foundation, Inc.
3*38fd1498Szrj
4*38fd1498Szrj This file is part of GCC.
5*38fd1498Szrj
6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under
7*38fd1498Szrj the terms of the GNU General Public License as published by the Free
8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later
9*38fd1498Szrj version.
10*38fd1498Szrj
11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14*38fd1498Szrj for more details.
15*38fd1498Szrj
16*38fd1498Szrj You should have received a copy of the GNU General Public License
17*38fd1498Szrj along with GCC; see the file COPYING3. If not see
18*38fd1498Szrj <http://www.gnu.org/licenses/>. */
19*38fd1498Szrj
20*38fd1498Szrj #include "config.h"
21*38fd1498Szrj #include "system.h"
22*38fd1498Szrj #include "coretypes.h"
23*38fd1498Szrj #include "selftest.h"
24*38fd1498Szrj #include "tree.h"
25*38fd1498Szrj #include "target.h"
26*38fd1498Szrj #include "langhooks.h"
27*38fd1498Szrj #include "options.h"
28*38fd1498Szrj #include "stringpool.h"
29*38fd1498Szrj #include "attribs.h"
30*38fd1498Szrj
31*38fd1498Szrj /* This function needed to be split out from selftest.c as it references
32*38fd1498Szrj tests from the whole source tree, and so is within
33*38fd1498Szrj OBJS in Makefile.in, whereas selftest.o is within OBJS-libcommon.
34*38fd1498Szrj This allows us to embed tests within files in OBJS-libcommon without
35*38fd1498Szrj introducing a dependency on objects within OBJS. */
36*38fd1498Szrj
37*38fd1498Szrj #if CHECKING_P
38*38fd1498Szrj
39*38fd1498Szrj /* Run all tests, aborting if any fail. */
40*38fd1498Szrj
41*38fd1498Szrj void
run_tests()42*38fd1498Szrj selftest::run_tests ()
43*38fd1498Szrj {
44*38fd1498Szrj /* Makefile.in has -fself-test=$(srcdir)/testsuite/selftests, so that
45*38fd1498Szrj flag_self_test contains the path to the selftest subdirectory of the
46*38fd1498Szrj source tree (without a trailing slash). Copy it up to
47*38fd1498Szrj path_to_selftest_files, to avoid selftest.c depending on
48*38fd1498Szrj option-handling. */
49*38fd1498Szrj path_to_selftest_files = flag_self_test;
50*38fd1498Szrj
51*38fd1498Szrj test_runner r ("-fself-test");
52*38fd1498Szrj
53*38fd1498Szrj /* Run all the tests, in hand-coded order of (approximate) dependencies:
54*38fd1498Szrj run the tests for lowest-level code first. */
55*38fd1498Szrj
56*38fd1498Szrj /* Sanity-check for selftests themselves. */
57*38fd1498Szrj selftest_c_tests ();
58*38fd1498Szrj
59*38fd1498Szrj /* Low-level data structures. */
60*38fd1498Szrj bitmap_c_tests ();
61*38fd1498Szrj sbitmap_c_tests ();
62*38fd1498Szrj et_forest_c_tests ();
63*38fd1498Szrj hash_map_tests_c_tests ();
64*38fd1498Szrj hash_set_tests_c_tests ();
65*38fd1498Szrj vec_c_tests ();
66*38fd1498Szrj pretty_print_c_tests ();
67*38fd1498Szrj wide_int_cc_tests ();
68*38fd1498Szrj ggc_tests_c_tests ();
69*38fd1498Szrj sreal_c_tests ();
70*38fd1498Szrj fibonacci_heap_c_tests ();
71*38fd1498Szrj typed_splay_tree_c_tests ();
72*38fd1498Szrj unique_ptr_tests_cc_tests ();
73*38fd1498Szrj
74*38fd1498Szrj /* Mid-level data structures. */
75*38fd1498Szrj input_c_tests ();
76*38fd1498Szrj vec_perm_indices_c_tests ();
77*38fd1498Szrj tree_c_tests ();
78*38fd1498Szrj gimple_c_tests ();
79*38fd1498Szrj rtl_tests_c_tests ();
80*38fd1498Szrj read_rtl_function_c_tests ();
81*38fd1498Szrj
82*38fd1498Szrj /* Higher-level tests, or for components that other selftests don't
83*38fd1498Szrj rely on. */
84*38fd1498Szrj diagnostic_show_locus_c_tests ();
85*38fd1498Szrj diagnostic_c_tests ();
86*38fd1498Szrj edit_context_c_tests ();
87*38fd1498Szrj fold_const_c_tests ();
88*38fd1498Szrj spellcheck_c_tests ();
89*38fd1498Szrj spellcheck_tree_c_tests ();
90*38fd1498Szrj tree_cfg_c_tests ();
91*38fd1498Szrj attribute_c_tests ();
92*38fd1498Szrj
93*38fd1498Szrj /* This one relies on most of the above. */
94*38fd1498Szrj function_tests_c_tests ();
95*38fd1498Szrj
96*38fd1498Szrj /* Run any target-specific selftests. */
97*38fd1498Szrj if (targetm.run_target_selftests)
98*38fd1498Szrj targetm.run_target_selftests ();
99*38fd1498Szrj
100*38fd1498Szrj store_merging_c_tests ();
101*38fd1498Szrj predict_c_tests ();
102*38fd1498Szrj simplify_rtx_c_tests ();
103*38fd1498Szrj
104*38fd1498Szrj /* Run any lang-specific selftests. */
105*38fd1498Szrj lang_hooks.run_lang_selftests ();
106*38fd1498Szrj
107*38fd1498Szrj /* Force a GC at the end of the selftests, to shake out GC-related
108*38fd1498Szrj issues. For example, if any GC-managed items have buggy (or missing)
109*38fd1498Szrj finalizers, this last collection will ensure that things that were
110*38fd1498Szrj failed to be finalized can be detected by valgrind. */
111*38fd1498Szrj forcibly_ggc_collect ();
112*38fd1498Szrj
113*38fd1498Szrj /* Finished running tests; the test_runner dtor will print a summary. */
114*38fd1498Szrj }
115*38fd1498Szrj
116*38fd1498Szrj #endif /* #if CHECKING_P */
117