]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix TestMkdirAllAtSlash on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Mon, 2 Feb 2015 16:40:47 +0000 (17:40 +0100)
committerDavid du Colombier <0intro@gmail.com>
Mon, 2 Feb 2015 17:01:45 +0000 (17:01 +0000)
Since CL 3676, the TestMkdirAllAtSlash test
depends on syscall.EROFS, which isn't defined
on Plan 9.

This change works around this issue by
defining a system dependent isReadonlyError
function.

Change-Id: If972fd2fe4828ee3bcb8537ea7f4ba29f7a87619
Reviewed-on: https://go-review.googlesource.com/3696
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/os/os_unix_test.go
src/os/path_test.go

index 21d40ccaf848c9b8cfe50a61008a3b0c88afe910..afee189650c0cc3afb7532cecdf90179b9b43b48 100644 (file)
@@ -13,6 +13,10 @@ import (
        "testing"
 )
 
+func init() {
+       isReadonlyError = func(err error) bool { return err == syscall.EROFS }
+}
+
 func checkUidGid(t *testing.T, path string, uid, gid int) {
        dir, err := Stat(path)
        if err != nil {
index 7252e870ce2af25650b2fb9eed8ae5f71c1b6890..66ed49b6fd33ac10425cf1a8074fe604d81af98e 100644 (file)
@@ -13,6 +13,8 @@ import (
        "testing"
 )
 
+var isReadonlyError = func(error) bool { return false }
+
 func TestMkdirAll(t *testing.T) {
        tmpDir := TempDir()
        path := tmpDir + "/_TestMkdirAll_/dir/./dir2"
@@ -212,7 +214,7 @@ func TestMkdirAllAtSlash(t *testing.T) {
        if err != nil {
                pathErr, ok := err.(*PathError)
                // common for users not to be able to write to /
-               if ok && (pathErr.Err == syscall.EACCES || pathErr.Err == syscall.EROFS) {
+               if ok && (pathErr.Err == syscall.EACCES || isReadonlyError(pathErr.Err)) {
                        t.Skipf("could not create %v: %v", dir, err)
                }
                t.Fatalf(`MkdirAll "/_go_os_test/dir": %v`, err)