xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/selftest-run-tests.c (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
13ad841b2Smrg /* Implementation of selftests.
2*4c3eb207Smrg    Copyright (C) 2015-2020 Free Software Foundation, Inc.
33ad841b2Smrg 
43ad841b2Smrg This file is part of GCC.
53ad841b2Smrg 
63ad841b2Smrg GCC is free software; you can redistribute it and/or modify it under
73ad841b2Smrg the terms of the GNU General Public License as published by the Free
83ad841b2Smrg Software Foundation; either version 3, or (at your option) any later
93ad841b2Smrg version.
103ad841b2Smrg 
113ad841b2Smrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
123ad841b2Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
133ad841b2Smrg FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
143ad841b2Smrg for more details.
153ad841b2Smrg 
163ad841b2Smrg You should have received a copy of the GNU General Public License
173ad841b2Smrg along with GCC; see the file COPYING3.  If not see
183ad841b2Smrg <http://www.gnu.org/licenses/>.  */
193ad841b2Smrg 
203ad841b2Smrg #include "config.h"
213ad841b2Smrg #include "system.h"
223ad841b2Smrg #include "coretypes.h"
233ad841b2Smrg #include "selftest.h"
243ad841b2Smrg #include "tree.h"
253ad841b2Smrg #include "target.h"
263ad841b2Smrg #include "langhooks.h"
273ad841b2Smrg #include "options.h"
28cef8759bSmrg #include "stringpool.h"
29cef8759bSmrg #include "attribs.h"
30*4c3eb207Smrg #include "analyzer/analyzer-selftests.h"
313ad841b2Smrg 
323ad841b2Smrg /* This function needed to be split out from selftest.c as it references
333ad841b2Smrg    tests from the whole source tree, and so is within
343ad841b2Smrg    OBJS in Makefile.in, whereas selftest.o is within OBJS-libcommon.
353ad841b2Smrg    This allows us to embed tests within files in OBJS-libcommon without
363ad841b2Smrg    introducing a dependency on objects within OBJS.  */
373ad841b2Smrg 
383ad841b2Smrg #if CHECKING_P
393ad841b2Smrg 
403ad841b2Smrg /* Run all tests, aborting if any fail.  */
413ad841b2Smrg 
423ad841b2Smrg void
run_tests()433ad841b2Smrg selftest::run_tests ()
443ad841b2Smrg {
453ad841b2Smrg   /* Makefile.in has -fself-test=$(srcdir)/testsuite/selftests, so that
463ad841b2Smrg      flag_self_test contains the path to the selftest subdirectory of the
473ad841b2Smrg      source tree (without a trailing slash).  Copy it up to
483ad841b2Smrg      path_to_selftest_files, to avoid selftest.c depending on
493ad841b2Smrg      option-handling.  */
503ad841b2Smrg   path_to_selftest_files = flag_self_test;
513ad841b2Smrg 
52cef8759bSmrg   test_runner r ("-fself-test");
533ad841b2Smrg 
543ad841b2Smrg   /* Run all the tests, in hand-coded order of (approximate) dependencies:
553ad841b2Smrg      run the tests for lowest-level code first.  */
563ad841b2Smrg 
573ad841b2Smrg   /* Sanity-check for selftests themselves.  */
583ad841b2Smrg   selftest_c_tests ();
593ad841b2Smrg 
603ad841b2Smrg   /* Low-level data structures.  */
613ad841b2Smrg   bitmap_c_tests ();
62cef8759bSmrg   sbitmap_c_tests ();
63627f7eb2Smrg   dumpfile_c_tests ();
643ad841b2Smrg   et_forest_c_tests ();
653ad841b2Smrg   hash_map_tests_c_tests ();
663ad841b2Smrg   hash_set_tests_c_tests ();
673ad841b2Smrg   vec_c_tests ();
683ad841b2Smrg   pretty_print_c_tests ();
693ad841b2Smrg   wide_int_cc_tests ();
703ad841b2Smrg   ggc_tests_c_tests ();
713ad841b2Smrg   sreal_c_tests ();
723ad841b2Smrg   fibonacci_heap_c_tests ();
733ad841b2Smrg   typed_splay_tree_c_tests ();
74cef8759bSmrg   unique_ptr_tests_cc_tests ();
75627f7eb2Smrg   opt_proposer_c_tests ();
76*4c3eb207Smrg   opts_c_tests ();
77627f7eb2Smrg   json_cc_tests ();
78627f7eb2Smrg   cgraph_c_tests ();
79627f7eb2Smrg   optinfo_emit_json_cc_tests ();
80627f7eb2Smrg   opt_problem_cc_tests ();
81*4c3eb207Smrg   ordered_hash_map_tests_cc_tests ();
823ad841b2Smrg 
833ad841b2Smrg   /* Mid-level data structures.  */
843ad841b2Smrg   input_c_tests ();
85cef8759bSmrg   vec_perm_indices_c_tests ();
863ad841b2Smrg   tree_c_tests ();
87627f7eb2Smrg   convert_c_tests ();
883ad841b2Smrg   gimple_c_tests ();
893ad841b2Smrg   rtl_tests_c_tests ();
903ad841b2Smrg   read_rtl_function_c_tests ();
91*4c3eb207Smrg   digraph_cc_tests ();
92*4c3eb207Smrg   tristate_cc_tests ();
933ad841b2Smrg 
943ad841b2Smrg   /* Higher-level tests, or for components that other selftests don't
953ad841b2Smrg      rely on.  */
963ad841b2Smrg   diagnostic_show_locus_c_tests ();
973ad841b2Smrg   diagnostic_c_tests ();
98*4c3eb207Smrg   diagnostic_format_json_cc_tests ();
993ad841b2Smrg   edit_context_c_tests ();
1003ad841b2Smrg   fold_const_c_tests ();
1013ad841b2Smrg   spellcheck_c_tests ();
1023ad841b2Smrg   spellcheck_tree_c_tests ();
1033ad841b2Smrg   tree_cfg_c_tests ();
104*4c3eb207Smrg   tree_diagnostic_path_cc_tests ();
105cef8759bSmrg   attribute_c_tests ();
1063ad841b2Smrg 
1073ad841b2Smrg   /* This one relies on most of the above.  */
1083ad841b2Smrg   function_tests_c_tests ();
1093ad841b2Smrg 
1103ad841b2Smrg   /* Run any target-specific selftests.  */
1113ad841b2Smrg   if (targetm.run_target_selftests)
1123ad841b2Smrg     targetm.run_target_selftests ();
1133ad841b2Smrg 
1143ad841b2Smrg   store_merging_c_tests ();
115cef8759bSmrg   predict_c_tests ();
116cef8759bSmrg   simplify_rtx_c_tests ();
117*4c3eb207Smrg   dbgcnt_c_tests ();
1183ad841b2Smrg 
1193ad841b2Smrg   /* Run any lang-specific selftests.  */
1203ad841b2Smrg   lang_hooks.run_lang_selftests ();
1213ad841b2Smrg 
122*4c3eb207Smrg   /* Run the analyzer selftests (if enabled).  */
123*4c3eb207Smrg   ana::selftest::run_analyzer_selftests ();
124*4c3eb207Smrg 
1253ad841b2Smrg   /* Force a GC at the end of the selftests, to shake out GC-related
1263ad841b2Smrg      issues.  For example, if any GC-managed items have buggy (or missing)
1273ad841b2Smrg      finalizers, this last collection will ensure that things that were
1283ad841b2Smrg      failed to be finalized can be detected by valgrind.  */
1293ad841b2Smrg   forcibly_ggc_collect ();
1303ad841b2Smrg 
131cef8759bSmrg   /* Finished running tests; the test_runner dtor will print a summary.  */
1323ad841b2Smrg }
1333ad841b2Smrg 
1343ad841b2Smrg #endif /* #if CHECKING_P */
135