]> granicus.if.org Git - strace/commitdiff
tests: robustify preadv2-pwritev2 test against odd kernels
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 11 Feb 2019 21:00:05 +0000 (21:00 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 11 Feb 2019 21:00:05 +0000 (21:00 +0000)
The test used to assume that either both preadv2 and pwritev2 syscalls
are implemented or both are not implemented, but, apparently, there are
kernels in the wild that implement just preadv2 syscall without
pwritev2.

* tests/preadv2-pwritev2.c (main): Skip the dumpio part of the test
if either preadv2 or pwritev2 syscall is not implemented.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1668750

tests/preadv2-pwritev2.c

index f0e6987df6b73929183acc7536a30c5296a763cc..1dfd674f054f0a8e67e222a73532ba4af0d86b31 100644 (file)
@@ -166,7 +166,7 @@ main(void)
        const unsigned long long pos = 0x7ac5fed6dad7bef8;
        const kernel_ulong_t pos_l = (kernel_ulong_t) pos;
        long rc;
-       int test_dumpio;
+       bool skip_dumpio_test = false;
 
        tprintf("%s", "");
 
@@ -183,9 +183,17 @@ main(void)
                (kernel_ulong_t) (pos >> 32);
        rc = syscall(__NR_preadv2, -1, NULL, vlen, pos_l, pos_h, 1);
 # endif
-       if (rc != -1 || (ENOSYS != errno && EBADF != errno))
-               perror_msg_and_fail("preadv2");
-       test_dumpio = EBADF == errno;
+       if (rc != -1)
+               error_msg_and_fail("preadv2: expected -1, returned %ld", rc);
+       switch (errno) {
+               case ENOSYS:
+                       skip_dumpio_test = true;
+                       break;
+               case EBADF:
+                       break;
+               default:
+                       perror_msg_and_fail("preadv2");
+       }
        tprintf("preadv2(-1, NULL, %lu, %lld, RWF_HIPRI) = %s\n",
                (unsigned long) vlen, pos, sprintrc(rc));
 
@@ -198,12 +206,21 @@ main(void)
 # else
        rc = syscall(__NR_pwritev2, -1, NULL, vlen, pos_l, pos_h, 1);
 # endif
-       if (rc != -1 || (ENOSYS != errno && EBADF != errno))
-               perror_msg_and_fail("pwritev2");
+       if (rc != -1)
+               error_msg_and_fail("pwritev2: expected -1, returned %ld", rc);
+       switch (errno) {
+               case ENOSYS:
+                       skip_dumpio_test = true;
+                       break;
+               case EBADF:
+                       break;
+               default:
+                       perror_msg_and_fail("pwritev2");
+       }
        tprintf("pwritev2(-1, NULL, %lu, %lld, RWF_HIPRI) = %s\n",
                (unsigned long) vlen, pos, sprintrc(rc));
 
-       if (test_dumpio)
+       if (!skip_dumpio_test)
                dumpio();
 
        tprintf("%s\n", "+++ exited with 0 +++");