| 1 |
# Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
# This program is free software; you can redistribute it and/or modify |
| 4 |
# it under the terms of the GNU General Public License as published by |
| 5 |
# the Free Software Foundation; either version 3 of the License, or |
| 6 |
# (at your option) any later version. |
| 7 |
# |
| 8 |
# This program is distributed in the hope that it will be useful, |
| 9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
# GNU General Public License for more details. |
| 12 |
# |
| 13 |
# You should have received a copy of the GNU General Public License |
| 14 |
# along with GCC; see the file COPYING3. If not see |
| 15 |
# <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
# Test the functionality of the GCC plugin support |
| 18 |
|
| 19 |
load_lib target-supports.exp |
| 20 |
load_lib gcc-dg.exp |
| 21 |
|
| 22 |
global TESTING_IN_BUILD_TREE |
| 23 |
global ENABLE_PLUGIN |
| 24 |
|
| 25 |
# The plugin testcases currently only work when the build tree is available. |
| 26 |
# Also check whether the host supports plugins. |
| 27 |
if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } { |
| 28 |
return |
| 29 |
} |
| 30 |
|
| 31 |
# If a testcase doesn't have special options, use these. |
| 32 |
global DEFAULT_CFLAGS |
| 33 |
if ![info exists DEFAULT_CFLAGS] then { |
| 34 |
set DEFAULT_CFLAGS " -ansi -pedantic-errors" |
| 35 |
} |
| 36 |
|
| 37 |
# The procedures in plugin-support.exp need these parameters. |
| 38 |
set default_flags $DEFAULT_CFLAGS |
| 39 |
|
| 40 |
if $tracelevel then { |
| 41 |
strace $tracelevel |
| 42 |
} |
| 43 |
|
| 44 |
# Load support procs. |
| 45 |
load_lib plugin-support.exp |
| 46 |
|
| 47 |
# These tests don't run runtest_file_p consistently if it |
| 48 |
# doesn't return the same values, so disable parallelization |
| 49 |
# of this *.exp file. The first parallel runtest to reach |
| 50 |
# this will run all the tests serially. |
| 51 |
if ![gcc_parallel_test_run_p plugin] { |
| 52 |
return |
| 53 |
} |
| 54 |
gcc_parallel_test_enable 0 |
| 55 |
|
| 56 |
# Specify the plugin source file and the associated test files in a list. |
| 57 |
# plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... } |
| 58 |
set plugin_test_list [list \ |
| 59 |
{ selfassign.cc self-assign-test-1.c self-assign-test-2.c } \ |
| 60 |
{ ggcplug.cc ggcplug-test-1.c } \ |
| 61 |
{ one_time_plugin.cc one_time-test-1.c } \ |
| 62 |
{ start_unit_plugin.cc start_unit-test-1.c } \ |
| 63 |
{ finish_unit_plugin.cc finish_unit-test-1.c } \ |
| 64 |
{ wide-int_plugin.cc wide-int-test-1.c } \ |
| 65 |
{ poly-int-01_plugin.cc poly-int-test-1.c } \ |
| 66 |
{ poly-int-02_plugin.cc poly-int-test-1.c } \ |
| 67 |
{ poly-int-03_plugin.cc poly-int-test-1.c } \ |
| 68 |
{ poly-int-04_plugin.cc poly-int-test-1.c } \ |
| 69 |
{ poly-int-05_plugin.cc poly-int-test-1.c } \ |
| 70 |
{ poly-int-06_plugin.cc poly-int-test-1.c } \ |
| 71 |
{ poly-int-07_plugin.cc poly-int-test-1.c } \ |
| 72 |
{ crash_test_plugin.cc \ |
| 73 |
crash-test-ice-in-header-sarif-2.1.c \ |
| 74 |
crash-test-ice-in-header-sarif-2.2.c \ |
| 75 |
crash-test-ice-sarif.c \ |
| 76 |
crash-test-ice-stderr.c \ |
| 77 |
crash-test-write-through-null-sarif.c \ |
| 78 |
crash-test-write-through-null-stderr.c } \ |
| 79 |
{ diagnostic_plugin_xhtml_format.cc \ |
| 80 |
diagnostic-test-xhtml-1.c } \ |
| 81 |
{ diagnostic_group_plugin.cc \ |
| 82 |
diagnostic-group-test-1.c } \ |
| 83 |
{ diagnostic_plugin_test_show_locus.cc \ |
| 84 |
diagnostic-test-show-locus-bw.c \ |
| 85 |
diagnostic-test-show-locus-color.c \ |
| 86 |
diagnostic-test-show-locus-no-labels.c \ |
| 87 |
diagnostic-test-show-locus-bw-line-numbers.c \ |
| 88 |
diagnostic-test-show-locus-bw-line-numbers-2.c \ |
| 89 |
diagnostic-test-show-locus-color-line-numbers.c \ |
| 90 |
diagnostic-test-show-locus-parseable-fixits.c \ |
| 91 |
diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v1.c \ |
| 92 |
diagnostic-test-show-locus-GCC_EXTRA_DIAGNOSTIC_OUTPUT-fixits-v2.c \ |
| 93 |
diagnostic-test-show-locus-generate-patch.c }\ |
| 94 |
{ diagnostic_plugin_test_tree_expression_range.cc \ |
| 95 |
diagnostic-test-expressions-1.c } \ |
| 96 |
{ diagnostic_plugin_show_trees.cc \ |
| 97 |
diagnostic-test-show-trees-1.c } \ |
| 98 |
{ diagnostic_plugin_test_string_literals.cc \ |
| 99 |
diagnostic-test-string-literals-1.c \ |
| 100 |
diagnostic-test-string-literals-2.c \ |
| 101 |
diagnostic-test-string-literals-3.c \ |
| 102 |
diagnostic-test-string-literals-4.c } \ |
| 103 |
{ diagnostic_plugin_test_inlining.cc \ |
| 104 |
diagnostic-test-inlining-1.c \ |
| 105 |
diagnostic-test-inlining-2.c \ |
| 106 |
diagnostic-test-inlining-3.c \ |
| 107 |
diagnostic-test-inlining-4.c } \ |
| 108 |
{ diagnostic_plugin_test_metadata.cc |
| 109 |
diagnostic-test-metadata.c \ |
| 110 |
diagnostic-test-metadata-sarif.c } \ |
| 111 |
{ diagnostic_plugin_test_nesting.cc \ |
| 112 |
diagnostic-test-nesting-text-plain.c \ |
| 113 |
diagnostic-test-nesting-text-indented.c \ |
| 114 |
diagnostic-test-nesting-text-indented-show-levels.c \ |
| 115 |
diagnostic-test-nesting-text-indented-unicode.c \ |
| 116 |
diagnostic-test-nesting-sarif.c } \ |
| 117 |
{ diagnostic_plugin_test_paths.cc \ |
| 118 |
diagnostic-test-paths-1.c \ |
| 119 |
diagnostic-test-paths-2.c \ |
| 120 |
diagnostic-test-paths-3.c \ |
| 121 |
diagnostic-test-paths-4.c \ |
| 122 |
diagnostic-test-paths-5.c \ |
| 123 |
diagnostic-test-paths-multithreaded-inline-events.c \ |
| 124 |
diagnostic-test-paths-multithreaded-sarif.c \ |
| 125 |
diagnostic-test-paths-multithreaded-separate-events.c \ |
| 126 |
diagnostic-path-format-plain.c \ |
| 127 |
diagnostic-path-format-none.c \ |
| 128 |
diagnostic-path-format-separate-events.c \ |
| 129 |
diagnostic-path-format-inline-events-1.c \ |
| 130 |
diagnostic-path-format-inline-events-2.c \ |
| 131 |
diagnostic-path-format-inline-events-3.c } \ |
| 132 |
{ diagnostic_plugin_test_text_art.cc \ |
| 133 |
diagnostic-test-text-art-none.c \ |
| 134 |
diagnostic-test-text-art-ascii-bw.c \ |
| 135 |
diagnostic-test-text-art-ascii-color.c \ |
| 136 |
diagnostic-test-text-art-unicode-bw.c \ |
| 137 |
diagnostic-test-text-art-unicode-color.c } \ |
| 138 |
{ location_overflow_plugin.cc \ |
| 139 |
location-overflow-test-1.c \ |
| 140 |
location-overflow-test-2.c \ |
| 141 |
location-overflow-test-3.c \ |
| 142 |
location-overflow-test-pr83173.c \ |
| 143 |
location-overflow-test-pr116047.c \ |
| 144 |
location-overflow-test-pr120061.c } \ |
| 145 |
{ must_tail_call_plugin.cc \ |
| 146 |
must-tail-call-1.c \ |
| 147 |
must-tail-call-2.c } \ |
| 148 |
{ expensive_selftests_plugin.cc \ |
| 149 |
expensive-selftests-1.c } \ |
| 150 |
{ dump_plugin.cc \ |
| 151 |
dump-1.c \ |
| 152 |
dump-2.c } \ |
| 153 |
{ analyzer_gil_plugin.cc \ |
| 154 |
gil-1.c } \ |
| 155 |
{ analyzer_known_fns_plugin.cc \ |
| 156 |
known-fns-1.c } \ |
| 157 |
{ analyzer_kernel_plugin.cc \ |
| 158 |
copy_from_user-1.c \ |
| 159 |
infoleak-1.c \ |
| 160 |
infoleak-2.c \ |
| 161 |
infoleak-3.c \ |
| 162 |
infoleak-CVE-2011-1078-1.c \ |
| 163 |
infoleak-CVE-2011-1078-2.c \ |
| 164 |
infoleak-CVE-2017-18549-1.c \ |
| 165 |
infoleak-CVE-2017-18550-1.c \ |
| 166 |
infoleak-antipatterns-1.c \ |
| 167 |
infoleak-fixit-1.c \ |
| 168 |
infoleak-pr112969.c \ |
| 169 |
infoleak-uninit-size-1.c \ |
| 170 |
infoleak-uninit-size-2.c \ |
| 171 |
infoleak-net-ethtool-ioctl.c \ |
| 172 |
infoleak-vfio_iommu_type1.c \ |
| 173 |
taint-CVE-2011-0521-1-fixed.c \ |
| 174 |
taint-CVE-2011-0521-1.c \ |
| 175 |
taint-CVE-2011-0521-2-fixed.c \ |
| 176 |
taint-CVE-2011-0521-2.c \ |
| 177 |
taint-CVE-2011-0521-3-fixed.c \ |
| 178 |
taint-CVE-2011-0521-3.c \ |
| 179 |
taint-CVE-2011-0521-4.c \ |
| 180 |
taint-CVE-2011-0521-5.c \ |
| 181 |
taint-CVE-2011-0521-5-fixed.c \ |
| 182 |
taint-CVE-2011-0521-6.c \ |
| 183 |
taint-antipatterns-1.c \ |
| 184 |
taint-modulus.c \ |
| 185 |
taint-pr112850.c \ |
| 186 |
taint-pr112850-precise.c \ |
| 187 |
taint-pr112850-too-complex.c \ |
| 188 |
taint-pr112850-unsanitized.c \ |
| 189 |
taint-pr112927.c \ |
| 190 |
taint-pr112974.c \ |
| 191 |
taint-pr112975.c \ |
| 192 |
taint-pr112977.c } \ |
| 193 |
{ analyzer_cpython_plugin.cc \ |
| 194 |
cpython-plugin-test-no-Python-h.c \ |
| 195 |
cpython-plugin-test-PyList_Append.c \ |
| 196 |
cpython-plugin-test-PyList_New.c \ |
| 197 |
cpython-plugin-test-PyLong_FromLong.c } \ |
| 198 |
] |
| 199 |
|
| 200 |
foreach plugin_test $plugin_test_list { |
| 201 |
# Replace each source file with its full-path name |
| 202 |
for {set i 0} {$i < [llength $plugin_test]} {incr i} { |
| 203 |
set basename [lindex $plugin_test $i] |
| 204 |
set plugin_test [lreplace $plugin_test $i $i $srcdir/$subdir/$basename] |
| 205 |
} |
| 206 |
set plugin_src [lindex $plugin_test 0] |
| 207 |
# If we're only testing specific files and this isn't one of them, skip it. |
| 208 |
if ![runtest_file_p $runtests $plugin_src] then { |
| 209 |
continue |
| 210 |
} |
| 211 |
# Skip tail call tests on targets that do not have sibcall_epilogue. |
| 212 |
if {[regexp ".*must_tail_call_plugin.c" $plugin_src] |
| 213 |
&& [istarget arm*-*-*] |
| 214 |
&& [check_effective_target_arm_thumb1]} then { |
| 215 |
continue |
| 216 |
} |
| 217 |
set plugin_input_tests [lreplace $plugin_test 0 0] |
| 218 |
plugin-test-execute $plugin_src $plugin_input_tests |
| 219 |
} |
| 220 |
|
| 221 |
# run the plugindir tests |
| 222 |
|
| 223 |
# Initialize `dg'. |
| 224 |
dg-init |
| 225 |
|
| 226 |
# Main loop. |
| 227 |
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/plugindir*.\[cSi\]]] \ |
| 228 |
"" $DEFAULT_CFLAGS |
| 229 |
|
| 230 |
# All done. |
| 231 |
dg-finish |
| 232 |
|
| 233 |
gcc_parallel_test_enable 1 |