diff mbox series

overlay/07[01]: use existing char/block devices

Message ID 20200316185320.26947-1-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show
Series overlay/07[01]: use existing char/block devices | expand

Commit Message

Amir Goldstein March 16, 2020, 6:53 p.m. UTC
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>
---
 tests/overlay/070 | 10 ++++++++--
 tests/overlay/071 | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/tests/overlay/070 b/tests/overlay/070
index 3256e63b..dfa2eb28 100755
--- a/tests/overlay/070
+++ b/tests/overlay/070
@@ -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
 }
diff --git a/tests/overlay/071 b/tests/overlay/071
index b8597e6e..e083c29d 100755
--- a/tests/overlay/071
+++ b/tests/overlay/071
@@ -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
 }