1 |
12 |
jlechner |
# Copyright (C) 2002, 2003, 2004 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 2 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 this program; if not, write to the Free Software
|
15 |
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
16 |
|
|
#
|
17 |
|
|
# This file was written by Jakub Jelinek,
|
18 |
|
|
# Based on compat.exp writte by Janis Johnson,
|
19 |
|
|
|
20 |
|
|
|
21 |
|
|
# Test interoperability of two compilers that follow the same ABI.
|
22 |
|
|
#
|
23 |
|
|
# Break simple tests into two pieces and see that they work when linked
|
24 |
|
|
# together. If an alternate compiler is specified then the two main
|
25 |
|
|
# pieces of each test are compiled with different compilers. The
|
26 |
|
|
# alternate compiler must be installed, and is specified by defining
|
27 |
|
|
# ALT_CC_UNDER_TEST in the environment.
|
28 |
|
|
#
|
29 |
|
|
# struct-layout-1 are generated structure layout interoperability tests,
|
30 |
|
|
# so a generator first needs to be compiled on host, run there and the
|
31 |
|
|
# generated tests then compiled on build and executed on target.
|
32 |
|
|
|
33 |
|
|
if $tracelevel then {
|
34 |
|
|
strace $tracelevel
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
global GCC_UNDER_TEST
|
38 |
|
|
|
39 |
|
|
# Load procedures from common libraries.
|
40 |
|
|
load_lib standard.exp
|
41 |
|
|
load_lib gcc.exp
|
42 |
|
|
|
43 |
|
|
#
|
44 |
|
|
# compat-use-alt-compiler -- make the alternate compiler the default
|
45 |
|
|
#
|
46 |
|
|
proc compat-use-alt-compiler { } {
|
47 |
|
|
global GCC_UNDER_TEST ALT_CC_UNDER_TEST
|
48 |
|
|
global same_alt
|
49 |
|
|
|
50 |
|
|
# We don't need to do this if the alternate compiler is actually
|
51 |
|
|
# the same as the compiler under test.
|
52 |
|
|
if { $same_alt == 0 } then {
|
53 |
|
|
set GCC_UNDER_TEST $ALT_CC_UNDER_TEST
|
54 |
|
|
}
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
#
|
58 |
|
|
# compat-use-tst-compiler -- make compiler under test the default
|
59 |
|
|
#
|
60 |
|
|
proc compat-use-tst-compiler { } {
|
61 |
|
|
global GCC_UNDER_TEST save_gcc_under_test
|
62 |
|
|
global same_alt
|
63 |
|
|
|
64 |
|
|
# We don't need to do this if the alternate compiler is actually
|
65 |
|
|
# the same as the compiler under test.
|
66 |
|
|
|
67 |
|
|
if { $same_alt == 0 } then {
|
68 |
|
|
set GCC_UNDER_TEST $save_gcc_under_test
|
69 |
|
|
}
|
70 |
|
|
}
|
71 |
|
|
|
72 |
|
|
# Load the language-independent compabibility support procedures.
|
73 |
|
|
# This must be done after the compat-use-*-compiler definitions.
|
74 |
|
|
load_lib compat.exp
|
75 |
|
|
|
76 |
|
|
gcc_init
|
77 |
|
|
|
78 |
|
|
# Save variables for the C compiler under test, which each test will
|
79 |
|
|
# change a couple of times. This must be done after calling gcc-init.
|
80 |
|
|
set save_gcc_under_test $GCC_UNDER_TEST
|
81 |
|
|
|
82 |
|
|
# Define an identifier for use with this suite to avoid name conflicts
|
83 |
|
|
# with other compat tests running at the same time.
|
84 |
|
|
set sid "c_compat"
|
85 |
|
|
|
86 |
|
|
# Find out whether there is an alternate compiler to test. If the
|
87 |
|
|
# variable is defined but is set to "same", that means we use the same
|
88 |
|
|
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
|
89 |
|
|
# are different.
|
90 |
|
|
set use_alt 0
|
91 |
|
|
set same_alt 0
|
92 |
|
|
if [info exists ALT_CC_UNDER_TEST] then {
|
93 |
|
|
set use_alt 1
|
94 |
|
|
if [string match "same" $ALT_CC_UNDER_TEST] then {
|
95 |
|
|
set same_alt 1
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
|
|
|
99 |
|
|
set tstobjdir "$tmpdir/gcc.dg-struct-layout-1"
|
100 |
|
|
set generator "$tmpdir/gcc.dg-struct-layout-1_generate"
|
101 |
|
|
|
102 |
|
|
set generator_src "$srcdir/$subdir/struct-layout-1_generate.c"
|
103 |
|
|
set generator_src "$generator_src $srcdir/$subdir/generate-random.c"
|
104 |
|
|
set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c"
|
105 |
|
|
set generator_cmd "-o $generator $generator_src"
|
106 |
|
|
|
107 |
|
|
set status [remote_exec host "$HOSTCC $HOSTCFLAGS $generator_cmd"]
|
108 |
|
|
set status [lindex $status 0]
|
109 |
|
|
if { $status == 0 } then {
|
110 |
|
|
file delete -force $tstobjdir
|
111 |
|
|
file mkdir $tstobjdir
|
112 |
|
|
set generator_args "-s $srcdir/$subdir -d $tstobjdir"
|
113 |
|
|
if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
|
114 |
|
|
set generator_args "$generator_args -n 15000"
|
115 |
|
|
}
|
116 |
|
|
if [check_effective_target_short_enums] then {
|
117 |
|
|
set generator_args "-e $generator_args"
|
118 |
|
|
}
|
119 |
|
|
set status [remote_exec host "$generator $generator_args"]
|
120 |
|
|
set status [lindex $status 0]
|
121 |
|
|
if { $status == 0 } then {
|
122 |
|
|
foreach src [lsort [find $tstobjdir *_main.c]] {
|
123 |
|
|
# If we're only testing specific files and this isn't one
|
124 |
|
|
# of them, skip it.
|
125 |
|
|
if ![runtest_file_p $runtests $src] then {
|
126 |
|
|
continue
|
127 |
|
|
}
|
128 |
|
|
|
129 |
|
|
compat-execute $src $sid $use_alt
|
130 |
|
|
}
|
131 |
|
|
} else {
|
132 |
|
|
warning "Could not execute gcc.dg/compat/struct-layout-1 generator"
|
133 |
|
|
}
|
134 |
|
|
} else {
|
135 |
|
|
warning "Could not compile gcc.dg/compat/struct-layout-1 generator"
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
# Restore the original compiler under test.
|
139 |
|
|
compat-use-tst-compiler
|