Skip to content

Commit

Permalink
all: skip unsupported tests for js/wasm
Browse files Browse the repository at this point in the history
The general policy for the current state of js/wasm is that it only
has to support tests that are also supported by nacl.

The test nilptr3.go makes assumptions about which nil checks can be
removed. Since WebAssembly does not signal on reading a null pointer,
all nil checks have to be explicit.

Updates #18892

Change-Id: I06a687860b8d22ae26b1c391499c0f5183e4c485
Reviewed-on: https://go-review.googlesource.com/110096
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
neelance authored and bradfitz committed Apr 30, 2018
1 parent 1b44167 commit e3c6847
Show file tree
Hide file tree
Showing 49 changed files with 399 additions and 41 deletions.
4 changes: 4 additions & 0 deletions src/archive/zip/zip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"internal/testenv"
"io"
"io/ioutil"
"runtime"
"sort"
"strings"
"testing"
Expand Down Expand Up @@ -461,6 +462,9 @@ func suffixIsZip64(t *testing.T, zip sizedReaderAt) bool {

// Zip64 is required if the total size of the records is uint32max.
func TestZip64LargeDirectory(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("too slow on wasm")
}
if testing.Short() {
t.Skip("skipping in short mode")
}
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func tooSlow(t *testing.T) {

func init() {
switch runtime.GOOS {
case "android", "nacl":
case "android", "js", "nacl":
canRun = false
case "darwin":
switch runtime.GOARCH {
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/go/internal/base/signal_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
// +build darwin dragonfly freebsd js linux nacl netbsd openbsd solaris

package base

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/debug/elf/file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ func TestCompressedSection(t *testing.T) {
func TestNoSectionOverlaps(t *testing.T) {
// Ensure cmd/link outputs sections without overlaps.
switch runtime.GOOS {
case "android", "darwin", "nacl", "plan9", "windows":
case "android", "darwin", "js", "nacl", "plan9", "windows":
t.Skipf("cmd/link doesn't produce ELF binaries on %s", runtime.GOOS)
}
_ = net.ResolveIPAddr // force dynamic linkage
Expand Down
4 changes: 4 additions & 0 deletions src/encoding/gob/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"io/ioutil"
"reflect"
"runtime"
"strings"
"testing"
)
Expand Down Expand Up @@ -1130,6 +1131,9 @@ func TestBadData(t *testing.T) {

// TestHugeWriteFails tests that enormous messages trigger an error.
func TestHugeWriteFails(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("out of memory on wasm")
}
if testing.Short() {
// Requires allocating a monster, so don't do this from all.bash.
t.Skip("skipping huge allocation in short mode")
Expand Down
9 changes: 6 additions & 3 deletions src/internal/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func HasGoBuild() bool {
return false
}
switch runtime.GOOS {
case "android", "nacl":
case "android", "nacl", "js":
return false
case "darwin":
if strings.HasPrefix(runtime.GOARCH, "arm") {
Expand Down Expand Up @@ -114,7 +114,7 @@ func GoTool() (string, error) {
// using os.StartProcess or (more commonly) exec.Command.
func HasExec() bool {
switch runtime.GOOS {
case "nacl":
case "nacl", "js":
return false
case "darwin":
if strings.HasPrefix(runtime.GOARCH, "arm") {
Expand Down Expand Up @@ -149,13 +149,16 @@ func MustHaveExec(t testing.TB) {
// HasExternalNetwork reports whether the current system can use
// external (non-localhost) networks.
func HasExternalNetwork() bool {
return !testing.Short()
return !testing.Short() && runtime.GOOS != "nacl" && runtime.GOOS != "js"
}

// MustHaveExternalNetwork checks that the current system can use
// external (non-localhost) networks.
// If not, MustHaveExternalNetwork calls t.Skip with an explanation.
func MustHaveExternalNetwork(t testing.TB) {
if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
t.Skipf("skipping test: no external network on %s", runtime.GOOS)
}
if testing.Short() {
t.Skipf("skipping test: no external network in -short mode")
}
Expand Down
2 changes: 1 addition & 1 deletion src/log/syslog/syslog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build !windows,!nacl,!plan9
// +build !windows,!nacl,!plan9,!js

package syslog

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/chanbarrier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func testChanSendBarrier(useSelect bool) {
var globalMu sync.Mutex
outer := 100
inner := 100000
if testing.Short() {
if testing.Short() || runtime.GOARCH == "wasm" {
outer = 10
inner = 1000
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/crash_nonunix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build windows plan9 nacl
// +build windows plan9 nacl js,wasm

package runtime_test

Expand Down
4 changes: 4 additions & 0 deletions src/runtime/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ func TestHugeGCInfo(t *testing.T) {
}

func TestPeriodicGC(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no sysmon on wasm yet")
}

// Make sure we're not in the middle of a GC.
runtime.GC()

Expand Down
15 changes: 15 additions & 0 deletions src/runtime/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ func TestSmhasherZeros(t *testing.T) {

// Strings with up to two nonzero bytes all have distinct hashes.
func TestSmhasherTwoNonzero(t *testing.T) {
if GOARCH == "wasm" {
t.Skip("Too slow on wasm")
}
if testing.Short() {
t.Skip("Skipping in short mode")
}
Expand Down Expand Up @@ -229,6 +232,9 @@ func TestSmhasherCyclic(t *testing.T) {

// Test strings with only a few bits set
func TestSmhasherSparse(t *testing.T) {
if GOARCH == "wasm" {
t.Skip("Too slow on wasm")
}
if testing.Short() {
t.Skip("Skipping in short mode")
}
Expand Down Expand Up @@ -264,6 +270,9 @@ func setbits(h *HashSet, b []byte, i int, k int) {
// Test all possible combinations of n blocks from the set s.
// "permutation" is a bad name here, but it is what Smhasher uses.
func TestSmhasherPermutation(t *testing.T) {
if GOARCH == "wasm" {
t.Skip("Too slow on wasm")
}
if testing.Short() {
t.Skip("Skipping in short mode")
}
Expand Down Expand Up @@ -433,6 +442,9 @@ func (k *IfaceKey) name() string {

// Flipping a single bit of a key should flip each output bit with 50% probability.
func TestSmhasherAvalanche(t *testing.T) {
if GOARCH == "wasm" {
t.Skip("Too slow on wasm")
}
if testing.Short() {
t.Skip("Skipping in short mode")
}
Expand Down Expand Up @@ -508,6 +520,9 @@ func TestSmhasherWindowed(t *testing.T) {
windowed(t, &BytesKey{make([]byte, 128)})
}
func windowed(t *testing.T, k Key) {
if GOARCH == "wasm" {
t.Skip("Too slow on wasm")
}
if testing.Short() {
t.Skip("Skipping in short mode")
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/pprof/pprof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build !nacl
// +build !nacl,!js

package pprof

Expand Down
26 changes: 26 additions & 0 deletions src/runtime/proc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func perpetuumMobile() {
}

func TestStopTheWorldDeadlock(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no preemption on wasm yet")
}
if testing.Short() {
t.Skip("skipping during short test")
}
Expand Down Expand Up @@ -230,6 +233,10 @@ func TestBlockLocked(t *testing.T) {
}

func TestTimerFairness(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no preemption on wasm yet")
}

done := make(chan bool)
c := make(chan bool)
for i := 0; i < 2; i++ {
Expand All @@ -256,6 +263,10 @@ func TestTimerFairness(t *testing.T) {
}

func TestTimerFairness2(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no preemption on wasm yet")
}

done := make(chan bool)
c := make(chan bool)
for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -290,6 +301,10 @@ var preempt = func() int {
}

func TestPreemption(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no preemption on wasm yet")
}

// Test that goroutines are preempted at function calls.
N := 5
if testing.Short() {
Expand All @@ -313,6 +328,10 @@ func TestPreemption(t *testing.T) {
}

func TestPreemptionGC(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no preemption on wasm yet")
}

// Test that pending GC preempts running goroutines.
P := 5
N := 10
Expand Down Expand Up @@ -385,6 +404,9 @@ func TestNumGoroutine(t *testing.T) {
}

func TestPingPongHog(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no preemption on wasm yet")
}
if testing.Short() {
t.Skip("skipping in -short mode")
}
Expand Down Expand Up @@ -834,6 +856,10 @@ func TestStealOrder(t *testing.T) {
}

func TestLockOSThreadNesting(t *testing.T) {
if runtime.GOARCH == "wasm" {
t.Skip("no threads on wasm yet")
}

go func() {
e, i := runtime.LockOSCounts()
if e != 0 || i != 0 {
Expand Down
5 changes: 4 additions & 1 deletion src/runtime/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) {
if GOOS == "nacl" {
t.Skip("nacl doesn't seem to fault on high addresses")
}
if GOOS == "js" {
t.Skip("js does not support catching faults")
}

defer func() {
if err := recover(); err != nil {
Expand Down Expand Up @@ -264,7 +267,7 @@ func TestTrailingZero(t *testing.T) {
}

func TestBadOpen(t *testing.T) {
if GOOS == "windows" || GOOS == "nacl" {
if GOOS == "windows" || GOOS == "nacl" || GOOS == "js" {
t.Skip("skipping OS that doesn't have open/read/write/close")
}
// make sure we get the correct error code if open fails. Same for
Expand Down
3 changes: 3 additions & 0 deletions src/runtime/rwmutex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func doTestParallelReaders(numReaders int) {
}

func TestParallelRWMutexReaders(t *testing.T) {
if GOARCH == "wasm" {
t.Skip("wasm has no threads yet")
}
defer GOMAXPROCS(GOMAXPROCS(-1))
// If runtime triggers a forced GC during this test then it will deadlock,
// since the goroutines can't be stopped/preempted.
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func TestStackMem(t *testing.T) {

// Test stack growing in different contexts.
func TestStackGrowth(t *testing.T) {
if GOARCH == "wasm" {
t.Skip("fails on wasm (too slow?)")
}

// Don't make this test parallel as this makes the 20 second
// timeout unreliable on slow builders. (See issue #19381.)

Expand Down
4 changes: 2 additions & 2 deletions src/syscall/syscall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func TestExecErrPermutedFds(t *testing.T) {
}

func TestGettimeofday(t *testing.T) {
if runtime.GOOS == "nacl" {
t.Skip("not implemented on nacl")
if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
t.Skip("not implemented on " + runtime.GOOS)
}
tv := &syscall.Timeval{}
if err := syscall.Gettimeofday(tv); err != nil {
Expand Down
9 changes: 8 additions & 1 deletion src/text/template/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ import (
// templates. This limit is only practically reached by accidentally
// recursive template invocations. This limit allows us to return
// an error instead of triggering a stack overflow.
const maxExecDepth = 100000
var maxExecDepth = initMaxExecDepth()

func initMaxExecDepth() int {
if runtime.GOARCH == "wasm" {
return 1000
}
return 100000
}

// state represents the state of an execution. It's not part of the
// template so that multiple executions of the same template
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug248.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !nacl,!plan9,!windows
// +build !nacl,!js,!plan9,!windows
// run

// Copyright 2009 The Go Authors. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug302.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !nacl
// +build !nacl,!js
// run

// Copyright 2010 The Go Authors. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug345.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !nacl,!plan9,!windows
// +build !nacl,!js,!plan9,!windows
// run

// Copyright 2011 The Go Authors. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug369.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !nacl,!windows
// +build !nacl,!js,!windows
// run

// Copyright 2011 The Go Authors. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/bug429_run.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !nacl
// +build !nacl,!js
// run

// Copyright 2014 The Go Authors. All rights reserved.
Expand Down
2 changes: 1 addition & 1 deletion test/fixedbugs/issue10958.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// +build !nacl,disabled_see_issue_18589
// +build !nacl,!js,disabled_see_issue_18589
// buildrun -t 10 -gcflags=-d=ssa/insert_resched_checks/on,ssa/check/on

// Copyright 2016 The Go Authors. All rights reserved.
Expand Down
Loading

0 comments on commit e3c6847

Please sign in to comment.