PageRenderTime 50ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/gcc/testsuite/lib/mike-gcc.exp

#
Expect | 260 lines | 201 code | 28 blank | 31 comment | 43 complexity | 57c8fe24d11da442bc9a475a81f11b49 MD5 | raw file
Possible License(s): LGPL-2.0, GPL-2.0, LGPL-2.1, AGPL-1.0, GPL-3.0, BSD-3-Clause
  1. # Copyright (C) 1988, 90, 91, 92, 95, 96, 1997, 2007
  2. # 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.
  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. # This file was derived from mike-g++.exp written by Mike Stump <mrs@cygnus.com>
  17. #
  18. # mike_cleanup -- remove any files that are created by the testcase
  19. #
  20. proc mike_cleanup { src_code output_file assembly_file } {
  21. remote_file build delete $output_file $assembly_file
  22. }
  23. #
  24. # prebase -- sets up a Mike Stump (mrs@cygnus.com) style gcc test
  25. #
  26. proc prebase { } {
  27. global compiler_output
  28. global not_compiler_output
  29. global compiler_result
  30. global not_compiler_result
  31. global program_output
  32. global groups
  33. global run
  34. global actions
  35. global target_regexp
  36. set compiler_output "^$"
  37. set not_compiler_output ".*Internal compiler error.*"
  38. set compiler_result ""
  39. set not_compiler_result ""
  40. set program_output ".*PASS.*"
  41. set groups {}
  42. set run no
  43. set actions assemble
  44. set target_regexp ".*"
  45. }
  46. #
  47. # run the test
  48. #
  49. proc postbase { src_code run groups args } {
  50. global verbose
  51. global srcdir
  52. global subdir
  53. global not_compiler_output
  54. global compiler_output
  55. global compiler_result
  56. global not_compiler_result
  57. global program_output
  58. global actions
  59. global target_regexp
  60. global host_triplet
  61. global target_triplet
  62. global tool
  63. global tmpdir
  64. global GCC_UNDER_TEST
  65. global GROUP
  66. if ![info exists GCC_UNDER_TEST] {
  67. error "No compiler specified for testing."
  68. }
  69. if ![regexp $target_regexp $target_triplet] {
  70. unsupported $subdir/$src_code
  71. return
  72. }
  73. if { [llength $args] > 0 } {
  74. set comp_options [lindex $args 0]
  75. } else {
  76. set comp_options ""
  77. }
  78. set fail_message $subdir/$src_code
  79. set pass_message $subdir/$src_code
  80. if [info exists GROUP] {
  81. if {[lsearch $groups $GROUP] == -1} {
  82. return
  83. }
  84. }
  85. if [string match $run yes] {
  86. set actions run
  87. }
  88. set output_file "$tmpdir/[file tail [file rootname $src_code]]"
  89. set assembly_file "$output_file"
  90. append assembly_file ".S"
  91. set compile_type "none"
  92. case $actions {
  93. compile
  94. {
  95. set compile_type "assembly"
  96. set output_file $assembly_file
  97. }
  98. assemble
  99. {
  100. set compile_type "object"
  101. append output_file ".o"
  102. }
  103. link
  104. {
  105. set compile_type "executable"
  106. append output_file ".exe"
  107. }
  108. run
  109. {
  110. set compile_type "executable"
  111. append output_file ".exe"
  112. set run yes
  113. }
  114. default
  115. {
  116. set output_file ""
  117. set compile_type "none"
  118. }
  119. }
  120. set src_file "$srcdir/$subdir/$src_code"
  121. set options ""
  122. lappend options "compiler=$GCC_UNDER_TEST"
  123. if { $comp_options != "" } {
  124. lappend options "additional_flags=$comp_options"
  125. }
  126. set comp_output [gcc_target_compile $src_file $output_file $compile_type $options]
  127. set pass no
  128. # Delete things like "ld.so warning" messages.
  129. set comp_output [prune_warnings $comp_output]
  130. if [regexp -- $not_compiler_output $comp_output] {
  131. if { $verbose > 1 } {
  132. send_user "\nChecking:\n$not_compiler_output\nto make sure it does not match:\n$comp_output\nbut it does.\n\n"
  133. } else {
  134. send_log "\nCompiler output:\n$comp_output\n\n"
  135. }
  136. fail $fail_message
  137. # The framework doesn't like to see any error remnants,
  138. # so remove them.
  139. uplevel {
  140. if [info exists errorInfo] {
  141. unset errorInfo
  142. }
  143. }
  144. mike_cleanup $src_code $output_file $assembly_file
  145. return
  146. }
  147. # remove any leftover CRs.
  148. regsub -all -- "\r" $comp_output "" comp_output
  149. regsub -all "(^|\n)\[^\n\]*linker input file unused since linking not done" $comp_output "" comp_output
  150. regsub -all "(^|\n)\[^\n\]*file path prefix \[^\n\]* never used" $comp_output "" comp_output
  151. set unsupported_message [${tool}_check_unsupported_p $comp_output]
  152. if { $unsupported_message != "" } {
  153. unsupported "$subdir/$src_code: $unsupported_message"
  154. mike_cleanup $src_code $output_file $assembly_file
  155. return
  156. }
  157. if { $verbose > 1 } {
  158. send_user "\nChecking:\n$compiler_output\nto see if it matches:\n$comp_output\n"
  159. } else {
  160. send_log "\nCompiler output:\n$comp_output\n\n"
  161. }
  162. if [regexp -- $compiler_output $comp_output] {
  163. if { $verbose > 1 } {
  164. send_user "Yes, it matches.\n\n"
  165. }
  166. set pass yes
  167. if [file exists [file rootname [file tail $src_code]].s] {
  168. set fd [open [file rootname [file tail $src_code]].s r]
  169. set dot_s [read $fd]
  170. close $fd
  171. if { $compiler_result != "" } {
  172. verbose "Checking .s file for $compiler_result" 2
  173. if [regexp -- $compiler_result $dot_s] {
  174. verbose "Yes, it matches." 2
  175. } else {
  176. verbose "Nope, doesn't match." 2
  177. verbose $dot_s 4
  178. set pass no
  179. }
  180. }
  181. if { $not_compiler_result != "" } {
  182. verbose "Checking .s file for not $not_compiler_result" 2
  183. if ![regexp -- $not_compiler_result $dot_s] {
  184. verbose "Nope, not found (that's good)." 2
  185. } else {
  186. verbose "Uh oh, it was found." 2
  187. verbose $dot_s 4
  188. set pass no
  189. }
  190. }
  191. }
  192. if [string match $run yes] {
  193. set result [gcc_load $output_file]
  194. set status [lindex $result 0]
  195. set output [lindex $result 1]
  196. if { $status == -1 } {
  197. mike_cleanup $src_code $output_file $assembly_file
  198. return
  199. }
  200. if { $verbose > 1 } {
  201. send_user "Checking:\n$program_output\nto see if it matches:\n$output\n\n"
  202. }
  203. if ![regexp -- $program_output $output] {
  204. set pass no
  205. if { $verbose > 1 } {
  206. send_user "Nope, does not match.\n\n"
  207. }
  208. } else {
  209. if { $verbose > 1 } {
  210. send_user "Yes, it matches.\n\n"
  211. }
  212. }
  213. }
  214. } else {
  215. if { $verbose > 1 } {
  216. send_user "Nope, does not match.\n\n"
  217. }
  218. }
  219. if [string match $pass "yes"] {
  220. pass $pass_message
  221. } else {
  222. fail $fail_message
  223. }
  224. # The framework doesn't like to see any error remnants,
  225. # so remove them.
  226. uplevel {
  227. if [info exists errorInfo] {
  228. unset errorInfo
  229. }
  230. }
  231. mike_cleanup $src_code $output_file $assembly_file
  232. }