]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: add wasip1 support
authorJohan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Sat, 25 Mar 2023 15:50:19 +0000 (08:50 -0700)
committerJohan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Thu, 6 Apr 2023 22:37:50 +0000 (22:37 +0000)
For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I530ea78a3cd142f3a745f650b21c30e7f10ce981
Reviewed-on: https://go-review.googlesource.com/c/go/+/479621
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/compile/internal/types2/example_test.go
src/cmd/dist/test.go
src/cmd/go/internal/base/signal_unix.go
src/cmd/go/internal/cache/cache_test.go
src/cmd/go/internal/lockedfile/internal/filelock/filelock_test.go
src/cmd/go/internal/lockedfile/lockedfile_test.go
src/cmd/go/internal/lockedfile/transform_test.go
src/cmd/go/internal/mmap/mmap_other.go
src/cmd/go/internal/work/build_test.go
src/cmd/internal/osinfo/os_wasip1.go [new file with mode: 0644]
src/cmd/test2json/signal_unix.go

index 9ff7d0cfa2e0d94e04332257ac5c782c48de2107..3fcad04b775a1eecefb3877906833b64dbe19795 100644 (file)
@@ -5,7 +5,7 @@
 // Only run where builders (build.golang.org) have
 // access to compiled packages for import.
 //
-//go:build !android && !ios && !js
+//go:build !android && !ios && !js && !wasip1
 
 package types2_test
 
index fa03068350df26d6990eb0e90e7324e623de0e49..01452ba7e57d838c233d08a7ef302f4d5dfc78ae 100644 (file)
@@ -675,7 +675,7 @@ func (t *tester) registerTests() {
        }
 
        // Runtime CPU tests.
-       if !t.compileOnly && goos != "js" { // js can't handle -cpu != 1
+       if !t.compileOnly && t.hasParallelism() {
                t.registerTest("runtime:cpu124", "GOMAXPROCS=2 runtime -cpu=1,2,4 -quick",
                        &goTest{
                                timeout:   300 * time.Second,
@@ -737,9 +737,9 @@ func (t *tester) registerTests() {
        // On the builders only, test that a moved GOROOT still works.
        // Fails on iOS because CC_FOR_TARGET refers to clangwrap.sh
        // in the unmoved GOROOT.
-       // Fails on Android and js/wasm with an exec format error.
+       // Fails on Android, js/wasm and wasip1/wasm with an exec format error.
        // Fails on plan9 with "cannot find GOROOT" (issue #21016).
-       if os.Getenv("GO_BUILDER_NAME") != "" && goos != "android" && !t.iOS() && goos != "plan9" && goos != "js" {
+       if os.Getenv("GO_BUILDER_NAME") != "" && goos != "android" && !t.iOS() && goos != "plan9" && goos != "js" && goos != "wasip1" {
                t.tests = append(t.tests, distTest{
                        name:    "moved_goroot",
                        heading: "moved GOROOT",
@@ -835,7 +835,7 @@ func (t *tester) registerTests() {
        }
 
        // sync tests
-       if goos != "js" { // js doesn't support -cpu=10
+       if t.hasParallelism() {
                t.registerTest("sync_cpu", "sync -cpu=10",
                        &goTest{
                                timeout: 120 * time.Second,
@@ -1476,6 +1476,14 @@ func (t *tester) hasSwig() bool {
        return true
 }
 
+func (t *tester) hasParallelism() bool {
+       switch goos {
+       case "js", "wasip1":
+               return false
+       }
+       return true
+}
+
 func (t *tester) raceDetectorSupported() bool {
        if gohostos != goos {
                return false
index f198df6abcdbc54ffee75fd2ff7d32cde43517de..0905971932606911be61e82a084f863e2e65982c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build unix || js
+//go:build unix || js || wasip1
 
 package base
 
index 5527d444bbab6470fcd2518633056a0c8f94e8bb..36c73331c5b1f31678ebbfb77bdf6c24719161b5 100644 (file)
@@ -8,7 +8,6 @@ import (
        "bytes"
        "encoding/binary"
        "fmt"
-       "internal/testenv"
        "os"
        "path/filepath"
        "runtime"
@@ -152,8 +151,8 @@ func dummyID(x int) [HashSize]byte {
 }
 
 func TestCacheTrim(t *testing.T) {
-       if runtime.GOOS == "js" {
-               testenv.SkipFlaky(t, 35220)
+       if runtime.GOOS == "js" || runtime.GOOS == "wasip1" {
+               t.Skip("file lock is unsupported on +" + runtime.GOOS)
        }
 
        dir, err := os.MkdirTemp("", "cachetest-")
index 8e2c6ab4ce2ed30a44f43e38351bed1c856d3f26..d32bf06160572c23d10e96336804d191e1b5ccb1 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !js && !plan9
+//go:build !js && !plan9 && !wasip1
 
 package filelock_test
 
index 6b54654ac72e444931c42d03de2e688040befe50..8dea8f70c2619fd1d71e4cce846539354c89ddd8 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// js does not support inter-process file locking.
+// js and wasip1 do not support inter-process file locking.
 //
-//go:build !js
+//go:build !js && !wasip1
 
 package lockedfile_test
 
index 833cbf787958c4abd14bad040f9e0d4eb03397d2..f8b28024042594eed75abe6f0ba6b2a5b5eda006 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// js does not support inter-process file locking.
+// js and wasip1 do not support inter-process file locking.
 //
-//go:build !js
+//go:build !js && !wasip1
 
 package lockedfile_test
 
index d146a4221649490d6541cff87e00d2c44839226d..22e9395b2160c8aacf22f8aec34b7e42a9332f65 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build (js && wasm) || plan9
+//go:build (js && wasm) || wasip1 || plan9
 
 package mmap
 
index b9c16eea74b5f4a12ded9379c555092603a08ff8..91648a31a7043a68b4fbc15f3938948881b9f032 100644 (file)
@@ -6,6 +6,7 @@ package work
 
 import (
        "fmt"
+       "internal/testenv"
        "io/fs"
        "os"
        "path/filepath"
@@ -221,13 +222,6 @@ func pkgImportPath(pkgpath string) *load.Package {
 // directory.
 // See https://golang.org/issue/18878.
 func TestRespectSetgidDir(t *testing.T) {
-       switch runtime.GOOS {
-       case "ios":
-               t.Skip("can't set SetGID bit with chmod on iOS")
-       case "windows", "plan9":
-               t.Skip("chown/chmod setgid are not supported on Windows or Plan 9")
-       }
-
        var b Builder
 
        // Check that `cp` is called instead of `mv` by looking at the output
@@ -250,12 +244,23 @@ func TestRespectSetgidDir(t *testing.T) {
        // the new temporary directory.
        err = os.Chown(setgiddir, os.Getuid(), os.Getgid())
        if err != nil {
+               if testenv.SyscallIsNotSupported(err) {
+                       t.Skip("skipping: chown is not supported on " + runtime.GOOS)
+               }
                t.Fatal(err)
        }
 
        // Change setgiddir's permissions to include the SetGID bit.
        if err := os.Chmod(setgiddir, 0755|fs.ModeSetgid); err != nil {
+               if testenv.SyscallIsNotSupported(err) {
+                       t.Skip("skipping: chmod is not supported on " + runtime.GOOS)
+               }
+               t.Fatal(err)
+       }
+       if fi, err := os.Stat(setgiddir); err != nil {
                t.Fatal(err)
+       } else if fi.Mode()&fs.ModeSetgid == 0 {
+               t.Skip("skipping: Chmod ignored ModeSetgid on " + runtime.GOOS)
        }
 
        pkgfile, err := os.CreateTemp("", "pkgfile")
diff --git a/src/cmd/internal/osinfo/os_wasip1.go b/src/cmd/internal/osinfo/os_wasip1.go
new file mode 100644 (file)
index 0000000..7295bb2
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2023 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.
+
+//go:build wasip1
+
+package osinfo
+
+import (
+       "errors"
+       "fmt"
+)
+
+// Version returns the OS version name/number.
+func Version() (string, error) {
+       return "", fmt.Errorf("unable to determine OS version: %w", errors.ErrUnsupported)
+}
index ed5ca7e42f4f4c832fa81a1a47ebd58ffc9602f6..2b4e44cb91a67a6e4aac765f596fcd7c13279e2c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build unix || js
+//go:build unix || js || wasip1
 
 package main