| 1 |
# Copyright (C) 2009-2025 Free Software Foundation, Inc. |
| 2 |
# Written by Ian Lance Taylor <[email protected]>. |
| 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 |
# <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
|
| 19 |
# Test using the testsuite for the gc Go compiler. In these tests the |
| 20 |
# first line is a shell script to run. That line expects the |
| 21 |
# following environment variables to be set: |
| 22 |
# A The file extension of the object file and the name of the executable |
| 23 |
# G The name of the compiler |
| 24 |
# L The name of the linker |
| 25 |
# F The basename of the test |
| 26 |
# D The directory of the test. |
| 27 |
# |
| 28 |
# Typical command lines: |
| 29 |
# // compile |
| 30 |
# // run |
| 31 |
# // $G $D/$F.go && $L $F.$A && ./$A.out |
| 32 |
# // $G $D/$F.go && $L $F.$A || echo BUG: known to fail incorrectly |
| 33 |
# // $G $D/$F.go && echo BUG: compilation succeeds incorrectly |
| 34 |
# // $G $D/$F.go || echo BUG: compilation should succeed |
| 35 |
|
| 36 |
load_lib go-dg.exp |
| 37 |
load_lib go-torture.exp |
| 38 |
load_lib target-supports.exp |
| 39 |
|
| 40 |
# Compare two files |
| 41 |
proc filecmp { file1 file2 testname } { |
| 42 |
set f1 [open $file1 r] |
| 43 |
set f2 [open $file2 r] |
| 44 |
set ok 1 |
| 45 |
while { [gets $f1 line1] >= 0 } { |
| 46 |
if { [gets $f2 line2] < 0 } { |
| 47 |
verbose -log "output mismatch: $file2 shorter than $file1" |
| 48 |
set ok 0 |
| 49 |
break |
| 50 |
} |
| 51 |
if { $line1 != $line2 } { |
| 52 |
verbose -log "output mismatch comparing $file1 and $file2" |
| 53 |
verbose -log "expected \"$line1\"" |
| 54 |
verbose -log "got \"$line2\"" |
| 55 |
set ok 0 |
| 56 |
break |
| 57 |
} |
| 58 |
} |
| 59 |
if { [gets $f2 line2] >= 0 } { |
| 60 |
verbose -log "output mismatch: $file1 shorter than $file2" |
| 61 |
set ok 0 |
| 62 |
} |
| 63 |
close $f1 |
| 64 |
close $f2 |
| 65 |
if { ! $ok } { |
| 66 |
fail $testname |
| 67 |
} else { |
| 68 |
pass $testname |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
# Implement errchk |
| 73 |
proc errchk { test opts } { |
| 74 |
global dg-do-what-default |
| 75 |
global DEFAULT_GOCFLAGS |
| 76 |
global runtests |
| 77 |
|
| 78 |
set saved-dg-do-what-default ${dg-do-what-default} |
| 79 |
set dg-do-what-default compile |
| 80 |
set filename [file tail $test] |
| 81 |
if { "$filename" == "$test" } { |
| 82 |
set filename "errchk-$filename" |
| 83 |
} |
| 84 |
set fdin [open $test r] |
| 85 |
fconfigure $fdin -translation binary |
| 86 |
set fdout [open $filename w] |
| 87 |
fconfigure $fdout -translation binary |
| 88 |
while { [gets $fdin copy_line] >= 0 } { |
| 89 |
if [string match "*////*" $copy_line] { |
| 90 |
puts $fdout $copy_line |
| 91 |
continue |
| 92 |
} |
| 93 |
|
| 94 |
# Combine quoted strings in comments, so that |
| 95 |
# // ERROR "first error" "second error" |
| 96 |
# turns into |
| 97 |
# // ERROR "first error|second error" |
| 98 |
# This format is used by the master testsuite to recognize |
| 99 |
# multiple errors on a single line. We don't require that all |
| 100 |
# the errors be present, but we do want to accept any of them. |
| 101 |
set changed "" |
| 102 |
while { $changed != $copy_line } { |
| 103 |
set changed $copy_line |
| 104 |
regsub {(// [^"]*"[^"]*)" "} $copy_line {\1|} out_line |
| 105 |
set copy_line $out_line |
| 106 |
} |
| 107 |
|
| 108 |
set index [string first // $copy_line] |
| 109 |
set eindex [string first ERROR $copy_line] |
| 110 |
if { $index >= 0 && $eindex > $index } { |
| 111 |
# We're putting the regexp in curly braces, so replace any |
| 112 |
# curly braces in the regexp with hex escapes. |
| 113 |
regsub -start $index -all "\{" $copy_line {\x7b} copy_line |
| 114 |
regsub -start $index -all "\}" $copy_line {\x7d} copy_line |
| 115 |
|
| 116 |
# Replace .* with [ -~]* because .* will eat newlines. |
| 117 |
# We can't easily use (?n) because this regexp will appear |
| 118 |
# in the middle of a large regexp. |
| 119 |
regsub -all {\.\*} $copy_line {[ -~]*} copy_line |
| 120 |
} |
| 121 |
|
| 122 |
# Change |
| 123 |
# // ERROR "string" |
| 124 |
# to |
| 125 |
# // { dg-error {string} } |
| 126 |
# The latter is what go-dg-runtest expects. |
| 127 |
regsub {// (GCCGO_)?ERROR "([^"]*)"([^"]*)$} $copy_line "// \{ dg-error \{\\2\} \}\\3" out_line |
| 128 |
|
| 129 |
puts $fdout $out_line |
| 130 |
} |
| 131 |
close $fdin |
| 132 |
close $fdout |
| 133 |
|
| 134 |
set hold_runtests $runtests |
| 135 |
set runtests "go-test.exp" |
| 136 |
go-dg-runtest $filename "" "-fno-show-column $DEFAULT_GOCFLAGS $opts" |
| 137 |
set runtests $hold_runtests |
| 138 |
|
| 139 |
file delete $filename |
| 140 |
set dg-do-what-default ${saved-dg-do-what-default} |
| 141 |
} |
| 142 |
|
| 143 |
# This is an execution test which should fail. |
| 144 |
proc go-execute-xfail { test } { |
| 145 |
global DEFAULT_GOCFLAGS |
| 146 |
global runtests |
| 147 |
|
| 148 |
set filename [file tail $test] |
| 149 |
set fdin [open $test r] |
| 150 |
set fdout [open $filename w] |
| 151 |
puts $fdout "// { dg-do run { xfail *-*-* } }" |
| 152 |
while { [gets $fdin copy_line] >= 0 } { |
| 153 |
puts $fdout $copy_line |
| 154 |
} |
| 155 |
close $fdin |
| 156 |
close $fdout |
| 157 |
|
| 158 |
set hold_runtests $runtests |
| 159 |
set runtests "go-test.exp" |
| 160 |
go-dg-runtest $filename "" "-w $DEFAULT_GOCFLAGS" |
| 161 |
set runtests $hold_runtests |
| 162 |
|
| 163 |
file delete $filename |
| 164 |
} |
| 165 |
|
| 166 |
# N.B. Keep in sync with libgo/configure.ac. |
| 167 |
proc go-set-goarch { } { |
| 168 |
global target_triplet |
| 169 |
|
| 170 |
switch -glob $target_triplet { |
| 171 |
"aarch64*-*-*" { |
| 172 |
set goarch "arm64" |
| 173 |
} |
| 174 |
"alpha*-*-*" { |
| 175 |
set goarch "alpha" |
| 176 |
} |
| 177 |
"arm*-*-*" - |
| 178 |
"ep9312*-*-*" - |
| 179 |
"strongarm*-*-*" - |
| 180 |
"xscale-*-*" { |
| 181 |
set goarch "arm" |
| 182 |
} |
| 183 |
"i?86-*-*" - |
| 184 |
"x86_64-*-*" { |
| 185 |
if [check_effective_target_ia32] { |
| 186 |
set goarch "386" |
| 187 |
} elseif [check_effective_target_x32] { |
| 188 |
set goarch "amd64p32" |
| 189 |
} else { |
| 190 |
set goarch "amd64" |
| 191 |
} |
| 192 |
} |
| 193 |
"mips*-*-*" { |
| 194 |
if [check_no_compiler_messages mipso32 assembly { |
| 195 |
#if _MIPS_SIM != _ABIO32 |
| 196 |
#error FOO |
| 197 |
#endif |
| 198 |
}] { |
| 199 |
set goarch "mips" |
| 200 |
} elseif [check_no_compiler_messages mipsn32 assembly { |
| 201 |
#if _MIPS_SIM != _ABIN32 |
| 202 |
#error FOO |
| 203 |
#endif |
| 204 |
}] { |
| 205 |
set goarch "mips64p32" |
| 206 |
} elseif [check_no_compiler_messages mipsn64 assembly { |
| 207 |
#if _MIPS_SIM != _ABI64 |
| 208 |
#error FOO |
| 209 |
#endif |
| 210 |
}] { |
| 211 |
set goarch "mips64" |
| 212 |
} else { |
| 213 |
perror "$target_triplet: unrecognized MIPS ABI" |
| 214 |
return "" |
| 215 |
} |
| 216 |
|
| 217 |
if [istarget "mips*el-*-*"] { |
| 218 |
append goarch "le" |
| 219 |
} |
| 220 |
} |
| 221 |
"powerpc*-*-*" { |
| 222 |
if [check_effective_target_ilp32] { |
| 223 |
set goarch "ppc" |
| 224 |
} else { |
| 225 |
if [istarget "powerpc64le-*-*"] { |
| 226 |
set goarch "ppc64le" |
| 227 |
} else { |
| 228 |
set goarch "ppc64" |
| 229 |
} |
| 230 |
} |
| 231 |
} |
| 232 |
"riscv64-*-*" { |
| 233 |
set goarch "riscv64" |
| 234 |
} |
| 235 |
"loongarch64-*-*" { |
| 236 |
set goarch "loongarch64" |
| 237 |
} |
| 238 |
"s390*-*-*" { |
| 239 |
if [check_effective_target_ilp32] { |
| 240 |
set goarch "s390" |
| 241 |
} else { |
| 242 |
set goarch "s390x" |
| 243 |
} |
| 244 |
} |
| 245 |
"sparc*-*-*" { |
| 246 |
if [check_effective_target_ilp32] { |
| 247 |
set goarch "sparc" |
| 248 |
} else { |
| 249 |
set goarch "sparc64" |
| 250 |
} |
| 251 |
} |
| 252 |
default { |
| 253 |
perror "$target_triplet: unhandled architecture" |
| 254 |
return "" |
| 255 |
} |
| 256 |
} |
| 257 |
verbose -log "Setting GOARCH=$goarch" 1 |
| 258 |
setenv GOARCH $goarch |
| 259 |
} |
| 260 |
|
| 261 |
# This be kept in sync with libgo/configure.ac. |
| 262 |
proc go-set-goos { } { |
| 263 |
global target_triplet |
| 264 |
|
| 265 |
switch -glob $target_triplet { |
| 266 |
"*-*-darwin*" { |
| 267 |
set goos "darwin" |
| 268 |
} |
| 269 |
"*-*-freebsd*" { |
| 270 |
set goos "freebsd" |
| 271 |
} |
| 272 |
"*-*-irix6*" { |
| 273 |
set goos "irix" |
| 274 |
} |
| 275 |
"*-*-linux*" { |
| 276 |
set goos "linux" |
| 277 |
} |
| 278 |
"*-*-netbsd*" { |
| 279 |
set goos "netbsd" |
| 280 |
} |
| 281 |
"*-*-openbsd*" { |
| 282 |
set goos "openbsd" |
| 283 |
} |
| 284 |
"*-*-dragonfly*" { |
| 285 |
set goos "dragonfly" |
| 286 |
} |
| 287 |
"*-*-rtems*" { |
| 288 |
set goos "rtems" |
| 289 |
} |
| 290 |
"*-*-solaris2*" { |
| 291 |
set goos "solaris" |
| 292 |
} |
| 293 |
"*-*-aix*" { |
| 294 |
set goos "aix" |
| 295 |
} |
| 296 |
"*-*-gnu*" { |
| 297 |
set goos "hurd" |
| 298 |
} |
| 299 |
default { |
| 300 |
perror "$target_triplet: unhandled GOOS" |
| 301 |
return |
| 302 |
} |
| 303 |
} |
| 304 |
verbose -log "Setting GOOS=$goos" 1 |
| 305 |
setenv GOOS $goos |
| 306 |
} |
| 307 |
|
| 308 |
# Take a list of files and return a lists of lists, where each list is |
| 309 |
# the set of files in the same package. |
| 310 |
proc go-find-packages { test name files } { |
| 311 |
set packages [list] |
| 312 |
foreach f $files { |
| 313 |
set fd [open $f r] |
| 314 |
while 1 { |
| 315 |
if { [gets $fd line] < 0 } { |
| 316 |
close $fd |
| 317 |
clone_output "$test: could not read $f" |
| 318 |
unresolved $name |
| 319 |
return [list] |
| 320 |
} |
| 321 |
|
| 322 |
if { [regexp "^package (\\w+)" $line match package] } { |
| 323 |
set len [llength $packages] |
| 324 |
for { set i 0 } { $i < $len } { incr i } { |
| 325 |
set p [lindex $packages $i] |
| 326 |
if { [lindex $p 0] == $package } { |
| 327 |
lappend p $f |
| 328 |
lset packages $i $p |
| 329 |
break |
| 330 |
} |
| 331 |
} |
| 332 |
if { $i >= $len } { |
| 333 |
lappend packages [list $package $f] |
| 334 |
} |
| 335 |
|
| 336 |
close $fd |
| 337 |
break |
| 338 |
} |
| 339 |
} |
| 340 |
} |
| 341 |
return $packages |
| 342 |
} |
| 343 |
|
| 344 |
proc go-gc-match { name } { |
| 345 |
verbose -log "go-gc-match $name" |
| 346 |
set idx [string first "," $name] |
| 347 |
if { $idx >= 0 } { |
| 348 |
set left [string range $name 0 [expr $idx - 1]] |
| 349 |
set right [string range $name [expr $idx + 1] end] |
| 350 |
return [expr [go-gc-match $left] && [go-gc-match $right]] |
| 351 |
} |
| 352 |
if { [string index $name 0] == "!" && [string index $name 1] == "!" } { |
| 353 |
return 0 |
| 354 |
} |
| 355 |
if { [string index $name 0] == "!" } { |
| 356 |
return [expr ! [go-gc-match [string range $name 1 end]]] |
| 357 |
} |
| 358 |
if { $name == [getenv GOARCH] || $name == [getenv GOOS] || $name == "gccgo" } { |
| 359 |
return 1 |
| 360 |
} |
| 361 |
|
| 362 |
return 0 |
| 363 |
} |
| 364 |
|
| 365 |
proc go-gc-tests { } { |
| 366 |
global srcdir subdir |
| 367 |
global runtests |
| 368 |
global GCC_UNDER_TEST |
| 369 |
global TOOL_OPTIONS |
| 370 |
global TORTURE_OPTIONS |
| 371 |
global dg-do-what-default |
| 372 |
global go_compile_args |
| 373 |
global go_execute_args |
| 374 |
global target_triplet |
| 375 |
|
| 376 |
# If a testcase doesn't have special options, use these. |
| 377 |
global DEFAULT_GOCFLAGS |
| 378 |
if ![info exists DEFAULT_GOCFLAGS] { |
| 379 |
set DEFAULT_GOCFLAGS " -pedantic-errors" |
| 380 |
} |
| 381 |
|
| 382 |
set options "" |
| 383 |
lappend options "additional_flags=$DEFAULT_GOCFLAGS" |
| 384 |
|
| 385 |
# Set GOARCH and GOOS for tests that need it. |
| 386 |
go-set-goarch |
| 387 |
go-set-goos |
| 388 |
|
| 389 |
# Running all the torture options takes too long and, since the |
| 390 |
# frontend ignores the standard options, it doesn't significantly |
| 391 |
# improve testing. |
| 392 |
set saved_torture_options $TORTURE_OPTIONS |
| 393 |
set TORTURE_OPTIONS [list { -O2 -g }] |
| 394 |
|
| 395 |
set saved-dg-do-what-default ${dg-do-what-default} |
| 396 |
|
| 397 |
set testdir [pwd] |
| 398 |
|
| 399 |
set tests [lsort [find $srcdir/$subdir *.go]] |
| 400 |
foreach test $tests { |
| 401 |
if ![runtest_file_p $runtests $test] { |
| 402 |
continue |
| 403 |
} |
| 404 |
|
| 405 |
# Skip the files in bench; they are not tests. |
| 406 |
if [string match "*go.test/test/bench/*" $test] { |
| 407 |
continue |
| 408 |
} |
| 409 |
|
| 410 |
# Skip the files in stress; they are not tests. |
| 411 |
if [string match "*go.test/test/stress/*" $test] { |
| 412 |
continue |
| 413 |
} |
| 414 |
|
| 415 |
# Skip the files in safe; gccgo does not support safe mode. |
| 416 |
if [string match "*go.test/test/safe/*" $test] { |
| 417 |
continue |
| 418 |
} |
| 419 |
|
| 420 |
# Skip files in sub-subdirectories: they are components of |
| 421 |
# other tests. |
| 422 |
if [string match "*go.test/test/*/*/*" $test] { |
| 423 |
continue |
| 424 |
} |
| 425 |
|
| 426 |
# Skip files in *.dir subdirectories: they are components of |
| 427 |
# other tests. |
| 428 |
if [string match "*go.test/test/*.dir/*" $test] { |
| 429 |
continue |
| 430 |
} |
| 431 |
|
| 432 |
set name [dg-trim-dirname $srcdir $test] |
| 433 |
|
| 434 |
# Skip certain tests if target is RTEMS OS. |
| 435 |
if [istarget "*-*-rtems*"] { |
| 436 |
if { [string match "*go.test/test/args.go" $test] \ |
| 437 |
|| [string match "*go.test/test/env.go" $test] } { |
| 438 |
untested "$name: uses the command-line or environment variables" |
| 439 |
continue |
| 440 |
} |
| 441 |
|
| 442 |
if { [string match "*go.test/test/stack.go" $test] \ |
| 443 |
|| [string match "*go.test/test/peano.go" $test] \ |
| 444 |
|| [string match "*go.test/test/chan/goroutines.go" $test] } { |
| 445 |
untested "$name: has very high memory requirement" |
| 446 |
continue |
| 447 |
} |
| 448 |
} |
| 449 |
|
| 450 |
# Handle certain tests in a target-dependant way. |
| 451 |
if { [istarget "alpha*-*-*"] || [istarget "sparc*-*-solaris*"] || [istarget "powerpc*-*-*"] || [istarget "s390*-*-*"] } { |
| 452 |
if { [string match "*go.test/test/nilptr.go" $test] } { |
| 453 |
untested $test |
| 454 |
continue |
| 455 |
} |
| 456 |
} |
| 457 |
|
| 458 |
if [check_effective_target_pie_enabled] { |
| 459 |
untested $test |
| 460 |
continue |
| 461 |
} |
| 462 |
|
| 463 |
if { [file tail $test] == "init1.go" } { |
| 464 |
# This tests whether GC runs during init, which for gccgo |
| 465 |
# it currently does not. |
| 466 |
untested $name |
| 467 |
continue |
| 468 |
} |
| 469 |
|
| 470 |
if { [file tail $test] == "closure.go" } { |
| 471 |
# This tests whether function closures do any memory |
| 472 |
# allocation, which for gccgo they currently do. |
| 473 |
untested $name |
| 474 |
continue |
| 475 |
} |
| 476 |
|
| 477 |
if { ( [file tail $test] == "select2.go" \ |
| 478 |
|| [file tail $test] == "stack.go" \ |
| 479 |
|| [file tail $test] == "peano.go" \ |
| 480 |
|| [file tail $test] == "nilptr2.go" \ |
| 481 |
|| [file tail $test] == "index0.go" ) \ |
| 482 |
&& ! [check_effective_target_split_stack] } { |
| 483 |
# These tests fails on targets without split stack. |
| 484 |
untested $name |
| 485 |
continue |
| 486 |
} |
| 487 |
|
| 488 |
if [string match "*go.test/test/rotate\[0123\].go" $test] { |
| 489 |
# These tests produces a temporary file that takes too long |
| 490 |
# to compile--5 minutes on my laptop without optimization. |
| 491 |
# When compiling without optimization it tests nothing |
| 492 |
# useful, since the point of the test is to see whether |
| 493 |
# the compiler generates rotate instructions. |
| 494 |
untested $name |
| 495 |
continue |
| 496 |
} |
| 497 |
|
| 498 |
if { [file tail $test] == "bug347.go" \ |
| 499 |
|| [file tail $test] == "bug348.go" } { |
| 500 |
# These tests don't work if the functions are inlined. |
| 501 |
set TORTURE_OPTIONS [list { -O0 -g }] |
| 502 |
} |
| 503 |
|
| 504 |
set fd [open $test r] |
| 505 |
|
| 506 |
set lines_ok 1 |
| 507 |
|
| 508 |
set test_line "" |
| 509 |
while 1 { |
| 510 |
if { [gets $fd file_line] < 0 } { |
| 511 |
if [eof $fd] { |
| 512 |
break |
| 513 |
} |
| 514 |
clone_output "$test: read failed" |
| 515 |
unresolved $name |
| 516 |
set lines_ok 0 |
| 517 |
break |
| 518 |
} |
| 519 |
|
| 520 |
if { [ string match "*nacl*exit 0*" $file_line ] \ |
| 521 |
|| [ string match "*exit 0*nacl*" $file_line ] \ |
| 522 |
|| [ string match "*Android*exit 0*" $file_line ] \ |
| 523 |
|| [ string match "*exit 0*Android*" $file_line ] \ |
| 524 |
|| [ string match "*\"\$GOOS\" == windows*" $file_line ] } { |
| 525 |
continue |
| 526 |
} |
| 527 |
|
| 528 |
if ![string match "// *" $file_line] { |
| 529 |
if { $file_line != "" } { |
| 530 |
break |
| 531 |
} |
| 532 |
continue |
| 533 |
} |
| 534 |
|
| 535 |
if { [ string match "// +build *" $file_line ] } { |
| 536 |
set words [split $file_line] |
| 537 |
set matches 0 |
| 538 |
for { set idx 2 } { $idx < [llength $words] } { incr idx } { |
| 539 |
if { [go-gc-match [lindex $words $idx]] } { |
| 540 |
set matches 1 |
| 541 |
break |
| 542 |
} |
| 543 |
} |
| 544 |
if { $matches == 1 } { |
| 545 |
continue |
| 546 |
} |
| 547 |
unsupported $name |
| 548 |
set lines_ok 0 |
| 549 |
break |
| 550 |
} |
| 551 |
|
| 552 |
if { $test_line == "" } { |
| 553 |
set test_line $file_line |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
close $fd |
| 558 |
|
| 559 |
if { $lines_ok == 0 } { |
| 560 |
continue |
| 561 |
} |
| 562 |
|
| 563 |
# runtest_file_p is already run above, and the code below can run |
| 564 |
# runtest_file_p again, make sure everything for this test is |
| 565 |
# performed if the above runtest_file_p decided this runtest |
| 566 |
# instance should execute the test |
| 567 |
gcc_parallel_test_enable 0 |
| 568 |
|
| 569 |
set go_compile_args "" |
| 570 |
set go_execute_args "" |
| 571 |
if { [regexp "// run (\[^|&>2\].*)\$" $test_line match progargs] \ |
| 572 |
&& ! [string match "*.go*" "$progargs"] } { |
| 573 |
set go_execute_args $progargs |
| 574 |
verbose -log "$test: go_execute_args is $go_execute_args" |
| 575 |
set index [string last " $progargs" $test_line] |
| 576 |
set test_line [string replace $test_line $index end] |
| 577 |
} elseif { [string match "*go.test/test/chan/goroutines.go" $test] \ |
| 578 |
&& [getenv GCCGO_RUN_ALL_TESTS] == "" } { |
| 579 |
# goroutines.go spawns by default 10000 threads, which is too much |
| 580 |
# for many OSes. |
| 581 |
if { [getenv GCC_TEST_RUN_EXPENSIVE] == "" } { |
| 582 |
set go_execute_args 64 |
| 583 |
} elseif { ![is_remote host] && ![is_remote target] } { |
| 584 |
# When using low ulimit -u limit, use maximum of |
| 585 |
# a quarter of that limit and 10000 even when running expensive |
| 586 |
# tests, otherwise parallel tests might fail after fork failures. |
| 587 |
set nproc [lindex [remote_exec host {sh -c ulimit\ -u}] 1] |
| 588 |
if { [string is integer -strict $nproc] } { |
| 589 |
set nproc [expr $nproc / 4] |
| 590 |
if { $nproc > 10000 } { set nproc 10000 } |
| 591 |
if { $nproc < 16 } { set nproc 16 } |
| 592 |
set go_execute_args $nproc |
| 593 |
} |
| 594 |
} |
| 595 |
if { "$go_execute_args" != "" } { |
| 596 |
verbose -log "$test: go_execute_args is $go_execute_args" |
| 597 |
} |
| 598 |
} |
| 599 |
|
| 600 |
if { $test_line == "// compile" |
| 601 |
|| $test_line == "// echo bug395 is broken # takes 90+ seconds to break" } { |
| 602 |
# This is a vanilla compile test. |
| 603 |
set dg-do-what-default "assemble" |
| 604 |
go-dg-runtest $test "" "-w $DEFAULT_GOCFLAGS" |
| 605 |
} elseif { $test_line == "// run" |
| 606 |
|| $test_line == "// \$G \$F.go && \$L \$F.\$A && ./\$A.out" } { |
| 607 |
# This is a vanilla execution test. |
| 608 |
go-torture-execute $test |
| 609 |
file delete core [glob -nocomplain core.*] |
| 610 |
} elseif { $test_line == "// build" } { |
| 611 |
# This is a vanilla compile and link test. |
| 612 |
set dg-do-what-default "link" |
| 613 |
go-dg-runtest $test "" "-w $DEFAULT_GOCFLAGS" |
| 614 |
} elseif { [string match "// runoutput*" $test_line] \ |
| 615 |
|| ($test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" |
| 616 |
&& $test_line2 == "// ./\$A.out >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1") } { |
| 617 |
# Run the test to get a .go program to run. |
| 618 |
set go_execute_args "" |
| 619 |
set hold_runtests $runtests |
| 620 |
set runtests "go-test.exp" |
| 621 |
set files [list] |
| 622 |
if { [string match "// runoutput*" $test_line] } { |
| 623 |
set args "" |
| 624 |
regsub "// runoutput\(.*\)" $test_line "\\1" args |
| 625 |
foreach f $args { |
| 626 |
lappend files "[file dirname $test]/$f" |
| 627 |
} |
| 628 |
} |
| 629 |
set dg-do-what-default "link" |
| 630 |
dg-test -keep-output $test "-O" "$files -w $DEFAULT_GOCFLAGS" |
| 631 |
set output_file "./[file rootname [file tail $test]].exe" |
| 632 |
set base "[file rootname [file tail $test]]" |
| 633 |
if [isnative] { |
| 634 |
if { [catch "exec $output_file >$base-out.go"] != 0 } { |
| 635 |
fail "$name execution" |
| 636 |
} else { |
| 637 |
pass "$name execution" |
| 638 |
file delete $base-out.x |
| 639 |
# Disable optimizations as some of these tests |
| 640 |
# take a long time to compile. |
| 641 |
set TORTURE_OPTIONS [list { -O0 -g -fno-var-tracking-assignments }] |
| 642 |
go-torture-execute "./$base-out.go" |
| 643 |
} |
| 644 |
file delete $base-out.go |
| 645 |
} |
| 646 |
file delete $output_file |
| 647 |
set runtests $hold_runtests |
| 648 |
} elseif { $test_line == "// cmpout" \ |
| 649 |
|| $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } { |
| 650 |
# This is an execution test for which we need to check the |
| 651 |
# program output. |
| 652 |
set hold_runtests $runtests |
| 653 |
set runtests "go-test.exp" |
| 654 |
set dg-do-what-default "link" |
| 655 |
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 656 |
set output_file "./[file rootname [file tail $test]].exe" |
| 657 |
set base "[file rootname [file tail $test]]" |
| 658 |
if [isnative] { |
| 659 |
verbose -log "$output_file >$base.p 2>&1" |
| 660 |
if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } { |
| 661 |
verbose -log $catcherr |
| 662 |
fail "$name execution" |
| 663 |
untested "$name compare" |
| 664 |
} else { |
| 665 |
pass "$name execution" |
| 666 |
regsub "\\.go$" $test ".out" expect |
| 667 |
filecmp $expect $base.p "$name compare" |
| 668 |
file delete $output_file |
| 669 |
} |
| 670 |
file delete $base.p |
| 671 |
} else { |
| 672 |
untested "$name execution" |
| 673 |
untested "$name compare" |
| 674 |
} |
| 675 |
set runtests $hold_runtests |
| 676 |
} elseif { [string match "// \$G \$D/\$F.go && \$L \$F.\$A && ! ./\$A.out || echo BUG: *" \ |
| 677 |
$test_line] } { |
| 678 |
go-execute-xfail $test |
| 679 |
} elseif { $test_line == "// errorcheck" } { |
| 680 |
errchk $test "" |
| 681 |
} elseif { $test_line == "// errorcheckdir" || $test_line == "// errorcheckdir -n" } { |
| 682 |
set hold_runtests $runtests |
| 683 |
set runtests "go-test.exp" |
| 684 |
set dir "[file rootname $test].dir" |
| 685 |
set files [lsort [glob "$dir/*.go"]] |
| 686 |
set packages [go-find-packages $test $name $files] |
| 687 |
if { [llength $packages] > 0 } { |
| 688 |
set dg-do-what-default "assemble" |
| 689 |
set del [list] |
| 690 |
set last [lindex $packages end] |
| 691 |
set packages [lreplace $packages end end] |
| 692 |
foreach p $packages { |
| 693 |
dg-test -keep-output [lrange $p 1 end] "-O -I." "-w $DEFAULT_GOCFLAGS" |
| 694 |
lappend del "[file rootname [file tail [lindex $p 1]]].o" |
| 695 |
} |
| 696 |
errchk [lindex $last 1] "[lrange $last 2 end]" |
| 697 |
foreach f $del { |
| 698 |
file delete $f |
| 699 |
} |
| 700 |
} |
| 701 |
set runtests $hold_runtests |
| 702 |
} elseif { [string match "// errorcheckoutput*" $test_line] } { |
| 703 |
# Run the test to get a .go program to error check. |
| 704 |
set go_execute_args "" |
| 705 |
set hold_runtests $runtests |
| 706 |
set runtests "go-test.exp" |
| 707 |
set files [list] |
| 708 |
regsub "// errorcheckoutput\(.*\)" $test_line "\\1" args |
| 709 |
foreach f $args { |
| 710 |
lappend files "[file dirname $test]/$f" |
| 711 |
} |
| 712 |
set dg-do-what-default "link" |
| 713 |
dg-test -keep-output $test "-O" "$files -w $DEFAULT_GOCFLAGS" |
| 714 |
set output_file "./[file rootname [file tail $test]].exe" |
| 715 |
set base "[file rootname [file tail $test]]" |
| 716 |
if [isnative] { |
| 717 |
if { [catch "exec $output_file >$base-out.go"] != 0 } { |
| 718 |
fail "$name execution" |
| 719 |
} else { |
| 720 |
pass "$name execution" |
| 721 |
errchk "$base-out.go" "" |
| 722 |
} |
| 723 |
file delete $base-out.go |
| 724 |
} |
| 725 |
file delete $output_file |
| 726 |
set runtests $hold_runtests |
| 727 |
} elseif { $test_line == "// compiledir" } { |
| 728 |
set hold_runtests $runtests |
| 729 |
set runtests "go-test.exp" |
| 730 |
set dg-do-what-default "assemble" |
| 731 |
set dir "[file rootname $test].dir" |
| 732 |
set files [lsort [glob "$dir/*.go"]] |
| 733 |
set packages [go-find-packages $test $name $files] |
| 734 |
if { [llength $packages] > 0 } { |
| 735 |
set del [list] |
| 736 |
foreach p $packages { |
| 737 |
dg-test -keep-output [lindex $p 1] "[lrange $p 2 end] -O -I." "-w $DEFAULT_GOCFLAGS" |
| 738 |
lappend del "[file rootname [file tail [lindex $p 1]]].o" |
| 739 |
} |
| 740 |
foreach f $del { |
| 741 |
file delete $f |
| 742 |
} |
| 743 |
} |
| 744 |
set runtests $hold_runtests |
| 745 |
} elseif { $test_line == "// rundir" } { |
| 746 |
set hold_runtests $runtests |
| 747 |
set runtests "go-test.exp" |
| 748 |
set dir "[file rootname $test].dir" |
| 749 |
set files [lsort [glob "$dir/*.go"]] |
| 750 |
set packages [go-find-packages $test $name $files] |
| 751 |
if { [llength $packages] > 0 } { |
| 752 |
set dg-do-what-default "assemble" |
| 753 |
set del [list] |
| 754 |
set last [lindex $packages end] |
| 755 |
set packages [lreplace $packages end end] |
| 756 |
foreach p $packages { |
| 757 |
dg-test -keep-output [lrange $p 1 end] "-O -I." "-w $DEFAULT_GOCFLAGS" |
| 758 |
lappend del "[file rootname [file tail [lindex $p 1]]].o" |
| 759 |
} |
| 760 |
set dg-do-what-default "link" |
| 761 |
set go_compile_args "" |
| 762 |
append go_compile_args [lrange $last 2 end] |
| 763 |
append go_compile_args $del |
| 764 |
go-torture-execute [lindex $last 1] |
| 765 |
foreach f $del { |
| 766 |
file delete $f |
| 767 |
} |
| 768 |
} |
| 769 |
set runtests $hold_runtests |
| 770 |
} elseif { $test_line == "// rundircmpout" } { |
| 771 |
set hold_runtests $runtests |
| 772 |
set runtests "go-test.exp" |
| 773 |
set dir "[file rootname $test].dir" |
| 774 |
set files [lsort [glob "$dir/*.go"]] |
| 775 |
set packages [go-find-packages $test $name $files] |
| 776 |
if { [llength $packages] > 0 } { |
| 777 |
set dg-do-what-default "assemble" |
| 778 |
set del [list] |
| 779 |
set last [lindex $packages end] |
| 780 |
set packages [lreplace $packages end end] |
| 781 |
foreach p $packages { |
| 782 |
dg-test -keep-output [lrange $p 1 end] "-O -I." "-w $DEFAULT_GOCFLAGS" |
| 783 |
lappend del "[file rootname [file tail [lindex $p 1]]].o" |
| 784 |
} |
| 785 |
set dg-do-what-default "link" |
| 786 |
dg-test -keep-output [lrange $last 1 end] "$del -O -I." "-w $DEFAULT_GOCFLAGS" |
| 787 |
set base "[file rootname [file tail [lindex $last 1]]]" |
| 788 |
set output_file "./$base.exe" |
| 789 |
lappend del $output_file |
| 790 |
if [isnative] { |
| 791 |
verbose -log "$output_file >$base.p 2>&1" |
| 792 |
if { [catch "exec $output_file 2>$base.p" catcherr] != 0 } { |
| 793 |
verbose -log $catcherr |
| 794 |
fail "$name execution" |
| 795 |
untested "$name compare" |
| 796 |
} else { |
| 797 |
pass "$name execution" |
| 798 |
regsub "\\.go$" "$test" ".out" expect |
| 799 |
filecmp $expect $base.p "$name compare" |
| 800 |
} |
| 801 |
lappend del $base.p |
| 802 |
} |
| 803 |
foreach f $del { |
| 804 |
file delete $f |
| 805 |
} |
| 806 |
} |
| 807 |
set runtests $hold_runtests |
| 808 |
} elseif { "$test_line" == "" |
| 809 |
|| [string match "// true*" $test_line] |
| 810 |
|| [string match "// skip*" $test_line] } { |
| 811 |
# Not a real test, just ignore. |
| 812 |
} elseif { [string match \ |
| 813 |
"// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \ |
| 814 |
$test_line] \ |
| 815 |
|| [string match \ |
| 816 |
"// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \ |
| 817 |
$test_line] } { |
| 818 |
if { [string match \ |
| 819 |
"// \$G \$D/\$F.dir/bug0.go && errchk \$G \$D/\$F.dir/bug1.go" \ |
| 820 |
$test_line] } { |
| 821 |
set name1 "bug0.go" |
| 822 |
set name2 "bug1.go" |
| 823 |
} elseif { [string match \ |
| 824 |
"// \$G \$D/\$F.dir/io.go && errchk \$G -e \$D/\$F.dir/main.go" \ |
| 825 |
$test_line] } { |
| 826 |
set name1 "io.go" |
| 827 |
set name2 "main.go" |
| 828 |
} |
| 829 |
set hold_runtests $runtests |
| 830 |
set runtests "go-test.exp" |
| 831 |
set dg-do-what-default "assemble" |
| 832 |
regsub "\\.go$" $test ".dir/$name1" file1 |
| 833 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 834 |
regsub "\\.go$" $test ".dir/$name2" file2 |
| 835 |
errchk $file2 "" |
| 836 |
file delete "[file rootname [file tail $file1]].o" |
| 837 |
set runtests $hold_runtests |
| 838 |
} elseif { [string match \ |
| 839 |
"// \$G \$D/\${F}1.go && errchk \$G \$D/\$F.go" \ |
| 840 |
$test_line ] } { |
| 841 |
set hold_runtests $runtests |
| 842 |
set runtests "go-test.exp" |
| 843 |
set dg-do-what-default "assemble" |
| 844 |
regsub "\\.go$" $test "1.go" file1 |
| 845 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 846 |
errchk $test "" |
| 847 |
file delete "[file rootname [file tail $file1]].o" |
| 848 |
set runtests $hold_runtests |
| 849 |
} elseif { [string match \ |
| 850 |
"// \$G \$D/\$F.dir/bug0.go && \$G \$D/\$F.dir/bug1.go && errchk \$G \$D/\$F.dir/bug2.go" \ |
| 851 |
$test_line] } { |
| 852 |
set hold_runtests $runtests |
| 853 |
set runtests "go-test.exp" |
| 854 |
set dg-do-what-default "assemble" |
| 855 |
regsub "\\.go$" $test ".dir/bug0.go" file1 |
| 856 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 857 |
regsub "\\.go$" $test ".dir/bug1.go" file2 |
| 858 |
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS" |
| 859 |
regsub "\\.go$" $test ".dir/bug2.go" file3 |
| 860 |
errchk $file3 "" |
| 861 |
file delete "[file rootname [file tail $file1]].o" |
| 862 |
file delete "[file rootname [file tail $file2]].o" |
| 863 |
set runtests $hold_runtests |
| 864 |
} elseif { [string match \ |
| 865 |
"// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \ |
| 866 |
$test_line] \ |
| 867 |
|| [string match \ |
| 868 |
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \ |
| 869 |
$test_line] \ |
| 870 |
|| $test_line == "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \ |
| 871 |
|| $test_line == "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \ |
| 872 |
|| $test_line == "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } { |
| 873 |
if { [string match \ |
| 874 |
"// \$G \$D/bug160.dir/x.go && \$G \$D/bug160.dir/y.go && \$L y.\$A && ./\$A.out" \ |
| 875 |
$test_line] } { |
| 876 |
set name1 "x.go" |
| 877 |
set name2 "y.go" |
| 878 |
} elseif { [string match \ |
| 879 |
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" \ |
| 880 |
$test_line] } { |
| 881 |
set name1 "p.go" |
| 882 |
set name2 "main.go" |
| 883 |
} elseif { $test_line == "// \$G \$D/\$F.dir/p1.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out" } { |
| 884 |
set name1 "p1.go" |
| 885 |
set name2 "main.go" |
| 886 |
} elseif { $test_line == "// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } { |
| 887 |
set name1 "lib.go" |
| 888 |
set name2 "" |
| 889 |
} elseif { $test_line == "// \$G \$D/method4a.go && \$G \$D/\$F.go && \$L \$F.\$A && ./$\A.out" } { |
| 890 |
set name1 "method4a.go" |
| 891 |
set name2 "" |
| 892 |
} |
| 893 |
set hold_runtests $runtests |
| 894 |
set runtests "go-test.exp" |
| 895 |
set dg-do-what-default "assemble" |
| 896 |
regsub "\\.go$" $test ".dir/$name1" file1 |
| 897 |
if { $name1 == "method4a.go" } { |
| 898 |
set file1 "[file dirname $test]/method4a.go" |
| 899 |
} |
| 900 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 901 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 902 |
regsub "\\.go$" $test ".dir/$name2" file2 |
| 903 |
if { $name2 == "" } { |
| 904 |
set file2 $test |
| 905 |
} |
| 906 |
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS" |
| 907 |
set ofile2 "[file rootname [file tail $file2]].o" |
| 908 |
set dg-do-what-default "link" |
| 909 |
set output_file "./[file rootname [file tail $test]].exe" |
| 910 |
set comp_output [go_target_compile "$ofile1 $ofile2" \ |
| 911 |
$output_file "executable" "$options"] |
| 912 |
set comp_output [go-dg-prune $target_triplet $comp_output] |
| 913 |
verbose -log $comp_output |
| 914 |
set result [go_load "$output_file" "" ""] |
| 915 |
set status [lindex $result 0] |
| 916 |
$status $name |
| 917 |
file delete $ofile1 $ofile2 $output_file |
| 918 |
set runtests $hold_runtests |
| 919 |
} elseif { $test_line == "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } { |
| 920 |
set hold_runtests $runtests |
| 921 |
set runtests "go-test.exp" |
| 922 |
set dg-do-what-default "assemble" |
| 923 |
regsub "\\.go$" $test ".dir/one.go" file1 |
| 924 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 925 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 926 |
regsub "\\.go$" $test ".dir/two.go" file2 |
| 927 |
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS" |
| 928 |
set ofile2 "[file rootname [file tail $file2]].o" |
| 929 |
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 930 |
set ofile3 "[file rootname [file tail $test]].o" |
| 931 |
set dg-do-what-default "link" |
| 932 |
set output_file "./[file rootname [file tail $test]].exe" |
| 933 |
set comp_output [go_target_compile "$ofile1 $ofile2 $ofile3" \ |
| 934 |
$output_file "executable" "$options"] |
| 935 |
set comp_output [go-dg-prune $target_triplet $comp_output] |
| 936 |
verbose -log $comp_output |
| 937 |
set result [go_load "$output_file" "" ""] |
| 938 |
set status [lindex $result 0] |
| 939 |
$status $name |
| 940 |
file delete $ofile1 $ofile2 $ofile3 $output_file |
| 941 |
set runtests $hold_runtests |
| 942 |
} elseif { [string match \ |
| 943 |
"// \$G \$D/embed0.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" \ |
| 944 |
$test_line ] } { |
| 945 |
set hold_runtests $runtests |
| 946 |
set runtests "go-test.exp" |
| 947 |
set dg-do-what-default "assemble" |
| 948 |
regsub "/\[^/\]*$" $test "/embed0.go" file1 |
| 949 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 950 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 951 |
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 952 |
set ofile2 "[file rootname [file tail $test]].o" |
| 953 |
set output_file "./[file rootname [file tail $test]].exe" |
| 954 |
set comp_output [go_target_compile "$ofile1 $ofile2" \ |
| 955 |
$output_file "executable" "$options"] |
| 956 |
set comp_output [go-dg-prune $target_triplet $comp_output] |
| 957 |
if [string match "" $comp_output] { |
| 958 |
set result [go_load "$output_file" "" ""] |
| 959 |
set status [lindex $result 0] |
| 960 |
$status $name |
| 961 |
} else { |
| 962 |
verbose -log $comp_output |
| 963 |
fail $name |
| 964 |
} |
| 965 |
file delete $ofile1 $ofile2 $output_file |
| 966 |
set runtests $hold_runtests |
| 967 |
} elseif { [string match \ |
| 968 |
"// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \ |
| 969 |
$test_line ] || \ |
| 970 |
[string match \ |
| 971 |
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \ |
| 972 |
$test_line ] } { |
| 973 |
if { [string match \ |
| 974 |
"// \$G \$D/\$F.dir/lib.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \ |
| 975 |
$test_line ] } { |
| 976 |
set name1 "lib.go" |
| 977 |
set name2 "main.go" |
| 978 |
} elseif { [string match \ |
| 979 |
"// \$G \$D/\$F.dir/p.go && \$G \$D/\$F.dir/main.go && \$L main.\$A && ./\$A.out || echo BUG*" \ |
| 980 |
$test_line ] } { |
| 981 |
set name1 "p.go" |
| 982 |
set name2 "main.go" |
| 983 |
} |
| 984 |
set hold_runtests $runtests |
| 985 |
set runtests "go-test.exp" |
| 986 |
set dg-do-what-default "assemble" |
| 987 |
regsub "\\.go$" $test ".dir/$name1" file1 |
| 988 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 989 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 990 |
regsub "\\.go$" $test ".dir/$name2" file2 |
| 991 |
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS" |
| 992 |
set ofile2 "[file rootname [file tail $file2]].o" |
| 993 |
set dg-do-what-default "link" |
| 994 |
set output_file "./[file rootname [file tail $file2]].exe" |
| 995 |
set comp_output [go_target_compile "$ofile1 $ofile2" \ |
| 996 |
$output_file "executable" "$options"] |
| 997 |
set comp_output [go-dg-prune $target_triplet $comp_output] |
| 998 |
if [string match "" $comp_output] { |
| 999 |
set result [go_load "$output_file" "" ""] |
| 1000 |
set status [lindex $result 0] |
| 1001 |
$status $name |
| 1002 |
} else { |
| 1003 |
verbose -log $comp_output |
| 1004 |
fail $name |
| 1005 |
} |
| 1006 |
file delete $ofile1 $ofile2 $output_file |
| 1007 |
set runtests $hold_runtests |
| 1008 |
} elseif { $test_line == "// \$G \$D/\$F.dir/bug0.go &&" \ |
| 1009 |
&& $test_line2 == "// \$G \$D/\$F.dir/bug1.go &&" \ |
| 1010 |
&& $test_line3 == "// \$G \$D/\$F.dir/bug2.go &&" \ |
| 1011 |
&& $test_line4 == "// errchk \$G -e \$D/\$F.dir/bug3.go &&" \ |
| 1012 |
&& $test_line5 == "// \$L bug2.\$A &&" \ |
| 1013 |
&& [string match "// ./\$A.out || echo BUG*" $test_line6] } { |
| 1014 |
set hold_runtests $runtests |
| 1015 |
set runtests "go-test.exp" |
| 1016 |
set dg-do-what-default "assemble" |
| 1017 |
regsub "\\.go$" $test ".dir/bug0.go" file0 |
| 1018 |
dg-test -keep-output $file0 "-O -fgo-prefix=bug0" "-w $DEFAULT_GOCFLAGS" |
| 1019 |
set ofile0 "[file rootname [file tail $file0]].o" |
| 1020 |
regsub "\\.go$" $test ".dir/bug1.go" file1 |
| 1021 |
dg-test -keep-output $file1 "-O -fgo-prefix=bug1" "-w $DEFAULT_GOCFLAGS" |
| 1022 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 1023 |
regsub "\\.go$" $test ".dir/bug2.go" file2 |
| 1024 |
dg-test -keep-output $file2 "-O" "-w $DEFAULT_GOCFLAGS" |
| 1025 |
set ofile2 "[file rootname [file tail $file2]].o" |
| 1026 |
regsub "\\.go$" $test ".dir/bug3.go" file3 |
| 1027 |
errchk $file3 "" |
| 1028 |
set output_file "./[file rootname [file tail $test]].exe" |
| 1029 |
set comp_output [go_target_compile "$ofile0 $ofile1 $ofile2" \ |
| 1030 |
$output_file "executable" "$options"] |
| 1031 |
set comp-output [go-dg-prune $target_triplet $comp_output] |
| 1032 |
if [string match "" $comp_output] { |
| 1033 |
set result [go_load "$output_file" "" ""] |
| 1034 |
set status [lindex $result 0] |
| 1035 |
$status $name |
| 1036 |
} else { |
| 1037 |
verbose -log $comp_output |
| 1038 |
fail $name |
| 1039 |
} |
| 1040 |
file delete $ofile0 $ofile1 $ofile2 $output_file |
| 1041 |
set runtests $hold_runtests |
| 1042 |
} elseif { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" \ |
| 1043 |
|| $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } { |
| 1044 |
if { $test_line == "// \$G \$D/import2.go && \$G \$D/\$F\.go" } { |
| 1045 |
set name1 "import2.go" |
| 1046 |
} elseif { $test_line == "// \$G \$D/recursive1.go && \$G \$D/\$F.go" } { |
| 1047 |
set name1 "recursive1.go" |
| 1048 |
} |
| 1049 |
set hold_runtests $runtests |
| 1050 |
set runtests "go-test.exp" |
| 1051 |
set dg-do-what-default "assemble" |
| 1052 |
regsub "/\[^/\]*$" $test "/${name1}" file1 |
| 1053 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 1054 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 1055 |
dg-test $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 1056 |
file delete $ofile1 |
| 1057 |
set runtests $hold_runtests |
| 1058 |
} elseif { $test_line == "// \$G \$D/ddd2.go && \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out" } { |
| 1059 |
set hold_runtests $runtests |
| 1060 |
set runtests "go-test.exp" |
| 1061 |
set dg-do-what-default "assemble" |
| 1062 |
regsub "/\[^/\]*$" $test "/ddd2.go" file1 |
| 1063 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 1064 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 1065 |
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 1066 |
set ofile2 "[file rootname [file tail $test]].o" |
| 1067 |
set output_file "./[file rootname [file tail $test]].exe" |
| 1068 |
set comp_output [go_target_compile "$ofile1 $ofile2" \ |
| 1069 |
$output_file "executable" "$options"] |
| 1070 |
set comp_output [go-dg-prune $target_triplet $comp_output] |
| 1071 |
if [string match "" $comp_output] { |
| 1072 |
set result [go_load "$output_file" "" ""] |
| 1073 |
set status [lindex $result 0] |
| 1074 |
$status $name |
| 1075 |
} else { |
| 1076 |
verbose -log $comp_output |
| 1077 |
fail $name |
| 1078 |
} |
| 1079 |
file delete $ofile1 $ofile2 $output_file |
| 1080 |
set runtests $hold_runtests |
| 1081 |
} elseif { $test_line == "// run cmplxdivide1.go" } { |
| 1082 |
regsub "/\[^/\]*$" $test "/cmplxdivide1.go" test2 |
| 1083 |
set output_file "./[file rootname [file tail $test]].o" |
| 1084 |
set comp_output [go_target_compile "$test $test2" \ |
| 1085 |
$output_file "executable" "$options"] |
| 1086 |
set comp_output [go-dg-prune $target_triplet $comp_output] |
| 1087 |
if [string match "" $comp_output] { |
| 1088 |
set result [go_load "$output_file" "" ""] |
| 1089 |
set status [lindex $result 0] |
| 1090 |
$status $name |
| 1091 |
} else { |
| 1092 |
verbose -log $comp_output |
| 1093 |
fail $name |
| 1094 |
} |
| 1095 |
file delete $output_file |
| 1096 |
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A &&" \ |
| 1097 |
&& $test_line2 == "// ./\$A.out -pass 0 >tmp.go && \$G tmp.go && \$L -o \$A.out1 tmp.\$A && ./\$A.out1 &&" \ |
| 1098 |
&& $test_line3 == "// ./\$A.out -pass 1 >tmp.go && errchk \$G -e tmp.go &&" \ |
| 1099 |
&& $test_line4 == "// ./\$A.out -pass 2 >tmp.go && errchk \$G -e tmp.go" } { |
| 1100 |
set go_execute_args "" |
| 1101 |
set hold_runtests $runtests |
| 1102 |
set runtests "go-test.exp" |
| 1103 |
set dg-do-what-default "link" |
| 1104 |
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 1105 |
set output_file "./[file rootname [file tail $test]].exe" |
| 1106 |
if [isnative] { |
| 1107 |
if { [catch "exec $output_file -pass 0 >tmp.go"] != 0 } { |
| 1108 |
fail "$name execution 0" |
| 1109 |
} else { |
| 1110 |
pass "$name execution 0" |
| 1111 |
file delete tmp.x |
| 1112 |
# Disable optimizations as this test takes a long time |
| 1113 |
# to compile. |
| 1114 |
set TORTURE_OPTIONS [list { -O0 -g -fno-var-tracking-assignments }] |
| 1115 |
go-torture-execute "./tmp.go" |
| 1116 |
} |
| 1117 |
if { [catch "exec $output_file -pass 1 >tmp.go"] != 0 } { |
| 1118 |
fail "$name execution 1" |
| 1119 |
} else { |
| 1120 |
pass "$name execution 1" |
| 1121 |
errchk tmp.go "" |
| 1122 |
} |
| 1123 |
if { [catch "exec $output_file -pass 2 >tmp.go"] != 0 } { |
| 1124 |
fail "$name execution 2" |
| 1125 |
} else { |
| 1126 |
pass "$name execution 2" |
| 1127 |
errchk tmp.go "" |
| 1128 |
} |
| 1129 |
file delete tmp.go |
| 1130 |
} |
| 1131 |
file delete $output_file |
| 1132 |
set runtests $hold_runtests |
| 1133 |
} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out >tmp.go &&" \ |
| 1134 |
&& $test_line2 == "// errchk \$G -e tmp.go" } { |
| 1135 |
set go_execute_args "" |
| 1136 |
set hold_runtests $runtests |
| 1137 |
set runtests "go-test.exp" |
| 1138 |
set dg-do-what-default "link" |
| 1139 |
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 1140 |
set output_file "./[file rootname [file tail $test]].exe" |
| 1141 |
if [isnative] { |
| 1142 |
if { [catch "exec $output_file >tmp.go"] != 0 } { |
| 1143 |
fail "$name execution" |
| 1144 |
} else { |
| 1145 |
pass "$name execution" |
| 1146 |
file delete tmp.x |
| 1147 |
errchk tmp.go "" |
| 1148 |
} |
| 1149 |
} |
| 1150 |
file delete $output_file |
| 1151 |
set runtests $hold_runtests |
| 1152 |
} elseif { $test_line == "// errchk \$G -e \$D/\$F.dir/\[ab\].go" } { |
| 1153 |
regsub "\\.go$" $test ".dir/a.go" file1 |
| 1154 |
regsub "\\.go$" $test ".dir/b.go" file2 |
| 1155 |
errchk "$file1" "$file2" |
| 1156 |
} elseif { $test_line == "// \$G -N -o slow.\$A \$D/bug369.dir/pkg.go &&" \ |
| 1157 |
&& $test_line2 == "// \$G -o fast.\$A \$D/bug369.dir/pkg.go &&" \ |
| 1158 |
&& $test_line3 == "// run" } { |
| 1159 |
set hold_runtests $runtests |
| 1160 |
set runtests "go-test.exp" |
| 1161 |
set dg-do-what-default "assemble" |
| 1162 |
regsub "\\.go$" $test ".dir/pkg.go" file1 |
| 1163 |
dg-test -keep-output $file1 "" "-fgo-prefix=slow -w $DEFAULT_GOCFLAGS" |
| 1164 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 1165 |
file rename -force $ofile1 slow.o |
| 1166 |
dg-test -keep-output $file1 "-O2" "-fgo-prefix=fast -w $DEFAULT_GOCFLAGS" |
| 1167 |
file rename -force $ofile1 fast.o |
| 1168 |
set ofile2 "[file rootname [file tail $test]].o" |
| 1169 |
dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 1170 |
set output_file "./[file rootname [file tail $test]].exe" |
| 1171 |
set comp_output [go_target_compile "$ofile2 slow.o fast.o" \ |
| 1172 |
$output_file "executable" "$options"] |
| 1173 |
set comp_output [go-dg-prune $target_triplet $comp_output] |
| 1174 |
if [string match "" $comp_output] { |
| 1175 |
set result [go_load "$output_file" "" ""] |
| 1176 |
set status [lindex $result 0] |
| 1177 |
$status $name |
| 1178 |
} else { |
| 1179 |
verbose -log $comp_output |
| 1180 |
fail $name |
| 1181 |
} |
| 1182 |
file delete slow.o fast.o $ofile2 $output_file |
| 1183 |
set runtests $hold_runtests |
| 1184 |
} elseif { [string match \ |
| 1185 |
"// \$G \$D/\$F.dir/pkg.go && \$G \$D/\$F.go || echo *" \ |
| 1186 |
$test_line ] } { |
| 1187 |
set hold_runtests $runtests |
| 1188 |
set runtests "go-test.exp" |
| 1189 |
set dg-do-what-default "assemble" |
| 1190 |
regsub "\\.go$" $test ".dir/pkg.go" file1 |
| 1191 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 1192 |
dg-test $test "-O" "-w $DEFAULT_GOCFLAGS" |
| 1193 |
file delete "[file rootname [file tail $file1]].o" |
| 1194 |
set runtests $hold_runtests |
| 1195 |
} elseif { [string match "// \$G \$D/\$F.dir/one.go && \$G \$D/\$F.dir/two.go || echo BUG*" \ |
| 1196 |
$test_line ] } { |
| 1197 |
set hold_runtests $runtests |
| 1198 |
set runtests "go-test.exp" |
| 1199 |
set dg-do-what-default "assemble" |
| 1200 |
regsub "\\.go$" $test ".dir/one.go" file1 |
| 1201 |
dg-test -keep-output $file1 "-O" "-w $DEFAULT_GOCFLAGS" |
| 1202 |
set ofile1 "[file rootname [file tail $file1]].o" |
| 1203 |
regsub "\\.go$" $test ".dir/two.go" file2 |
| 1204 |
dg-test $file2 "-O" "-w $DEFAULT_GOCFLAGS" |
| 1205 |
file delete $ofile1 |
| 1206 |
set runtests $hold_runtests |
| 1207 |
} elseif { $test_line == "// \$G \$D/bug302.dir/p.go && pack grc pp.a p.\$A && \$G \$D/bug302.dir/main.go" \ |
| 1208 |
|| $test_line == "// \$G \$D/empty.go && errchk \$G \$D/\$F.go" } { |
| 1209 |
# These tests import the same package under two different |
| 1210 |
# names, which gccgo does not support. |
| 1211 |
} elseif { $test_line == "// \$G -S \$D/\$F.go | egrep initdone >/dev/null && echo BUG sinit || true" } { |
| 1212 |
# This tests whether initializers are written out |
| 1213 |
# statically. gccgo does not provide a way to test that, |
| 1214 |
# as an initializer will be generated for any code which |
| 1215 |
# has global variables which need to be registered as GC |
| 1216 |
# roots. |
| 1217 |
} elseif { $test_line == "// errorcheck -0 -m" |
| 1218 |
|| $test_line == "// errorcheck -0 -m -l" } { |
| 1219 |
# This tests debug output of the gc compiler, which is |
| 1220 |
# meaningless for gccgo. |
| 1221 |
} elseif { $test_line == "// \[ \$A == 6 \] || errchk \$G -e \$D/\$F.go" \ |
| 1222 |
|| $test_line == "// \[ \$A != 6 \] || errchk \$G -e \$D/\$F.go" } { |
| 1223 |
# This tests specific handling of the gc compiler on types |
| 1224 |
# that are too large. It is target specific in a way I |
| 1225 |
# haven't bothered to check for here. |
| 1226 |
} elseif { $test_line == "// \$G \$D/\$F.go && \$L -X main.tbd hello \$F.\$A && ./\$A.out" } { |
| 1227 |
# This tests the gc ld -X option, which gccgo does not |
| 1228 |
# support. |
| 1229 |
} elseif { $test_line == "// \$G \$D/pkg.go && pack grc pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && errchk \$G -I. -u \$D/main.go" |
| 1230 |
|| $test_line == "// \$G \$D/pkg.go && pack grcS pkg.a pkg.\$A 2> /dev/null && rm pkg.\$A && \$G -I. -u \$D/main.go" } { |
| 1231 |
# This tests the gc -u option, which gccgo does not |
| 1232 |
# support. |
| 1233 |
} elseif { $test_line == "// errorcheck -0 -N -d=nil" \ |
| 1234 |
|| $test_line == "// errorcheck -0 -d=nil" } { |
| 1235 |
# This tests gc nil pointer checks using -d=nil, which |
| 1236 |
# gccgo does not support. |
| 1237 |
} else { |
| 1238 |
clone_output "$name: unrecognized test line: $test_line" |
| 1239 |
unsupported $name |
| 1240 |
} |
| 1241 |
|
| 1242 |
set go_compile_args "" |
| 1243 |
set go_execute_args "" |
| 1244 |
set TORTURE_OPTIONS [list { -O2 -g }] |
| 1245 |
gcc_parallel_test_enable 1 |
| 1246 |
} |
| 1247 |
|
| 1248 |
set dg-do-what-default ${saved-dg-do-what-default} |
| 1249 |
set TORTURE_OPTIONS $saved_torture_options |
| 1250 |
} |
| 1251 |
|
| 1252 |
go-gc-tests |