output.exp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Copyright (C) 2005-2015 Free Software Foundation, Inc.
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with GCC; see the file COPYING3. If not see
  14. # <http://www.gnu.org/licenses/>.
  15. # Run GCC with the input file also specified as output file. Check that the
  16. # compiler prints an error message and does not overwrite the input file.
  17. load_lib gcc-defs.exp
  18. load_lib target-supports.exp
  19. # These tests don't run runtest_file_p consistently if it
  20. # doesn't return the same values, so disable parallelization
  21. # of this *.exp file. The first parallel runtest to reach
  22. # this will run all the tests serially.
  23. if ![gcc_parallel_test_run_p output] {
  24. return
  25. }
  26. # I'm not sure if this is needed here. It was in options.exp.
  27. gcc_parallel_test_enable 0
  28. proc check_gcc_overwrite_input {} {
  29. set filename test-[pid]
  30. set fd [open $filename.c w]
  31. puts $fd "int main (void) \{ return 0; \}"
  32. close $fd
  33. remote_download host $filename.c
  34. set test "input overwrite test"
  35. set compiler cc1
  36. set gcc_output [gcc_target_compile $filename.c $filename.c executable ""]
  37. # Is this right, or do I need to use something like remote_upload?
  38. set fd [open $filename.c r]
  39. set file_data [read $fd]
  40. close $fd
  41. remote_file build delete $filename.c
  42. # check if the contents of the input file has changed
  43. if {!($file_data eq "int main (void) \{ return 0; \}\n")} {
  44. fail "$test (input overwritten)"
  45. return
  46. }
  47. # check if the error message was printed
  48. if {![regexp -- "same as output" $gcc_output]} {
  49. fail "$test (no error printed)"
  50. return
  51. }
  52. pass $test
  53. }
  54. check_gcc_overwrite_input
  55. gcc_parallel_test_enable 1