unix: skip TestOpenByHandleAt if name_to_handle_at not supported

Updates golang/go#30537

Change-Id: Ica526a4bc689af594b0e91c988631bf9987a6119
Reviewed-on: https://go-review.googlesource.com/c/sys/+/174077
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Ian Lance Taylor 2019-04-26 06:04:56 -07:00
Родитель 1607263960
Коммит a129542de9
1 изменённых файлов: 14 добавлений и 9 удалений

Просмотреть файл

@ -539,8 +539,21 @@ func TestClockNanosleep(t *testing.T) {
}
func TestOpenByHandleAt(t *testing.T) {
skipIfNotSupported := func(t *testing.T, name string, err error) {
if err == unix.EPERM {
t.Skipf("skipping %s test without CAP_DAC_READ_SEARCH", name)
}
if err == unix.ENOSYS {
t.Skipf("%s system call not available", name)
}
if err == unix.EOPNOTSUPP {
t.Skipf("%s not supported on this filesystem", name)
}
}
h, mountID, err := unix.NameToHandleAt(unix.AT_FDCWD, "syscall_linux_test.go", 0)
if err != nil {
skipIfNotSupported(t, "name_to_handle_at", err)
t.Fatalf("NameToHandleAt: %v", err)
}
t.Logf("mountID: %v, handle: size=%d, type=%d, bytes=%q", mountID,
@ -557,15 +570,7 @@ func TestOpenByHandleAt(t *testing.T) {
h = unix.NewFileHandle(h.Type(), h.Bytes())
}
fd, err := unix.OpenByHandleAt(int(mount.Fd()), h, unix.O_RDONLY)
if err == unix.EPERM {
t.Skipf("skipping OpenByHandleAt without CAP_DAC_READ_SEARCH")
}
if err == unix.ENOSYS {
t.Skipf("name_to_handle_at system call not available")
}
if err == unix.EOPNOTSUPP {
t.Skipf("name_to_handle_at not supported on this filesystem")
}
skipIfNotSupported(t, "open_by_handle_at", err)
if err != nil {
t.Fatalf("OpenByHandleAt: %v", err)
}