overlay/07[01]: use existing char/block devices
authorAmir Goldstein <amir73il@gmail.com>
Mon, 16 Mar 2020 18:53:20 +0000 (20:53 +0200)
committerEryu Guan <guaneryu@gmail.com>
Sun, 22 Mar 2020 15:18:38 +0000 (23:18 +0800)
If the arbitrary char/block devices 1:1 do not exist in the system,
the tests fail.

Use /dev/zero and loop device instead of made up device numbers.

Reposted-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/overlay/070
tests/overlay/071

index 3256e63bdb51d962972e11737f2f72a7b0b60275..dfa2eb286f1dae523cb4095e56b8e60173b406e8 100755 (executable)
@@ -32,6 +32,7 @@ _cleanup()
        rm -f $tmp.*
        # Unmount the nested overlay mount
        $UMOUNT_PROG $mnt2 2>/dev/null
+       [ -z "$loopdev" ] || _destroy_loop_device $loopdev
 }
 
 # get standard environment, filters and checks
@@ -48,6 +49,7 @@ _require_command "$FLOCK_PROG" "flock"
 # We need to require all features together, because nfs_export cannot
 # be enabled when index is disabled
 _require_scratch_overlay_features index nfs_export redirect_dir
+_require_loop
 
 lower=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
 upper=$OVL_BASE_SCRATCH_MNT/$OVL_UPPER
@@ -69,6 +71,10 @@ create_dirs()
 
        # Create the nested overlay upper dirs
        mkdir -p $upper2 $work2 $mnt2
+
+       # Create a loop device for blkdev tests
+       $XFS_IO_PROG -f -c "truncate 128k" $lower/img >> $seqres.full 2>&1
+       loopdev=`_create_loop_device $lower/img`
 }
 
 # Mount a nested overlay with $SCRATCH_MNT as lower layer
@@ -116,8 +122,8 @@ create_test_files()
        ln -s $dir/file $dir/symlink
        touch $dir/link
        ln $dir/link $dir/link2
-       mknod $dir/chrdev c 1 1
-       mknod $dir/blkdev b 1 1
+       cp -a /dev/zero $dir/chrdev
+       cp -a $loopdev $dir/blkdev
        mknod $dir/fifo p
        $here/src/af_unix $dir/socket
 }
index b8597e6e04a065c34902ab824e36a9a9c1df4cba..e083c29dc62981cbcbc64581b215720c473a601c 100755 (executable)
@@ -35,6 +35,7 @@ _cleanup()
        rm -f $tmp.*
        # Unmount the nested overlay mount
        $UMOUNT_PROG $mnt2 2>/dev/null
+       [ -z "$loopdev" ] || _destroy_loop_device $loopdev
 }
 
 # get standard environment, filters and checks
@@ -52,6 +53,7 @@ _require_command "$FLOCK_PROG" "flock"
 # We need to require all features together, because nfs_export cannot
 # be enabled when index is disabled
 _require_scratch_overlay_features index nfs_export redirect_dir
+_require_loop
 
 # Lower overlay lower layer is on test fs, upper is on scratch fs
 lower=$OVL_BASE_TEST_MNT/$OVL_LOWER-$seq
@@ -75,6 +77,10 @@ create_dirs()
        # Re-create the nested overlay upper dirs
        rm -rf $lower $upper2 $work2 $mnt2
        mkdir $lower $upper2 $work2 $mnt2
+
+       # Create a loop device for blkdev tests
+       $XFS_IO_PROG -f -c "truncate 128k" $lower/img >> $seqres.full 2>&1
+       loopdev=`_create_loop_device $lower/img`
 }
 
 # Mount a nested overlay with $SCRATCH_MNT as lower layer
@@ -126,8 +132,8 @@ create_test_files()
        ln -s $dir/file $dir/symlink
        touch $dir/link
        ln $dir/link $dir/link2
-       mknod $dir/chrdev c 1 1
-       mknod $dir/blkdev b 1 1
+       cp -a /dev/zero $dir/chrdev
+       cp -a $loopdev $dir/blkdev
        mknod $dir/fifo p
        $here/src/af_unix $dir/socket
 }