summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/plugin/plugin.exp
blob: 81dee2248fe332b46b96b16247d6f9d5626ed5f9 (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
#   Copyright (C) 2009-2017 Free Software Foundation, Inc.

# This program 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 of the License, or
# (at your option) any later version.
# 
# This program 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/>.

# Test the functionality of the GCC plugin support

load_lib target-supports.exp
load_lib gcc-dg.exp

global TESTING_IN_BUILD_TREE
global ENABLE_PLUGIN

# The plugin testcases currently only work when the build tree is available.
# Also check whether the host supports plugins.
if { ![info exists TESTING_IN_BUILD_TREE] || ![info exists ENABLE_PLUGIN] } {
    return
}

# If a testcase doesn't have special options, use these.
global DEFAULT_CFLAGS
if ![info exists DEFAULT_CFLAGS] then {
    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
}

# The procedures in plugin-support.exp need these parameters.
set default_flags $DEFAULT_CFLAGS

if $tracelevel then {
    strace $tracelevel
}

# Load support procs.
load_lib plugin-support.exp

# These tests don't run runtest_file_p consistently if it
# doesn't return the same values, so disable parallelization
# of this *.exp file.  The first parallel runtest to reach
# this will run all the tests serially.
if ![gcc_parallel_test_run_p plugin] {
    return
}
gcc_parallel_test_enable 0

# Specify the plugin source file and the associated test files in a list.
# plugin_test_list={ {plugin1 test1 test2 ...} {plugin2 test1 ...} ... }
set plugin_test_list [list \
    { selfassign.c self-assign-test-1.c self-assign-test-2.c } \
    { ggcplug.c ggcplug-test-1.c } \
    { one_time_plugin.c one_time-test-1.c } \
    { start_unit_plugin.c start_unit-test-1.c } \
    { finish_unit_plugin.c finish_unit-test-1.c } \
    { wide-int_plugin.c wide-int-test-1.c } \
    { poly-int-01_plugin.c poly-int-test-1.c } \
    { poly-int-02_plugin.c poly-int-test-1.c } \
    { poly-int-03_plugin.c poly-int-test-1.c } \
    { poly-int-04_plugin.c poly-int-test-1.c } \
    { poly-int-05_plugin.c poly-int-test-1.c } \
    { poly-int-06_plugin.c poly-int-test-1.c } \
    { poly-int-07_plugin.c poly-int-test-1.c } \
    { diagnostic_plugin_test_show_locus.c \
	  diagnostic-test-show-locus-bw.c \
	  diagnostic-test-show-locus-color.c \
	  diagnostic-test-show-locus-parseable-fixits.c \
	  diagnostic-test-show-locus-generate-patch.c } \
    { diagnostic_plugin_test_tree_expression_range.c \
	  diagnostic-test-expressions-1.c } \
    { diagnostic_plugin_show_trees.c \
	  diagnostic-test-show-trees-1.c } \
    { diagnostic_plugin_test_string_literals.c \
	  diagnostic-test-string-literals-1.c \
	  diagnostic-test-string-literals-2.c \
	  diagnostic-test-string-literals-3.c \
	  diagnostic-test-string-literals-4.c } \
    { diagnostic_plugin_test_inlining.c \
	  diagnostic-test-inlining-1.c \
	  diagnostic-test-inlining-2.c \
	  diagnostic-test-inlining-3.c \
	  diagnostic-test-inlining-4.c } \
    { location_overflow_plugin.c \
	  location-overflow-test-1.c \
	  location-overflow-test-2.c } \
    { must_tail_call_plugin.c \
	  must-tail-call-1.c \
	  must-tail-call-2.c } \
    { expensive_selftests_plugin.c \
	  expensive-selftests-1.c } \
]

foreach plugin_test $plugin_test_list {
    # Replace each source file with its full-path name
    for {set i 0} {$i < [llength $plugin_test]} {incr i} {
	set basename [lindex $plugin_test $i]
	set plugin_test [lreplace $plugin_test $i $i $srcdir/$subdir/$basename]
    }
    set plugin_src [lindex $plugin_test 0]
    # If we're only testing specific files and this isn't one of them, skip it.
    if ![runtest_file_p $runtests $plugin_src] then {
        continue
    }
    # Skip tail call tests on targets that do not have sibcall_epilogue.
    if {[regexp ".*must_tail_call_plugin.c" $plugin_src]
	&& [istarget arm*-*-*]
	&& [check_effective_target_arm_thumb1]} then {
	continue
    }
    set plugin_input_tests [lreplace $plugin_test 0 0]
    plugin-test-execute $plugin_src $plugin_input_tests
}

# run the plugindir tests

# Initialize `dg'.
dg-init

# Main loop.
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/plugindir*.\[cSi\]]] \
	"" $DEFAULT_CFLAGS

# All done.
dg-finish

gcc_parallel_test_enable 1