generic/571: skip test on filesystems that don't support F_SETLEASE fcntl
authorScott Mayhew <smayhew@redhat.com>
Wed, 1 Apr 2020 17:26:59 +0000 (13:26 -0400)
committerEryu Guan <guaneryu@gmail.com>
Mon, 6 Apr 2020 12:37:38 +0000 (20:37 +0800)
Add an option to the locktest program to check for fcntl setlease
support, and skip the generic/571 test on filesystems where the
check returns EINVAL.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/rc
src/locktest.c
tests/generic/571

index d30204e6bdbd75351c9b05db505d09ea5986483b..3265c793160c95856f668141ef67a26e49530e2d 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3501,6 +3501,14 @@ _require_test_fcntl_advisory_locks()
                _notrun "Require fcntl advisory locks support"
 }
 
+_require_test_fcntl_setlease()
+{
+       _require_test_program "locktest"
+       touch $TEST_DIR/setlease_testfile
+       $here/src/locktest -t $TEST_DIR/setlease_testfile >/dev/null 2>&1
+       [ $? -eq 22 ] && _notrun "Require fcntl setlease support"
+}
+
 _require_ofd_locks()
 {
        # Give a test run by getlk wrlck on testfile.
index 8696966fad97b3588374178e2dbe43a3b7e52f50..0e7c3008d1d03e2e4a2031a92f25cd59709505d5 100644 (file)
@@ -1030,6 +1030,7 @@ main(int argc, char *argv[])
     extern int optind;
     int fail_count = 0;
     int run_leases = 0;
+    int test_setlease = 0;
     
     atexit(cleanup);
     
@@ -1042,7 +1043,7 @@ main(int argc, char *argv[])
            prog = p+1;
     }
 
-    while ((c = getopt(argc, argv, "dLn:h:p:?")) != EOF) {
+    while ((c = getopt(argc, argv, "dLn:h:p:t?")) != EOF) {
        switch (c) {
 
        case 'd':       /* debug flag */
@@ -1072,6 +1073,10 @@ main(int argc, char *argv[])
            }
            break;
 
+       case 't':
+           test_setlease = 1;
+           break;
+
        case '?':
        default:
            errflag++;
@@ -1090,6 +1095,13 @@ main(int argc, char *argv[])
     if (do_open(O_RDWR) == FAIL)
        exit(1);
 
+    if (test_setlease == 1) {
+       fcntl(f_fd, F_SETLEASE, F_UNLCK);
+       saved_errno = errno;
+       close(f_fd);
+       exit(saved_errno);
+    }
+
     setbuf(stderr, NULL);
 
     if (server) {
index 68c8a604c4432402893f993d44a0b0d5b5b74dae..599e3e68f4c4c49cd400421b3f1274db7078c2fd 100755 (executable)
@@ -26,6 +26,7 @@ _supported_fs generic
 _supported_os Linux
 _require_test
 _require_test_fcntl_advisory_locks
+_require_test_fcntl_setlease
 
 _run_leasetest