OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [compat/] [struct-layout-1.exp] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
# Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008
2
# Free Software Foundation, Inc.
3
 
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with GCC; see the file COPYING3.  If not see
16
# .
17
#
18
# This file was written by Jakub Jelinek, 
19
# Based on compat.exp writte by Janis Johnson, 
20
 
21
 
22
# Test interoperability of two compilers that follow the same ABI.
23
#
24
# Break simple tests into two pieces and see that they work when linked
25
# together.  If an alternate compiler is specified then the two main
26
# pieces of each test are compiled with different compilers.  The
27
# alternate compiler must be installed, and is specified by defining
28
# ALT_CXX_UNDER_TEST in the environment.
29
#
30
# struct-layout-1 are generated structure layout interoperability tests,
31
# so a generator first needs to be compiled on host, run there and the
32
# generated tests then compiled on build and executed on target.
33
 
34
if $tracelevel then {
35
    strace $tracelevel
36
}
37
 
38
global GXX_UNDER_TEST
39
global ld_library_path
40
 
41
# Load procedures from common libraries.
42
load_lib standard.exp
43
load_lib g++.exp
44
load_lib target-libpath.exp
45
 
46
#
47
# compat-use-alt-compiler -- make the alternate compiler the default
48
#
49
proc compat-use-alt-compiler { } {
50
    global GXX_UNDER_TEST ALT_CXX_UNDER_TEST
51
    global CXXFLAGS
52
    global ALWAYS_CXXFLAGS
53
    global ld_library_path alt_ld_library_path
54
    global same_alt
55
 
56
    # We don't need to do this if the alternate compiler is actually
57
    # the same as the compiler under test.
58
    if { $same_alt == 0 } then {
59
        set GXX_UNDER_TEST $ALT_CXX_UNDER_TEST
60
        set CXXFLAGS ""
61
        set ALWAYS_CXXFLAGS ""
62
        set ld_library_path $alt_ld_library_path
63
        set_ld_library_path_env_vars
64
    }
65
}
66
 
67
#
68
# compat-use-tst-compiler -- make compiler under test the default
69
#
70
proc compat-use-tst-compiler { } {
71
    global GXX_UNDER_TEST save_gxx_under_test
72
    global CXXFLAGS save_cxxflags
73
    global ALWAYS_CXXFLAGS save_always_cxxflags
74
    global ld_library_path save_ld_library_path
75
    global same_alt
76
 
77
    # We don't need to do this if the alternate compiler is actually
78
    # the same as the compiler under test.
79
 
80
    if { $same_alt == 0 } then {
81
        set GXX_UNDER_TEST $save_gxx_under_test
82
        set CXXFLAGS $save_cxxflags
83
        set ALWAYS_CXXFLAGS $save_always_cxxflags
84
        set ld_library_path $save_ld_library_path
85
        set_ld_library_path_env_vars
86
    }
87
}
88
 
89
# Load the language-independent compabibility support procedures.
90
# This must be done after the compat-use-*-compiler definitions.
91
load_lib compat.exp
92
 
93
g++_init
94
 
95
# Save variables for the C++ compiler under test, which each test will
96
# change a couple of times.  This must be done after calling g++-init.
97
set save_gxx_under_test $GXX_UNDER_TEST
98
set save_cxxflags $CXXFLAGS
99
set save_always_cxxflags $ALWAYS_CXXFLAGS
100
set save_ld_library_path $ld_library_path
101
 
102
# Define an identifier for use with this suite to avoid name conflicts
103
# with other compat tests running at the same time.
104
set sid "cp_compat"
105
 
106
# Find out whether there is an alternate compiler to test.  If the
107
# variable is defined but is set to "same", that means we use the same
108
# compiler twice, which is meaningful if the two parts of COMPAT_OPTIONS
109
# are different.
110
set use_alt 0
111
set same_alt 0
112
set alt_ld_library_path "."
113
if [info exists ALT_CXX_UNDER_TEST] then {
114
    set use_alt 1
115
    if [string match "same" $ALT_CXX_UNDER_TEST] then {
116
        set same_alt 1
117
    } else {
118
        if [info exists ALT_LD_LIBRARY_PATH] then {
119
            append alt_ld_library_path ":${ALT_LD_LIBRARY_PATH}"
120
        }
121
    }
122
}
123
 
124
set tstobjdir "$tmpdir/g++.dg-struct-layout-1"
125
set generator "$tmpdir/g++.dg-struct-layout-1_generate.exe"
126
 
127
set generator_src "$srcdir/$subdir/struct-layout-1_generate.c"
128
set generator_src "$generator_src $srcdir/$subdir/../../gcc.dg/compat/generate-random.c"
129
set generator_src "$generator_src $srcdir/$subdir/../../gcc.dg/compat/generate-random_r.c"
130
set generator_cmd "-o $generator $generator_src"
131
 
132
# Temporarily switch to the environment of the host compiler.
133
restore_ld_library_path_env_vars
134
set status [remote_exec build "$HOSTCC $HOSTCFLAGS $generator_cmd"]
135
set status [lindex $status 0]
136
set_ld_library_path_env_vars
137
if { $status == 0 } then {
138
    file delete -force $tstobjdir
139
    file mkdir $tstobjdir
140
    set generator_args "-s $srcdir/$subdir -d $tstobjdir"
141
    if [info exists env(RUN_ALL_COMPAT_TESTS) ] then {
142
        set generator_args "$generator_args -n 15000"
143
    }
144
    if [check_effective_target_short_enums] then {
145
        set generator_args "-e $generator_args"
146
    }
147
    set status [remote_exec host "$generator $generator_args"]
148
    set status [lindex $status 0]
149
    if { $status == 0 } then {
150
        foreach src [lsort [find $tstobjdir *_main.C]] {
151
            # If we're only testing specific files and this isn't one
152
            # of them, skip it.
153
            if ![runtest_file_p $runtests $src] then {
154
                continue
155
            }
156
 
157
            compat-execute $src $sid $use_alt
158
        }
159
    } else {
160
        warning "Could not execute g++.dg/compat/struct-layout-1 generator"
161
    }
162
} else {
163
    warning "Could not compile g++.dg/compat/struct-layout-1 generator"
164
}
165
 
166
# Restore the original compiler under test.
167
compat-use-tst-compiler

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.