mirror of
https://github.com/golang/go
synced 2024-10-02 22:25:08 +00:00
all: skip unsupported tests for js/wasm
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>
This commit is contained in:
parent
1b44167d05
commit
e3c684777a
|
@ -15,6 +15,7 @@ import (
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -461,6 +462,9 @@ func suffixIsZip64(t *testing.T, zip sizedReaderAt) bool {
|
||||||
|
|
||||||
// Zip64 is required if the total size of the records is uint32max.
|
// Zip64 is required if the total size of the records is uint32max.
|
||||||
func TestZip64LargeDirectory(t *testing.T) {
|
func TestZip64LargeDirectory(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("too slow on wasm")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping in short mode")
|
t.Skip("skipping in short mode")
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ func tooSlow(t *testing.T) {
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "android", "nacl":
|
case "android", "js", "nacl":
|
||||||
canRun = false
|
canRun = false
|
||||||
case "darwin":
|
case "darwin":
|
||||||
switch runtime.GOARCH {
|
switch runtime.GOARCH {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// 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
|
package base
|
||||||
|
|
||||||
|
|
2
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
generated
vendored
2
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch_test.go
generated
vendored
|
@ -361,7 +361,7 @@ func closedError() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHttpsInsecure(t *testing.T) {
|
func TestHttpsInsecure(t *testing.T) {
|
||||||
if runtime.GOOS == "nacl" {
|
if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
|
||||||
t.Skip("test assumes tcp available")
|
t.Skip("test assumes tcp available")
|
||||||
}
|
}
|
||||||
saveHome := os.Getenv(homeEnv())
|
saveHome := os.Getenv(homeEnv())
|
||||||
|
|
2
src/cmd/vendor/github.com/google/pprof/internal/driver/webui_test.go
generated
vendored
2
src/cmd/vendor/github.com/google/pprof/internal/driver/webui_test.go
generated
vendored
|
@ -237,7 +237,7 @@ func makeFakeProfile() *profile.Profile {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetHostAndPort(t *testing.T) {
|
func TestGetHostAndPort(t *testing.T) {
|
||||||
if runtime.GOOS == "nacl" {
|
if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
|
||||||
t.Skip("test assumes tcp available")
|
t.Skip("test assumes tcp available")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -784,7 +784,7 @@ func TestCompressedSection(t *testing.T) {
|
||||||
func TestNoSectionOverlaps(t *testing.T) {
|
func TestNoSectionOverlaps(t *testing.T) {
|
||||||
// Ensure cmd/link outputs sections without overlaps.
|
// Ensure cmd/link outputs sections without overlaps.
|
||||||
switch runtime.GOOS {
|
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)
|
t.Skipf("cmd/link doesn't produce ELF binaries on %s", runtime.GOOS)
|
||||||
}
|
}
|
||||||
_ = net.ResolveIPAddr // force dynamic linkage
|
_ = net.ResolveIPAddr // force dynamic linkage
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
@ -1130,6 +1131,9 @@ func TestBadData(t *testing.T) {
|
||||||
|
|
||||||
// TestHugeWriteFails tests that enormous messages trigger an error.
|
// TestHugeWriteFails tests that enormous messages trigger an error.
|
||||||
func TestHugeWriteFails(t *testing.T) {
|
func TestHugeWriteFails(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("out of memory on wasm")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
// Requires allocating a monster, so don't do this from all.bash.
|
// Requires allocating a monster, so don't do this from all.bash.
|
||||||
t.Skip("skipping huge allocation in short mode")
|
t.Skip("skipping huge allocation in short mode")
|
||||||
|
|
|
@ -41,7 +41,7 @@ func HasGoBuild() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "android", "nacl":
|
case "android", "nacl", "js":
|
||||||
return false
|
return false
|
||||||
case "darwin":
|
case "darwin":
|
||||||
if strings.HasPrefix(runtime.GOARCH, "arm") {
|
if strings.HasPrefix(runtime.GOARCH, "arm") {
|
||||||
|
@ -114,7 +114,7 @@ func GoTool() (string, error) {
|
||||||
// using os.StartProcess or (more commonly) exec.Command.
|
// using os.StartProcess or (more commonly) exec.Command.
|
||||||
func HasExec() bool {
|
func HasExec() bool {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "nacl":
|
case "nacl", "js":
|
||||||
return false
|
return false
|
||||||
case "darwin":
|
case "darwin":
|
||||||
if strings.HasPrefix(runtime.GOARCH, "arm") {
|
if strings.HasPrefix(runtime.GOARCH, "arm") {
|
||||||
|
@ -149,13 +149,16 @@ func MustHaveExec(t testing.TB) {
|
||||||
// HasExternalNetwork reports whether the current system can use
|
// HasExternalNetwork reports whether the current system can use
|
||||||
// external (non-localhost) networks.
|
// external (non-localhost) networks.
|
||||||
func HasExternalNetwork() bool {
|
func HasExternalNetwork() bool {
|
||||||
return !testing.Short()
|
return !testing.Short() && runtime.GOOS != "nacl" && runtime.GOOS != "js"
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustHaveExternalNetwork checks that the current system can use
|
// MustHaveExternalNetwork checks that the current system can use
|
||||||
// external (non-localhost) networks.
|
// external (non-localhost) networks.
|
||||||
// If not, MustHaveExternalNetwork calls t.Skip with an explanation.
|
// If not, MustHaveExternalNetwork calls t.Skip with an explanation.
|
||||||
func MustHaveExternalNetwork(t testing.TB) {
|
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() {
|
if testing.Short() {
|
||||||
t.Skipf("skipping test: no external network in -short mode")
|
t.Skipf("skipping test: no external network in -short mode")
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !windows,!nacl,!plan9
|
// +build !windows,!nacl,!plan9,!js
|
||||||
|
|
||||||
package syslog
|
package syslog
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ func testChanSendBarrier(useSelect bool) {
|
||||||
var globalMu sync.Mutex
|
var globalMu sync.Mutex
|
||||||
outer := 100
|
outer := 100
|
||||||
inner := 100000
|
inner := 100000
|
||||||
if testing.Short() {
|
if testing.Short() || runtime.GOARCH == "wasm" {
|
||||||
outer = 10
|
outer = 10
|
||||||
inner = 1000
|
inner = 1000
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build windows plan9 nacl
|
// +build windows plan9 nacl js,wasm
|
||||||
|
|
||||||
package runtime_test
|
package runtime_test
|
||||||
|
|
||||||
|
|
|
@ -155,6 +155,10 @@ func TestHugeGCInfo(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPeriodicGC(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.
|
// Make sure we're not in the middle of a GC.
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,9 @@ func TestSmhasherZeros(t *testing.T) {
|
||||||
|
|
||||||
// Strings with up to two nonzero bytes all have distinct hashes.
|
// Strings with up to two nonzero bytes all have distinct hashes.
|
||||||
func TestSmhasherTwoNonzero(t *testing.T) {
|
func TestSmhasherTwoNonzero(t *testing.T) {
|
||||||
|
if GOARCH == "wasm" {
|
||||||
|
t.Skip("Too slow on wasm")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("Skipping in short mode")
|
t.Skip("Skipping in short mode")
|
||||||
}
|
}
|
||||||
|
@ -229,6 +232,9 @@ func TestSmhasherCyclic(t *testing.T) {
|
||||||
|
|
||||||
// Test strings with only a few bits set
|
// Test strings with only a few bits set
|
||||||
func TestSmhasherSparse(t *testing.T) {
|
func TestSmhasherSparse(t *testing.T) {
|
||||||
|
if GOARCH == "wasm" {
|
||||||
|
t.Skip("Too slow on wasm")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("Skipping in short mode")
|
t.Skip("Skipping in short mode")
|
||||||
}
|
}
|
||||||
|
@ -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.
|
// Test all possible combinations of n blocks from the set s.
|
||||||
// "permutation" is a bad name here, but it is what Smhasher uses.
|
// "permutation" is a bad name here, but it is what Smhasher uses.
|
||||||
func TestSmhasherPermutation(t *testing.T) {
|
func TestSmhasherPermutation(t *testing.T) {
|
||||||
|
if GOARCH == "wasm" {
|
||||||
|
t.Skip("Too slow on wasm")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("Skipping in short mode")
|
t.Skip("Skipping in short mode")
|
||||||
}
|
}
|
||||||
|
@ -433,6 +442,9 @@ func (k *IfaceKey) name() string {
|
||||||
|
|
||||||
// Flipping a single bit of a key should flip each output bit with 50% probability.
|
// Flipping a single bit of a key should flip each output bit with 50% probability.
|
||||||
func TestSmhasherAvalanche(t *testing.T) {
|
func TestSmhasherAvalanche(t *testing.T) {
|
||||||
|
if GOARCH == "wasm" {
|
||||||
|
t.Skip("Too slow on wasm")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("Skipping in short mode")
|
t.Skip("Skipping in short mode")
|
||||||
}
|
}
|
||||||
|
@ -508,6 +520,9 @@ func TestSmhasherWindowed(t *testing.T) {
|
||||||
windowed(t, &BytesKey{make([]byte, 128)})
|
windowed(t, &BytesKey{make([]byte, 128)})
|
||||||
}
|
}
|
||||||
func windowed(t *testing.T, k Key) {
|
func windowed(t *testing.T, k Key) {
|
||||||
|
if GOARCH == "wasm" {
|
||||||
|
t.Skip("Too slow on wasm")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("Skipping in short mode")
|
t.Skip("Skipping in short mode")
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
|
|
||||||
package pprof
|
package pprof
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ func perpetuumMobile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStopTheWorldDeadlock(t *testing.T) {
|
func TestStopTheWorldDeadlock(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("no preemption on wasm yet")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping during short test")
|
t.Skip("skipping during short test")
|
||||||
}
|
}
|
||||||
|
@ -230,6 +233,10 @@ func TestBlockLocked(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTimerFairness(t *testing.T) {
|
func TestTimerFairness(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("no preemption on wasm yet")
|
||||||
|
}
|
||||||
|
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
c := make(chan bool)
|
c := make(chan bool)
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
|
@ -256,6 +263,10 @@ func TestTimerFairness(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTimerFairness2(t *testing.T) {
|
func TestTimerFairness2(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("no preemption on wasm yet")
|
||||||
|
}
|
||||||
|
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
c := make(chan bool)
|
c := make(chan bool)
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
|
@ -290,6 +301,10 @@ var preempt = func() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPreemption(t *testing.T) {
|
func TestPreemption(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("no preemption on wasm yet")
|
||||||
|
}
|
||||||
|
|
||||||
// Test that goroutines are preempted at function calls.
|
// Test that goroutines are preempted at function calls.
|
||||||
N := 5
|
N := 5
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
|
@ -313,6 +328,10 @@ func TestPreemption(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPreemptionGC(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.
|
// Test that pending GC preempts running goroutines.
|
||||||
P := 5
|
P := 5
|
||||||
N := 10
|
N := 10
|
||||||
|
@ -385,6 +404,9 @@ func TestNumGoroutine(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPingPongHog(t *testing.T) {
|
func TestPingPongHog(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("no preemption on wasm yet")
|
||||||
|
}
|
||||||
if testing.Short() {
|
if testing.Short() {
|
||||||
t.Skip("skipping in -short mode")
|
t.Skip("skipping in -short mode")
|
||||||
}
|
}
|
||||||
|
@ -834,6 +856,10 @@ func TestStealOrder(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLockOSThreadNesting(t *testing.T) {
|
func TestLockOSThreadNesting(t *testing.T) {
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
t.Skip("no threads on wasm yet")
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
e, i := runtime.LockOSCounts()
|
e, i := runtime.LockOSCounts()
|
||||||
if e != 0 || i != 0 {
|
if e != 0 || i != 0 {
|
||||||
|
|
|
@ -169,6 +169,9 @@ func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) {
|
||||||
if GOOS == "nacl" {
|
if GOOS == "nacl" {
|
||||||
t.Skip("nacl doesn't seem to fault on high addresses")
|
t.Skip("nacl doesn't seem to fault on high addresses")
|
||||||
}
|
}
|
||||||
|
if GOOS == "js" {
|
||||||
|
t.Skip("js does not support catching faults")
|
||||||
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
|
@ -264,7 +267,7 @@ func TestTrailingZero(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBadOpen(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")
|
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
|
// make sure we get the correct error code if open fails. Same for
|
||||||
|
|
|
@ -47,6 +47,9 @@ func doTestParallelReaders(numReaders int) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestParallelRWMutexReaders(t *testing.T) {
|
func TestParallelRWMutexReaders(t *testing.T) {
|
||||||
|
if GOARCH == "wasm" {
|
||||||
|
t.Skip("wasm has no threads yet")
|
||||||
|
}
|
||||||
defer GOMAXPROCS(GOMAXPROCS(-1))
|
defer GOMAXPROCS(GOMAXPROCS(-1))
|
||||||
// If runtime triggers a forced GC during this test then it will deadlock,
|
// If runtime triggers a forced GC during this test then it will deadlock,
|
||||||
// since the goroutines can't be stopped/preempted.
|
// since the goroutines can't be stopped/preempted.
|
||||||
|
|
|
@ -76,6 +76,10 @@ func TestStackMem(t *testing.T) {
|
||||||
|
|
||||||
// Test stack growing in different contexts.
|
// Test stack growing in different contexts.
|
||||||
func TestStackGrowth(t *testing.T) {
|
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
|
// Don't make this test parallel as this makes the 20 second
|
||||||
// timeout unreliable on slow builders. (See issue #19381.)
|
// timeout unreliable on slow builders. (See issue #19381.)
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,8 @@ func TestExecErrPermutedFds(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGettimeofday(t *testing.T) {
|
func TestGettimeofday(t *testing.T) {
|
||||||
if runtime.GOOS == "nacl" {
|
if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
|
||||||
t.Skip("not implemented on nacl")
|
t.Skip("not implemented on " + runtime.GOOS)
|
||||||
}
|
}
|
||||||
tv := &syscall.Timeval{}
|
tv := &syscall.Timeval{}
|
||||||
if err := syscall.Gettimeofday(tv); err != nil {
|
if err := syscall.Gettimeofday(tv); err != nil {
|
||||||
|
|
|
@ -19,7 +19,14 @@ import (
|
||||||
// templates. This limit is only practically reached by accidentally
|
// templates. This limit is only practically reached by accidentally
|
||||||
// recursive template invocations. This limit allows us to return
|
// recursive template invocations. This limit allows us to return
|
||||||
// an error instead of triggering a stack overflow.
|
// 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
|
// state represents the state of an execution. It's not part of the
|
||||||
// template so that multiple executions of the same template
|
// template so that multiple executions of the same template
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl,!plan9,!windows
|
// +build !nacl,!js,!plan9,!windows
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2010 The Go Authors. All rights reserved.
|
// Copyright 2010 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl,!plan9,!windows
|
// +build !nacl,!js,!plan9,!windows
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl,!windows
|
// +build !nacl,!js,!windows
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -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
|
// buildrun -t 10 -gcflags=-d=ssa/insert_resched_checks/on,ssa/check/on
|
||||||
|
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
// doesn't go into the Go runtime.
|
// doesn't go into the Go runtime.
|
||||||
// +build !windows
|
// +build !windows
|
||||||
|
|
||||||
|
// wasm does not work, because the linear memory is not executable.
|
||||||
|
// +build !wasm
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl,!android,!darwin darwin,!arm
|
// +build !nacl,!js,!android,!darwin darwin,!arm
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl,!android
|
// +build !nacl,!js,!android
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// run
|
// run
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
|
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// run
|
// run
|
||||||
|
// +build !js
|
||||||
|
|
||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2017 The Go Authors. All rights reserved.
|
// Copyright 2017 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if runtime.Compiler != "gc" || runtime.GOOS == "nacl" {
|
if runtime.Compiler != "gc" || runtime.GOOS == "nacl" || runtime.GOOS == "js" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if runtime.GOOS == "nacl" {
|
if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
|
||||||
return // no file system available on builders
|
return // no file system available on builders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,8 @@ var tests = []struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if runtime.GOOS == "nacl" {
|
if runtime.GOOS == "nacl" || runtime.GOOS == "js" {
|
||||||
return // no file system available on builders
|
return // can not exec go tool
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := ioutil.TempFile("", "issue22662b.go")
|
f, err := ioutil.TempFile("", "issue22662b.go")
|
||||||
|
|
|
@ -16,7 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if runtime.Compiler != "gc" || runtime.GOOS == "nacl" {
|
if runtime.Compiler != "gc" || runtime.GOOS == "nacl" || runtime.GOOS == "js" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// terribly slow on wasm
|
||||||
|
// +build !wasm
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2011 The Go Authors. All rights reserved.
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2016 The Go Authors. All rights reserved.
|
// Copyright 2016 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// errorcheck -0 -m -live
|
// errorcheck -0 -m -live
|
||||||
|
|
||||||
// +build !windows
|
// +build !windows,!js
|
||||||
|
|
||||||
// Copyright 2015 The Go Authors. All rights reserved.
|
// Copyright 2015 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// errorcheck -0 -d=nil
|
// errorcheck -0 -d=nil
|
||||||
|
|
||||||
|
// +build !wasm
|
||||||
|
|
||||||
// Copyright 2013 The Go Authors. All rights reserved.
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
270
test/nilptr3_wasm.go
Normal file
270
test/nilptr3_wasm.go
Normal file
|
@ -0,0 +1,270 @@
|
||||||
|
// errorcheck -0 -d=nil
|
||||||
|
|
||||||
|
// +build wasm
|
||||||
|
|
||||||
|
// Copyright 2013 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// Test that nil checks are removed.
|
||||||
|
// Optimization is enabled.
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
type Struct struct {
|
||||||
|
X int
|
||||||
|
Y float64
|
||||||
|
}
|
||||||
|
|
||||||
|
type BigStruct struct {
|
||||||
|
X int
|
||||||
|
Y float64
|
||||||
|
A [1 << 20]int
|
||||||
|
Z string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Empty struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
type Empty1 struct {
|
||||||
|
Empty
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
intp *int
|
||||||
|
arrayp *[10]int
|
||||||
|
array0p *[0]int
|
||||||
|
bigarrayp *[1 << 26]int
|
||||||
|
structp *Struct
|
||||||
|
bigstructp *BigStruct
|
||||||
|
emptyp *Empty
|
||||||
|
empty1p *Empty1
|
||||||
|
)
|
||||||
|
|
||||||
|
func f1() {
|
||||||
|
_ = *intp // ERROR "generated nil check"
|
||||||
|
|
||||||
|
// This one should be removed but the block copy needs
|
||||||
|
// to be turned into its own pseudo-op in order to see
|
||||||
|
// the indirect.
|
||||||
|
_ = *arrayp // ERROR "generated nil check"
|
||||||
|
|
||||||
|
// 0-byte indirect doesn't suffice.
|
||||||
|
// we don't registerize globals, so there are no removed.* nil checks.
|
||||||
|
_ = *array0p // ERROR "generated nil check"
|
||||||
|
_ = *array0p // ERROR "removed nil check"
|
||||||
|
|
||||||
|
_ = *intp // ERROR "removed nil check"
|
||||||
|
_ = *arrayp // ERROR "removed nil check"
|
||||||
|
_ = *structp // ERROR "generated nil check"
|
||||||
|
_ = *emptyp // ERROR "generated nil check"
|
||||||
|
_ = *arrayp // ERROR "removed nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func f2() {
|
||||||
|
var (
|
||||||
|
intp *int
|
||||||
|
arrayp *[10]int
|
||||||
|
array0p *[0]int
|
||||||
|
bigarrayp *[1 << 20]int
|
||||||
|
structp *Struct
|
||||||
|
bigstructp *BigStruct
|
||||||
|
emptyp *Empty
|
||||||
|
empty1p *Empty1
|
||||||
|
)
|
||||||
|
|
||||||
|
_ = *intp // ERROR "generated nil check"
|
||||||
|
_ = *arrayp // ERROR "generated nil check"
|
||||||
|
_ = *array0p // ERROR "generated nil check"
|
||||||
|
_ = *array0p // ERROR "removed.* nil check"
|
||||||
|
_ = *intp // ERROR "removed.* nil check"
|
||||||
|
_ = *arrayp // ERROR "removed.* nil check"
|
||||||
|
_ = *structp // ERROR "generated nil check"
|
||||||
|
_ = *emptyp // ERROR "generated nil check"
|
||||||
|
_ = *arrayp // ERROR "removed.* nil check"
|
||||||
|
_ = *bigarrayp // ERROR "generated nil check" ARM removed nil check before indirect!!
|
||||||
|
_ = *bigstructp // ERROR "generated nil check"
|
||||||
|
_ = *empty1p // ERROR "generated nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func fx10k() *[10000]int
|
||||||
|
|
||||||
|
var b bool
|
||||||
|
|
||||||
|
func f3(x *[10000]int) {
|
||||||
|
// Using a huge type and huge offsets so the compiler
|
||||||
|
// does not expect the memory hardware to fault.
|
||||||
|
_ = x[9999] // ERROR "generated nil check"
|
||||||
|
|
||||||
|
for {
|
||||||
|
if x[9999] != 0 { // ERROR "removed nil check"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x = fx10k()
|
||||||
|
_ = x[9999] // ERROR "generated nil check"
|
||||||
|
if b {
|
||||||
|
_ = x[9999] // ERROR "removed.* nil check"
|
||||||
|
} else {
|
||||||
|
_ = x[9999] // ERROR "removed.* nil check"
|
||||||
|
}
|
||||||
|
_ = x[9999] // ERROR "removed nil check"
|
||||||
|
|
||||||
|
x = fx10k()
|
||||||
|
if b {
|
||||||
|
_ = x[9999] // ERROR "generated nil check"
|
||||||
|
} else {
|
||||||
|
_ = x[9999] // ERROR "generated nil check"
|
||||||
|
}
|
||||||
|
_ = x[9999] // ERROR "generated nil check"
|
||||||
|
|
||||||
|
fx10k()
|
||||||
|
// This one is a bit redundant, if we figured out that
|
||||||
|
// x wasn't going to change across the function call.
|
||||||
|
// But it's a little complex to do and in practice doesn't
|
||||||
|
// matter enough.
|
||||||
|
_ = x[9999] // ERROR "removed nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func f3a() {
|
||||||
|
x := fx10k()
|
||||||
|
y := fx10k()
|
||||||
|
z := fx10k()
|
||||||
|
_ = &x[9] // ERROR "generated nil check"
|
||||||
|
y = z
|
||||||
|
_ = &x[9] // ERROR "removed.* nil check"
|
||||||
|
x = y
|
||||||
|
_ = &x[9] // ERROR "generated nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func f3b() {
|
||||||
|
x := fx10k()
|
||||||
|
y := fx10k()
|
||||||
|
_ = &x[9] // ERROR "generated nil check"
|
||||||
|
y = x
|
||||||
|
_ = &x[9] // ERROR "removed.* nil check"
|
||||||
|
x = y
|
||||||
|
_ = &x[9] // ERROR "removed.* nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func fx10() *[10]int
|
||||||
|
|
||||||
|
func f4(x *[10]int) {
|
||||||
|
// Most of these have no checks because a real memory reference follows,
|
||||||
|
// and the offset is small enough that if x is nil, the address will still be
|
||||||
|
// in the first unmapped page of memory.
|
||||||
|
|
||||||
|
_ = x[9] // ERROR "generated nil check" // bug: would like to remove this check (but nilcheck and load are in different blocks)
|
||||||
|
|
||||||
|
for {
|
||||||
|
if x[9] != 0 { // ERROR "removed nil check"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x = fx10()
|
||||||
|
_ = x[9] // ERROR "generated nil check" // bug would like to remove before indirect
|
||||||
|
if b {
|
||||||
|
_ = x[9] // ERROR "removed nil check"
|
||||||
|
} else {
|
||||||
|
_ = x[9] // ERROR "removed nil check"
|
||||||
|
}
|
||||||
|
_ = x[9] // ERROR "removed nil check"
|
||||||
|
|
||||||
|
x = fx10()
|
||||||
|
if b {
|
||||||
|
_ = x[9] // ERROR "generated nil check" // bug would like to remove before indirect
|
||||||
|
} else {
|
||||||
|
_ = &x[9] // ERROR "generated nil check"
|
||||||
|
}
|
||||||
|
_ = x[9] // ERROR "generated nil check" // bug would like to remove before indirect
|
||||||
|
|
||||||
|
fx10()
|
||||||
|
_ = x[9] // ERROR "removed nil check"
|
||||||
|
|
||||||
|
x = fx10()
|
||||||
|
y := fx10()
|
||||||
|
_ = &x[9] // ERROR "generated nil check"
|
||||||
|
y = x
|
||||||
|
_ = &x[9] // ERROR "removed[a-z ]* nil check"
|
||||||
|
x = y
|
||||||
|
_ = &x[9] // ERROR "removed[a-z ]* nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func f5(p *float32, q *float64, r *float32, s *float64) float64 {
|
||||||
|
x := float64(*p) // ERROR "generated nil check"
|
||||||
|
y := *q // ERROR "generated nil check"
|
||||||
|
*r = 7 // ERROR "generated nil check"
|
||||||
|
*s = 9 // ERROR "generated nil check"
|
||||||
|
return x + y
|
||||||
|
}
|
||||||
|
|
||||||
|
type T [29]byte
|
||||||
|
|
||||||
|
func f6(p, q *T) {
|
||||||
|
x := *p // ERROR "generated nil check"
|
||||||
|
*q = x // ERROR "generated nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func m1(m map[int][80]byte) byte {
|
||||||
|
v := m[3] // ERROR "removed nil check"
|
||||||
|
return v[5]
|
||||||
|
}
|
||||||
|
func m2(m map[int][800]byte) byte {
|
||||||
|
v := m[3] // ERROR "removed nil check"
|
||||||
|
return v[5]
|
||||||
|
}
|
||||||
|
func m3(m map[int][80]byte) (byte, bool) {
|
||||||
|
v, ok := m[3] // ERROR "removed nil check"
|
||||||
|
return v[5], ok
|
||||||
|
}
|
||||||
|
func m4(m map[int][800]byte) (byte, bool) {
|
||||||
|
v, ok := m[3] // ERROR "removed nil check"
|
||||||
|
return v[5], ok
|
||||||
|
}
|
||||||
|
func p1() byte {
|
||||||
|
p := new([100]byte)
|
||||||
|
return p[5] // ERROR "removed nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure not to do nil check for access of PAUTOHEAP
|
||||||
|
//go:noinline
|
||||||
|
func (p *Struct) m() {}
|
||||||
|
func c1() {
|
||||||
|
var x Struct
|
||||||
|
func() { x.m() }() // ERROR "removed nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
type SS struct {
|
||||||
|
x byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type TT struct {
|
||||||
|
SS
|
||||||
|
}
|
||||||
|
|
||||||
|
func f(t *TT) *byte {
|
||||||
|
// See issue 17242.
|
||||||
|
s := &t.SS // ERROR "removed nil check"
|
||||||
|
return &s.x // ERROR "generated nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure not to do nil check for newobject
|
||||||
|
func f7() (*Struct, float64) {
|
||||||
|
t := new(Struct)
|
||||||
|
p := &t.Y // ERROR "removed nil check"
|
||||||
|
return t, *p // ERROR "removed nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure to remove nil check for memory move (issue #18003)
|
||||||
|
func f8(t *[8]int) [8]int {
|
||||||
|
return *t // ERROR "generated nil check"
|
||||||
|
}
|
||||||
|
|
||||||
|
func f9() []int {
|
||||||
|
x := new([1]int)
|
||||||
|
x[0] = 1 // ERROR "removed nil check"
|
||||||
|
y := x[:] // ERROR "removed nil check"
|
||||||
|
return y
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "runtime"
|
||||||
|
|
||||||
type Number *Number
|
type Number *Number
|
||||||
|
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
@ -116,7 +118,11 @@ var results = [...]int{
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
for i := 0; i <= 9; i++ {
|
max := 9
|
||||||
|
if runtime.GOARCH == "wasm" {
|
||||||
|
max = 7 // stack size is limited
|
||||||
|
}
|
||||||
|
for i := 0; i <= max; i++ {
|
||||||
if f := count(fact(gen(i))); f != results[i] {
|
if f := count(fact(gen(i))); f != results[i] {
|
||||||
println("FAIL:", i, "!:", f, "!=", results[i])
|
println("FAIL:", i, "!:", f, "!=", results[i])
|
||||||
panic(0)
|
panic(0)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// +build !nacl
|
// +build !nacl,!js
|
||||||
// run
|
// run
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
|
|
Loading…
Reference in a new issue