1 |
149 |
jeremybenn |
# Copyright (C) 2002, 2003, 2004, 2007 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 |
|
|
# .
|
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 |
|
|
global compat_save_gcc_under_test
|
39 |
|
|
global compat_use_alt
|
40 |
|
|
global compat_same_alt
|
41 |
|
|
global compat_have_dfp
|
42 |
|
|
|
43 |
|
|
# Load procedures from common libraries.
|
44 |
|
|
load_lib standard.exp
|
45 |
|
|
load_lib gcc.exp
|
46 |
|
|
|
47 |
|
|
# Load the language-dependent compabibility support procedures.
|
48 |
|
|
load_lib c-compat.exp
|
49 |
|
|
|
50 |
|
|
# Load the language-independent compabibility support procedures.
|
51 |
|
|
load_lib compat.exp
|
52 |
|
|
|
53 |
|
|
gcc_init
|
54 |
|
|
|
55 |
|
|
# Save variables for the C compiler under test, which each test will
|
56 |
|
|
# change a couple of times. This must be done after calling gcc-init.
|
57 |
|
|
set compat_save_gcc_under_test $GCC_UNDER_TEST
|
58 |
|
|
|
59 |
|
|
# Define an identifier for use with this suite to avoid name conflicts
|
60 |
|
|
# with other compat tests running at the same time.
|
61 |
|
|
set sid "c_compat"
|
62 |
|
|
|
63 |
|
|
# Find out whether there is an alternate compiler to test. If the
|
64 |
|
|
# variable is defined but is set to "same", that means we use the same
|
65 |
|
|
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
|
66 |
|
|
# are different.
|
67 |
|
|
set compat_use_alt 0
|
68 |
|
|
set compat_same_alt 0
|
69 |
|
|
|
70 |
|
|
if [info exists ALT_CC_UNDER_TEST] then {
|
71 |
|
|
set compat_use_alt 1
|
72 |
|
|
if [string match "same" $ALT_CC_UNDER_TEST] then {
|
73 |
|
|
set compat_same_alt 1
|
74 |
|
|
}
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
compat_setup_dfp
|
78 |
|
|
|
79 |
|
|
if { $compat_have_dfp == 0 } {
|
80 |
|
|
set skip_dfp "-DSKIP_DECIMAL_FLOAT"
|
81 |
|
|
} else {
|
82 |
|
|
set skip_dfp ""
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
set tstobjdir "$tmpdir/gcc.dg-struct-layout-1"
|
86 |
|
|
set generator "$tmpdir/gcc.dg-struct-layout-1_generate"
|
87 |
|
|
|
88 |
|
|
set generator_src "$srcdir/$subdir/struct-layout-1_generate.c"
|
89 |
|
|
set generator_src "$generator_src $srcdir/$subdir/generate-random.c"
|
90 |
|
|
set generator_src "$generator_src $srcdir/$subdir/generate-random_r.c"
|
91 |
|
|
set generator_cmd "-o $generator $skip_dfp $generator_src"
|
92 |
|
|
|
93 |
|
|
set status [remote_exec host "$HOSTCC $HOSTCFLAGS $generator_cmd"]
|
94 |
|
|
set status [lindex $status 0]
|
95 |
|
|
if { $status == 0 } then {
|
96 |
|
|
file delete -force $tstobjdir
|
97 |
|
|
file mkdir $tstobjdir
|
98 |
|
|
set generator_args "-s $srcdir/$subdir -d $tstobjdir"
|
99 |
|
|
if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
|
100 |
|
|
set generator_args "$generator_args -n 15000"
|
101 |
|
|
}
|
102 |
|
|
if [check_effective_target_short_enums] then {
|
103 |
|
|
set generator_args "-e $generator_args"
|
104 |
|
|
}
|
105 |
|
|
set status [remote_exec host "$generator $generator_args"]
|
106 |
|
|
set status [lindex $status 0]
|
107 |
|
|
if { $status == 0 } then {
|
108 |
|
|
foreach src [lsort [find $tstobjdir *_main.c]] {
|
109 |
|
|
# If we're only testing specific files and this isn't one
|
110 |
|
|
# of them, skip it.
|
111 |
|
|
if ![runtest_file_p $runtests $src] then {
|
112 |
|
|
continue
|
113 |
|
|
}
|
114 |
|
|
|
115 |
|
|
compat-execute $src $sid $compat_use_alt
|
116 |
|
|
}
|
117 |
|
|
} else {
|
118 |
|
|
warning "Could not execute gcc.dg/compat/struct-layout-1 generator"
|
119 |
|
|
}
|
120 |
|
|
} else {
|
121 |
|
|
warning "Could not compile gcc.dg/compat/struct-layout-1 generator"
|
122 |
|
|
}
|
123 |
|
|
|
124 |
|
|
# Restore the original compiler under test.
|
125 |
|
|
compat-use-tst-compiler
|