aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/internal/go_templates/testenv/testenv_notwin.go
diff options
context:
space:
mode:
Diffstat (limited to 'tpl/internal/go_templates/testenv/testenv_notwin.go')
-rw-r--r--tpl/internal/go_templates/testenv/testenv_notwin.go28
1 files changed, 27 insertions, 1 deletions
diff --git a/tpl/internal/go_templates/testenv/testenv_notwin.go b/tpl/internal/go_templates/testenv/testenv_notwin.go
index 81171fd19..30e159a6e 100644
--- a/tpl/internal/go_templates/testenv/testenv_notwin.go
+++ b/tpl/internal/go_templates/testenv/testenv_notwin.go
@@ -7,13 +7,39 @@
package testenv
import (
+ "fmt"
+ "os"
+ "path/filepath"
"runtime"
)
func hasSymlink() (ok bool, reason string) {
switch runtime.GOOS {
- case "android", "plan9":
+ case "plan9":
return false, ""
+ case "android", "wasip1":
+ // For wasip1, some runtimes forbid absolute symlinks,
+ // or symlinks that escape the current working directory.
+ // Perform a simple test to see whether the runtime
+ // supports symlinks or not. If we get a permission
+ // error, the runtime does not support symlinks.
+ dir, err := os.MkdirTemp("", "")
+ if err != nil {
+ return false, ""
+ }
+ defer func() {
+ _ = os.RemoveAll(dir)
+ }()
+ fpath := filepath.Join(dir, "testfile.txt")
+ if err := os.WriteFile(fpath, nil, 0644); err != nil {
+ return false, ""
+ }
+ if err := os.Symlink(fpath, filepath.Join(dir, "testlink")); err != nil {
+ if SyscallIsNotSupported(err) {
+ return false, fmt.Sprintf("symlinks unsupported: %s", err.Error())
+ }
+ return false, ""
+ }
}
return true, ""