Commit 187cccbd authored by David du Colombier's avatar David du Colombier

os: fix TestMkdirAllAtSlash on Plan 9

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/3696Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 3bf005ce
......@@ -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 {
......
......@@ -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)
......
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