setenv GOARCH $goarch
}
+# This be kept in sync with libgo/configure.ac.
+proc go-set-goos { } {
+ global target_triplet
+
+ switch -glob $target_triplet {
+ "*-*-darwin*" {
+ set goos "darwin"
+ }
+ "*-*-freebsd*" {
+ set goos "freebsd"
+ }
+ "*-*-irix6*" {
+ set goos "irix"
+ }
+ "*-*-linux*" {
+ set goos "linux"
+ }
+ "*-*-netbsd*" {
+ set goos "netbsd"
+ }
+ "*-*-openbsd*" {
+ set goos "openbsd"
+ }
+ "*-*-dragonfly*" {
+ set goos "dragonfly"
+ }
+ "*-*-rtems*" {
+ set goos "rtems"
+ }
+ "*-*-solaris2*" {
+ set goos "solaris"
+ }
+ "*-*-aix*" {
+ set goos "aix"
+ }
+ "*-*-gnu*" {
+ set goos "hurd"
+ }
+ default {
+ perror "$target_triplet: unhandled GOOS"
+ return
+ }
+ }
+ verbose -log "Setting GOOS=$goos" 1
+ setenv GOOS $goos
+}
+
# Take a list of files and return a lists of lists, where each list is
# the set of files in the same package.
proc go-find-packages { test name files } {
return $packages
}
+proc go-gc-match { name } {
+ verbose -log "go-gc-match $name"
+ set idx [string first "," $name]
+ if { $idx >= 0 } {
+ set left [string range $name 0 [expr $idx - 1]]
+ set right [string range $name [expr $idx + 1] end]
+ return [expr [go-gc-match $left] && [go-gc-match $right]]
+ }
+ if { [string index $name 0] == "!" && [string index $name 1] == "!" } {
+ return 0
+ }
+ if { [string index $name 0] == "!" } {
+ return [expr ! [go-gc-match [string range $name 1 end]]]
+ }
+ if { $name == [getenv GOARCH] || $name == [getenv GOOS] || $name == "gccgo" } {
+ return 1
+ }
+
+ return 0
+}
+
proc go-gc-tests { } {
global srcdir subdir
global runtests
set options ""
lappend options "additional_flags=$DEFAULT_GOCFLAGS"
- # Set GOARCH for tests that need it.
+ # Set GOARCH and GOOS for tests that need it.
go-set-goarch
+ go-set-goos
# Running all the torture options takes too long and, since the
# frontend ignores the standard options, it doesn't significantly
set lines_ok 1
+ set test_line ""
while 1 {
- if { [gets $fd test_line] < 0 } {
- close $fd
- clone_output "$test: could not read first line"
+ if { [gets $fd file_line] < 0 } {
+ if [eof $fd] {
+ break
+ }
+ clone_output "$test: read failed"
unresolved $name
set lines_ok 0
break
}
- if { [ string match "*nacl*exit 0*" $test_line ] \
- || [ string match "*exit 0*nacl*" $test_line ] \
- || [ string match "*Android*exit 0*" $test_line ] \
- || [ string match "*exit 0*Android*" $test_line ] \
- || [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
+ if { [ string match "*nacl*exit 0*" $file_line ] \
+ || [ string match "*exit 0*nacl*" $file_line ] \
+ || [ string match "*Android*exit 0*" $file_line ] \
+ || [ string match "*exit 0*Android*" $file_line ] \
+ || [ string match "*\"\$GOOS\" == windows*" $file_line ] } {
continue
}
- if { [ string match "// +build *" $test_line ] } {
- set matches_pos 0
- set matches_neg 0
- if { [ regexp -line "\[ \][getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
- set matches_pos 1
- } elseif { [ regexp -line "\[ \]\![getenv GOARCH]\(\[ \]\|\$\)" $test_line ] } {
- set matches_neg 1
- } elseif { [ regexp -line "\[ \]linux\(\[ \]\|\$\)" $test_line ] } {
- set matches_pos 1
- } elseif { [ regexp -line "\[ \]\!linux\(\[ \]\|\$\)" $test_line ] } {
- set matches_neg 1
- } elseif { [ regexp -line "\[ \]\!windows\(\[ \]\|\$\)" $test_line ] } {
- set matches_pos 1
- } elseif { [ regexp -line "\[ \]windows\(\[ \]\|\$\)" $test_line ] } {
- set matches_neg 1
+ if ![string match "// *" $file_line] {
+ if { $file_line != "" } {
+ break
}
- if { $matches_pos == 1 && $matches_neg == 0 } {
+ continue
+ }
+
+ if { [ string match "// +build *" $file_line ] } {
+ set words [split $file_line]
+ set matches 0
+ for { set idx 2 } { $idx < [llength $words] } { incr idx } {
+ if { [go-gc-match [lindex $words $idx]] } {
+ set matches 1
+ break
+ }
+ }
+ if { $matches == 1 } {
continue
}
- close $fd
unsupported $name
set lines_ok 0
+ break
}
- break
- }
-
- if { $lines_ok == 0 } {
- continue
+ if { $test_line == "" } {
+ set test_line $file_line
+ }
}
- set lineno 1
- set test_line1 $test_line
+ close $fd
- while { [eval "string match \"//*&&\" \${test_line$lineno}"] } {
- set lineno [expr $lineno + 1]
- if { [eval "gets \$fd test_line$lineno"] < 0 } {
- close $fd
- clone_output "$test: could not read line $lineno"
- unresolved $name
- set lines_ok 0
- break
- }
- }
if { $lines_ok == 0 } {
continue
}
- close $fd
-
# runtest_file_p is already run above, and the code below can run
# runtest_file_p again, make sure everything for this test is
# performed if the above runtest_file_p decided this runtest