Skip to content

Commit a50acf3

Browse files
committed
unix: fix IoctlFileDedupeRange test
The test introduced in CL 284352 breaks on several builders, either with IoctlFileDedupeRange returning ENOTTY (as already seen for android in the TryBot run) or returning EINVAL in the FileDedupeRange.Status field. Both seem to indicate that the underlying filesystem doesn't support deduplication, so skip the test in these cases. Also rename the test to indicate the func it is testing. Change-Id: I29553a5fc95f98335cb233f05d4c2dfb5640dc4c Reviewed-on: https://go-review.googlesource.com/c/sys/+/295911 Trust: Tobias Klauser <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matt Layher <[email protected]>
1 parent 4ada943 commit a50acf3

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

unix/syscall_linux_test.go

+12-14
Original file line numberDiff line numberDiff line change
@@ -797,13 +797,7 @@ func TestOpenat2(t *testing.T) {
797797
}
798798
}
799799

800-
func TestFideduperange(t *testing.T) {
801-
if runtime.GOOS == "android" {
802-
// The ioctl in the build robot android-amd64 returned ENOTTY,
803-
// an error not documented for that syscall.
804-
t.Skip("FIDEDUPERANGE ioctl doesn't work on android, skipping test")
805-
}
806-
800+
func TestIoctlFileDedupeRange(t *testing.T) {
807801
f1, err := ioutil.TempFile("", t.Name())
808802
if err != nil {
809803
t.Fatal(err)
@@ -855,17 +849,19 @@ func TestFideduperange(t *testing.T) {
855849
}}
856850

857851
err = unix.IoctlFileDedupeRange(int(f1.Fd()), &dedupe)
858-
if err == unix.EOPNOTSUPP || err == unix.EINVAL {
852+
if err == unix.EOPNOTSUPP || err == unix.EINVAL || err == unix.ENOTTY {
859853
t.Skip("deduplication not supported on this filesystem")
860854
} else if err != nil {
861855
t.Fatal(err)
862856
}
863857

864858
// The first Info should be equal
865859
if dedupe.Info[0].Status < 0 {
866-
// We expect status to be a negated errno
867-
t.Errorf("Unexpected error in FileDedupeRange: %s",
868-
unix.ErrnoName(unix.Errno(-dedupe.Info[0].Status)))
860+
errno := unix.Errno(-dedupe.Info[0].Status)
861+
if errno == unix.EINVAL {
862+
t.Skip("deduplication not supported on this filesystem")
863+
}
864+
t.Errorf("Unexpected error in FileDedupeRange: %s", unix.ErrnoName(errno))
869865
} else if dedupe.Info[0].Status == unix.FILE_DEDUPE_RANGE_DIFFERS {
870866
t.Errorf("Unexpected different bytes in FileDedupeRange")
871867
}
@@ -876,9 +872,11 @@ func TestFideduperange(t *testing.T) {
876872

877873
// The second Info should be different
878874
if dedupe.Info[1].Status < 0 {
879-
// We expect status to be a negated errno
880-
t.Errorf("Unexpected error in FileDedupeRange: %s",
881-
unix.ErrnoName(unix.Errno(-dedupe.Info[1].Status)))
875+
errno := unix.Errno(-dedupe.Info[1].Status)
876+
if errno == unix.EINVAL {
877+
t.Skip("deduplication not supported on this filesystem")
878+
}
879+
t.Errorf("Unexpected error in FileDedupeRange: %s", unix.ErrnoName(errno))
882880
} else if dedupe.Info[1].Status == unix.FILE_DEDUPE_RANGE_SAME {
883881
t.Errorf("Unexpected equal bytes in FileDedupeRange")
884882
}

0 commit comments

Comments
 (0)