aboutsummaryrefslogtreecommitdiff
path: root/gcc/selftest-run-tests.cc
blob: e2fc8f84b1b4792f88e5ebf93b8ec56d5a7a7688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Implementation of selftests.
   Copyright (C) 2015-2023 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "selftest.h"
#include "tree.h"
#include "target.h"
#include "langhooks.h"
#include "options.h"
#include "stringpool.h"
#include "attribs.h"
#include "analyzer/analyzer-selftests.h"
#include "text-art/selftests.h"

/* This function needed to be split out from selftest.cc as it references
   tests from the whole source tree, and so is within
   OBJS in Makefile.in, whereas selftest.o is within OBJS-libcommon.
   This allows us to embed tests within files in OBJS-libcommon without
   introducing a dependency on objects within OBJS.  */

#if CHECKING_P

/* Run all tests, aborting if any fail.  */

void
selftest::run_tests ()
{
  /* Makefile.in has -fself-test=$(srcdir)/testsuite/selftests, so that
     flag_self_test contains the path to the selftest subdirectory of the
     source tree (without a trailing slash).  Copy it up to
     path_to_selftest_files, to avoid selftest.cc depending on
     option-handling.  */
  path_to_selftest_files = flag_self_test;

  test_runner r ("-fself-test");

  /* Run all the tests, in hand-coded order of (approximate) dependencies:
     run the tests for lowest-level code first.  */

  /* Sanity-check for selftests themselves.  */
  selftest_cc_tests ();

  /* Low-level data structures.  */
  bitmap_cc_tests ();
  sbitmap_cc_tests ();
  dumpfile_cc_tests ();
  et_forest_cc_tests ();
  hash_map_tests_cc_tests ();
  hash_set_tests_cc_tests ();
  vec_cc_tests ();
  pretty_print_cc_tests ();
  wide_int_cc_tests ();
  ggc_tests_cc_tests ();
  sreal_cc_tests ();
  fibonacci_heap_cc_tests ();
  typed_splay_tree_cc_tests ();
  opt_suggestions_cc_tests ();
  opts_cc_tests ();
  json_cc_tests ();
  cgraph_cc_tests ();
  optinfo_emit_json_cc_tests ();
  ordered_hash_map_tests_cc_tests ();
  splay_tree_cc_tests ();

  /* Mid-level data structures.  */
  input_cc_tests ();
  vec_perm_indices_cc_tests ();
  tree_cc_tests ();
  convert_cc_tests ();
  gimple_cc_tests ();
  rtl_tests_cc_tests ();
  read_rtl_function_cc_tests ();
  digraph_cc_tests ();
  tristate_cc_tests ();
  ipa_modref_tree_cc_tests ();

  /* Higher-level tests, or for components that other selftests don't
     rely on.  */
  diagnostic_show_locus_cc_tests ();
  diagnostic_format_json_cc_tests ();
  edit_context_cc_tests ();
  fold_const_cc_tests ();
  spellcheck_cc_tests ();
  spellcheck_tree_cc_tests ();
  tree_cfg_cc_tests ();
  tree_diagnostic_path_cc_tests ();
  attribs_cc_tests ();

  /* This one relies on most of the above.  */
  function_tests_cc_tests ();

  /* Run any target-specific selftests.  */
  if (targetm.run_target_selftests)
    targetm.run_target_selftests ();

  store_merging_cc_tests ();
  predict_cc_tests ();
  simplify_rtx_cc_tests ();
  dbgcnt_cc_tests ();

  /* Run any lang-specific selftests.  */
  lang_hooks.run_lang_selftests ();

  text_art_tests ();

  /* Run the analyzer selftests (if enabled).  */
  ana::selftest::run_analyzer_selftests ();

  /* Force a GC at the end of the selftests, to shake out GC-related
     issues.  For example, if any GC-managed items have buggy (or missing)
     finalizers, this last collection will ensure that things that were
     failed to be finalized can be detected by valgrind.  */
  ggc_collect (GGC_COLLECT_FORCE);

  /* Finished running tests; the test_runner dtor will print a summary.  */
}

#endif /* #if CHECKING_P */