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