Skip to content

Commit af026f9

Browse files
committed
Refactor DejaGNU testsuite
Use more standard layout for DejaGNU testsuite. 3 subdirectories are used for tests: - compile/*: tests are build using default torture options. - xfail_compile/*: tests are expected to fail early in the frontend and are only build once. - execute/*: tests are executed and exit status is checked. The previous .exp files were copied from D tests and were expected to be used in a different way not really applicable for the current Rust tests. Fixes Rust-GCC#281
1 parent 30e3d49 commit af026f9

File tree

174 files changed

+396
-756
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+396
-756
lines changed

gcc/testsuite/lib/rust-dg.exp

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2012-2019 Free Software Foundation, Inc.
1+
# Copyright (C) 1997-2021 Free Software Foundation, Inc.
22

33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -19,30 +19,7 @@ load_lib gcc-dg.exp
1919
# Define rust callbacks for dg.exp.
2020

2121
proc rust-dg-test { prog do_what extra_tool_flags } {
22-
upvar dg-do-what dg-do-what
23-
24-
# Demote link and run tests to compile-only if D runtime is missing.
25-
if ![check_effective_target_d_runtime] {
26-
switch $do_what {
27-
link -
28-
run {
29-
set do_what compile
30-
set dg-do-what compile
31-
}
32-
}
33-
}
34-
35-
# Strip rust.test prefix off test names to avoid pathname failures in
36-
# some tests.
37-
set prog [dg-trim-dirname rust.test $prog]
38-
39-
set result \
40-
[gcc-dg-test-1 rust_target_compile $prog $do_what $extra_tool_flags]
41-
42-
set comp_output [lindex $result 0]
43-
set output_file [lindex $result 1]
44-
45-
return [list $comp_output $output_file]
22+
return [gcc-dg-test-1 rust_target_compile $prog $do_what $extra_tool_flags]
4623
}
4724

4825
proc rust-dg-prune { system text } {
@@ -51,39 +28,6 @@ proc rust-dg-prune { system text } {
5128

5229
# Utility routines.
5330

54-
#
55-
# Modified dg-runtest that can cycle through a list of optimization options
56-
# as c-torture does.
57-
#
58-
59-
proc rust-dg-runtest { testcases flags default-extra-flags } {
60-
global runtests
61-
62-
foreach test $testcases {
63-
# If we're only testing specific files and this isn't one of
64-
# them, skip it.
65-
66-
if ![runtest_file_p $runtests $test] {
67-
continue
68-
}
69-
70-
# Use TORTURE_OPTIONS to cycle through an option list.
71-
if [torture-options-exist] then {
72-
global torture_with_loops
73-
set option_list $torture_with_loops
74-
} else {
75-
set option_list { "" }
76-
}
77-
78-
set nshort [file tail [file dirname $test]]/[file tail $test]
79-
80-
foreach flags_t $option_list {
81-
verbose "Testing $nshort, $flags $flags_t" 1
82-
dg-test $test "$flags $flags_t" ${default-extra-flags}
83-
}
84-
}
85-
}
86-
8731
#
8832
# rust_load -- wrapper around default rust_load to handle tests that
8933
# require program arguments passed to them.
@@ -98,7 +42,6 @@ if { [info procs rust_load] != [list] \
9842
if [info exists RUST_EXECUTE_ARGS] then {
9943
set args [concat "{$RUST_EXECUTE_ARGS}"]
10044
}
101-
#print "Running: $program [lindex $args 0]"
10245
set result [eval [list prev_rust_load $program] $args ]
10346
return $result
10447
}

gcc/testsuite/lib/rust.exp

Lines changed: 19 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2012-2020 Free Software Foundation, Inc.
1+
# Copyright (C) 2012-2021 Free Software Foundation, Inc.
22

33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -30,39 +30,6 @@ load_lib target-libpath.exp
3030
set rust_compile_options ""
3131

3232

33-
#
34-
# rust_version -- extract and print the version number of the compiler
35-
#
36-
37-
proc rust_version { } {
38-
global RUST_UNDER_TEST
39-
40-
rust_init
41-
42-
# ignore any arguments after the command
43-
set compiler [lindex $RUST_UNDER_TEST 0]
44-
45-
# verify that the compiler exists
46-
if { [is_remote host] || [which $compiler] != 0 } then {
47-
set tmp [remote_exec host "$compiler -v"]
48-
set status [lindex $tmp 0]
49-
set output [lindex $tmp 1]
50-
regexp " version \[^\n\r\]*" $output version
51-
if { $status == 0 && [info exists version] } then {
52-
if [is_remote host] {
53-
clone_output "$compiler $version\n"
54-
} else {
55-
clone_output "[which $compiler] $version\n"
56-
}
57-
} else {
58-
clone_output "Couldn't determine version of $output [which $compiler]\n"
59-
}
60-
} else {
61-
# compiler does not exist (this should have already been detected)
62-
warning "$compiler does not exist"
63-
}
64-
}
65-
6633
#
6734
# rust_include_flags -- include flags for the gcc tree structure
6835
#
@@ -118,7 +85,7 @@ proc rust_init { args } {
11885
global libdir
11986
global gluefile wrap_flags
12087
global objdir srcdir
121-
global ALWAYS_DFLAGS
88+
global ALWAYS_RUSTFLAGS
12289
global TOOL_EXECUTABLE TOOL_OPTIONS
12390
global RUST_UNDER_TEST
12491
global TESTING_IN_BUILD_TREE
@@ -148,6 +115,7 @@ proc rust_init { args } {
148115
exit 1
149116
}
150117
}
118+
151119
if ![info exists tmpdir] {
152120
set tmpdir "/tmp"
153121
}
@@ -164,24 +132,24 @@ proc rust_init { args } {
164132
# compilation. They are passed first to allow individual
165133
# tests to override them.
166134
if [info exists TEST_ALWAYS_FLAGS] {
167-
lappend ALWAYS_DFLAGS "additional_flags=$TEST_ALWAYS_FLAGS"
135+
lappend ALWAYS_RUSTFLAGS "additional_flags=$TEST_ALWAYS_FLAGS"
168136
}
169137

170138
if ![is_remote host] {
171139
if [info exists TOOL_OPTIONS] {
172-
lappend ALWAYS_DFLAGS "additional_flags=[rust_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
173-
lappend ALWAYS_DFLAGS "ldflags=[rust_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
140+
lappend ALWAYS_RUSTFLAGS "additional_flags=[rust_include_flags [get_multilibs ${TOOL_OPTIONS}] ]"
141+
lappend ALWAYS_RUSTFLAGS "ldflags=[rust_link_flags [get_multilibs ${TOOL_OPTIONS}] ]"
174142
} else {
175-
lappend ALWAYS_DFLAGS "additional_flags=[rust_include_flags [get_multilibs] ]"
176-
lappend ALWAYS_DFLAGS "ldflags=[rust_link_flags [get_multilibs] ]"
143+
lappend ALWAYS_RUSTFLAGS "additional_flags=[rust_include_flags [get_multilibs] ]"
144+
lappend ALWAYS_RUSTFLAGS "ldflags=[rust_link_flags [get_multilibs] ]"
177145
}
178146
}
179147

180148
if [info exists TOOL_OPTIONS] {
181-
lappend ALWAYS_DFLAGS "additional_flags=$TOOL_OPTIONS"
149+
lappend ALWAYS_RUSTFLAGS "additional_flags=$TOOL_OPTIONS"
182150
}
183151

184-
verbose -log "ALWAYS_DFLAGS set to $ALWAYS_DFLAGS"
152+
verbose -log "ALWAYS_RUSTFLAGS set to $ALWAYS_RUSTFLAGS"
185153

186154
set gcc_warning_prefix "warning:"
187155
set gcc_error_prefix "(fatal )?error:"
@@ -196,7 +164,7 @@ proc rust_init { args } {
196164
proc rust_target_compile { source dest type options } {
197165
global tmpdir
198166
global gluefile wrap_flags
199-
global ALWAYS_DFLAGS
167+
global ALWAYS_RUSTFLAGS
200168
global RUST_UNDER_TEST
201169

202170
if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
@@ -207,7 +175,14 @@ proc rust_target_compile { source dest type options } {
207175
lappend options "timeout=[timeout_value]"
208176
lappend options "compiler=$RUST_UNDER_TEST"
209177

210-
set options [concat "$ALWAYS_DFLAGS" $options]
178+
set options [concat "$ALWAYS_RUSTFLAGS" $options]
211179
set options [dg-additional-files-options $options $source]
180+
181+
## FIXME: until the compiler is made less verbose, we need to prune its output completely.
182+
# Only keep line containing error so that the test will correctly report the error and the test
183+
# can FAIL or XFAIL
184+
global additional_prunes
185+
set additional_prunes "^((?!error).)*$"
186+
212187
return [target_compile $source $dest $type $options]
213188
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (C) 2021 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+
#
18+
# Rust torture test suite.
19+
#
20+
21+
# Load support procs.
22+
load_lib rust-dg.exp
23+
24+
# Initialize `dg'.
25+
dg-init
26+
27+
# Main loop.
28+
set saved-dg-do-what-default ${dg-do-what-default}
29+
30+
set dg-do-what-default "compile"
31+
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.rs]] "" "-w"
32+
set dg-do-what-default ${saved-dg-do-what-default}
33+
34+
# All done.
35+
dg-finish
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() -> i32 {
2+
0
3+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright (C) 2021 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+
#
18+
# Rust torture test suite.
19+
#
20+
21+
# Load support procs.
22+
load_lib rust-dg.exp
23+
24+
# Initialize `dg'.
25+
dg-init
26+
27+
# Main loop.
28+
set saved-dg-do-what-default ${dg-do-what-default}
29+
30+
set dg-do-what-default "run"
31+
gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.rs]] "" "-w"
32+
set dg-do-what-default ${saved-dg-do-what-default}
33+
34+
# All done.
35+
dg-finish
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// { dg-xfail-run-if "" { *-*-* } }
2+
// { dg-excess-errors "Noisy debug print" }
3+
fn main() -> i32 {
4+
1
5+
}

gcc/testsuite/rust.test/fail_compilation/arrays1.rs

Lines changed: 0 additions & 4 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/arrays2.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/bad_type1.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/break1.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/break2.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/continue1.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/func1.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/func2.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/func3.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/generics1.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/generics2.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/generics3.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

gcc/testsuite/rust.test/fail_compilation/generics5.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)