unix: fix TestFchmodat on Illumos

On Illumos, TestFchmodat fails with:

--- FAIL: TestFchmodat (0.00s)
        syscall_unix_test.go:502: Fchmodat: unexpected error: operation not supported on transport endpoint

Like Linux, Illumos doesn't support flags != 0 in Fchmodat, see
https://illumos.org/man/2/chmod

Adjust TestFchmodat accordingly to handle EOPNOTSUPP on Illumos.

Change-Id: Icd4564497a41c4aa962cd76604b5ca2c7575d96c
Reviewed-on: https://go-review.googlesource.com/101775
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Tobias Klauser
2018-03-21 07:56:37 +00:00
committed by Tobias Klauser
parent 641605214e
commit bb729a5782

View File

@@ -492,16 +492,18 @@ func TestFchmodat(t *testing.T) {
}
mode = os.FileMode(0644)
didChmodSymlink := true
err = unix.Fchmodat(unix.AT_FDCWD, "symlink1", uint32(mode), unix.AT_SYMLINK_NOFOLLOW)
if err != nil {
if runtime.GOOS == "linux" && err == unix.EOPNOTSUPP {
// Linux doesn't support flags != 0
if (runtime.GOOS == "linux" || runtime.GOOS == "solaris") && err == unix.EOPNOTSUPP {
// Linux and Illumos don't support flags != 0
didChmodSymlink = false
} else {
t.Fatalf("Fchmodat: unexpected error: %v", err)
}
}
if runtime.GOOS == "linux" {
if !didChmodSymlink {
// Didn't change mode of the symlink. On Linux, the permissions
// of a symbolic link are always 0777 according to symlink(7)
mode = os.FileMode(0777)