Commit 04b83988 authored by Tobias Klauser's avatar Tobias Klauser Committed by Tobias Klauser

unix: fix or skip failing tests on android and iOS

The mkfifo syscall is disallowed on android and iOS. sched_setaffinity
is disallowed on android. Skip all tests which use them.

/usr/bin does not exist on android. Use /system/bin in TestGetwd
instead, like TestChdirAndGetwd in the os package.

Like linux, android does not support Fchmodat with flags != 0. Adjust
TestFchmodat accordingly.

TestDevices might stat some device files which are not accessible, skip
those.

iOS cannot exec subprocesses, thus skip TestPassFD.

Fixes golang/go#25535

Change-Id: Ic764b9152f0a7b703ad4f47fdb1a9a5e94718154
Reviewed-on: https://go-review.googlesource.com/114395
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent e2c7578a
...@@ -33,6 +33,9 @@ func TestDevices(t *testing.T) { ...@@ -33,6 +33,9 @@ func TestDevices(t *testing.T) {
var stat unix.Stat_t var stat unix.Stat_t
err := unix.Stat(tc.path, &stat) err := unix.Stat(tc.path, &stat)
if err != nil { if err != nil {
if err == unix.EACCES {
t.Skip("no permission to stat device, skipping test")
}
t.Errorf("failed to stat device: %v", err) t.Errorf("failed to stat device: %v", err)
return return
} }
......
...@@ -32,6 +32,10 @@ func TestIoctlGetInt(t *testing.T) { ...@@ -32,6 +32,10 @@ func TestIoctlGetInt(t *testing.T) {
} }
func TestPpoll(t *testing.T) { func TestPpoll(t *testing.T) {
if runtime.GOOS == "android" {
t.Skip("mkfifo syscall is not available on android, skipping test")
}
f, cleanup := mktmpfifo(t) f, cleanup := mktmpfifo(t)
defer cleanup() defer cleanup()
...@@ -259,6 +263,9 @@ func TestSchedSetaffinity(t *testing.T) { ...@@ -259,6 +263,9 @@ func TestSchedSetaffinity(t *testing.T) {
if runtime.NumCPU() < 2 { if runtime.NumCPU() < 2 {
t.Skip("skipping setaffinity tests on single CPU system") t.Skip("skipping setaffinity tests on single CPU system")
} }
if runtime.GOOS == "android" {
t.Skip("skipping setaffinity tests on android")
}
err = unix.SchedSetaffinity(0, &newMask) err = unix.SchedSetaffinity(0, &newMask)
if err != nil { if err != nil {
......
...@@ -125,6 +125,10 @@ func TestFcntlFlock(t *testing.T) { ...@@ -125,6 +125,10 @@ func TestFcntlFlock(t *testing.T) {
// "-test.run=^TestPassFD$" and an environment variable used to signal // "-test.run=^TestPassFD$" and an environment variable used to signal
// that the test should become the child process instead. // that the test should become the child process instead.
func TestPassFD(t *testing.T) { func TestPassFD(t *testing.T) {
if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
t.Skip("cannot exec subprocess on iOS, skipping test")
}
if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" {
passFDChild() passFDChild()
return return
...@@ -390,6 +394,11 @@ func TestDup(t *testing.T) { ...@@ -390,6 +394,11 @@ func TestDup(t *testing.T) {
} }
func TestPoll(t *testing.T) { func TestPoll(t *testing.T) {
if runtime.GOOS == "android" ||
(runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64")) {
t.Skip("mkfifo syscall is not available on android and iOS, skipping test")
}
f, cleanup := mktmpfifo(t) f, cleanup := mktmpfifo(t)
defer cleanup() defer cleanup()
...@@ -426,7 +435,10 @@ func TestGetwd(t *testing.T) { ...@@ -426,7 +435,10 @@ func TestGetwd(t *testing.T) {
// These are chosen carefully not to be symlinks on a Mac // These are chosen carefully not to be symlinks on a Mac
// (unlike, say, /var, /etc) // (unlike, say, /var, /etc)
dirs := []string{"/", "/usr/bin"} dirs := []string{"/", "/usr/bin"}
if runtime.GOOS == "darwin" { switch runtime.GOOS {
case "android":
dirs = []string{"/", "/system/bin"}
case "darwin":
switch runtime.GOARCH { switch runtime.GOARCH {
case "arm", "arm64": case "arm", "arm64":
d1, err := ioutil.TempDir("", "d1") d1, err := ioutil.TempDir("", "d1")
...@@ -534,7 +546,7 @@ func TestFchmodat(t *testing.T) { ...@@ -534,7 +546,7 @@ func TestFchmodat(t *testing.T) {
didChmodSymlink := true didChmodSymlink := true
err = unix.Fchmodat(unix.AT_FDCWD, "symlink1", uint32(mode), unix.AT_SYMLINK_NOFOLLOW) err = unix.Fchmodat(unix.AT_FDCWD, "symlink1", uint32(mode), unix.AT_SYMLINK_NOFOLLOW)
if err != nil { if err != nil {
if (runtime.GOOS == "linux" || runtime.GOOS == "solaris") && err == unix.EOPNOTSUPP { if (runtime.GOOS == "android" || runtime.GOOS == "linux" || runtime.GOOS == "solaris") && err == unix.EOPNOTSUPP {
// Linux and Illumos don't support flags != 0 // Linux and Illumos don't support flags != 0
didChmodSymlink = false didChmodSymlink = false
} else { } else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment