From a129542de9ae0895210abff9c95d67a1f33cb93d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 26 Apr 2019 06:04:56 -0700 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- unix/syscall_linux_test.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/unix/syscall_linux_test.go b/unix/syscall_linux_test.go index 9962fa1f..00aa6556 100644 --- a/unix/syscall_linux_test.go +++ b/unix/syscall_linux_test.go @@ -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) }