1 # Copyright
(C
) 2005-2018 Free Software Foundation
, Inc.
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.
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.
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
/>.
17 # Run GCC with the input file also specified as output file. Check that the
18 # compiler prints an error message and does not overwrite the input file.
21 load_lib target
-supports.exp
23 # These tests don
't run runtest_file_p consistently if it
24 # doesn't
return the same
values, so disable parallelization
25 # of this
*.exp file. The first parallel runtest to reach
26 # this will run all the tests serially.
27 if ![gcc_parallel_test_run_p output
] {
31 # I
'm not sure if this is needed here. It was in options.exp.
32 gcc_parallel_test_enable 0
34 proc check_gcc_overwrite_input {} {
35 set filename test-[pid]
36 set fd [open $filename.c w]
37 puts $fd "int main (void) \{ return 0; \}"
39 remote_download host $filename.c
40 set test "input overwrite test"
42 set gcc_output [gcc_target_compile $filename.c $filename.c executable ""]
44 # Is this right, or do I need to use something like remote_upload?
45 set fd [open $filename.c r]
46 set file_data [read $fd]
48 remote_file build delete $filename.c
50 # check if the contents of the input file has changed
51 if {!($file_data eq "int main (void) \{ return 0; \}\n")} {
52 fail "$test (input overwritten)"
56 # check if the error message was printed
57 if {![regexp -- "same as output" $gcc_output]} {
58 fail "$test (no error printed)"
64 check_gcc_overwrite_input
66 gcc_parallel_test_enable 1