[PATCH 30/40] fstests: don't use directory stacks

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



From: Dave Chinner <dchinner@xxxxxxxxxx>

Using bash directory stacking (pushd, popd, etc) seems to be
somewhat unreliable. I've been seeing occasional random failures
from both pushd and popd commands that cause the test to fail, and
there does not appear to be any reason for the failures occurring.

Rather than wasting time chasing ghosts, just get rid of the
directory stacking altogether.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 tests/generic/099 |  8 +++-----
 tests/generic/109 |  5 +----
 tests/generic/135 | 24 +++++++++++-------------
 tests/generic/707 |  7 ++++---
 4 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/tests/generic/099 b/tests/generic/099
index c7d5932b6..980fd38f3 100755
--- a/tests/generic/099
+++ b/tests/generic/099
@@ -253,15 +253,13 @@ echo ""
 echo "=== Recursive change ACL ==="
 rm -fr root
 mkdir root
-pushd root >/dev/null
 # create an arbitrary little tree
-for i in 1 2 3 4 5 6 7 8 9 0
-do
+( cd root ; for i in 1 2 3 4 5 6 7 8 9 0; do
 	mkdir -p a/$i
 	mkdir -p b/c$i/$i
 	touch a/$i/mumble
-done
-popd >/dev/null
+done )
+
 chown -R 12345:54321 root
 echo "Change #1..."
 _runas -u 12345 -g 54321 -- chacl -r u::rwx,g::-w-,o::--x root
diff --git a/tests/generic/109 b/tests/generic/109
index 2b0b438cf..894e07167 100755
--- a/tests/generic/109
+++ b/tests/generic/109
@@ -54,10 +54,7 @@ _scratch_mount >> $seqres.full 2>&1
 # Test different directory sizes to test various directory formats
 for f in 1 2 3 4 5 8 12 18 27 40 60 90 135 202 303 454 681 1020 1530 2295; do
 	mkdir $SCRATCH_MNT/dir$f
-	pushd $SCRATCH_MNT/dir$f >/dev/null
-	filldir $f
-	renamedir
-	popd >/dev/null
+	( cd $SCRATCH_MNT/dir$f ; filldir $f ; renamedir )
 done
 
 status=0
diff --git a/tests/generic/135 b/tests/generic/135
index 30c52af72..cb9407fdf 100755
--- a/tests/generic/135
+++ b/tests/generic/135
@@ -21,30 +21,28 @@ _scratch_mount
 cd $SCRATCH_MNT
 
 # create file with async I/O
-$XFS_IO_PROG -f -c 'pwrite -b 4k -S 0x12 0 4k' async_file > /dev/null
+$XFS_IO_PROG -f -c 'pwrite -b 4k -S 0x12 0 4k' $SCRATCH_MNT/async_file > /dev/null
 
 # create file with sync I/O
-$XFS_IO_PROG -f -s -c 'pwrite -b 4k -S 0x34 0 4k' sync_file > /dev/null
+$XFS_IO_PROG -f -s -c 'pwrite -b 4k -S 0x34 0 4k' $SCRATCH_MNT/sync_file > /dev/null
 
 # create file with direct I/O
-$XFS_IO_PROG -f -d -c 'pwrite -b 4k -S 0x56 0 4k' direct_file > /dev/null
+$XFS_IO_PROG -f -d -c 'pwrite -b 4k -S 0x56 0 4k' $SCRATCH_MNT/direct_file > /dev/null
 
 # create file, truncate and then dirty again
-$XFS_IO_PROG -f -c 'pwrite -b 4k -S 0x78 0 4k' trunc_file > /dev/null
-$XFS_IO_PROG -f -c 'truncate 2k' trunc_file > /dev/null
-$XFS_IO_PROG -c 'pwrite 1k 0 1k' trunc_file > /dev/null
+$XFS_IO_PROG -f -c 'pwrite -b 4k -S 0x78 0 4k' $SCRATCH_MNT/trunc_file > /dev/null
+$XFS_IO_PROG -f -c 'truncate 2k' $SCRATCH_MNT/trunc_file > /dev/null
+$XFS_IO_PROG -c 'pwrite 1k 0 1k' $SCRATCH_MNT/trunc_file > /dev/null
 
-pushd / > /dev/null
 _scratch_cycle_mount
-popd > /dev/null
 
 # check file size and contents
-od -Ad -x async_file
-od -Ad -x sync_file
-od -Ad -x direct_file
-od -Ad -x trunc_file
+od -Ad -x $SCRATCH_MNT/async_file
+od -Ad -x $SCRATCH_MNT/sync_file
+od -Ad -x $SCRATCH_MNT/direct_file
+od -Ad -x $SCRATCH_MNT/trunc_file
 
-rm -f async_file sync_file direct_file trunc_file
+rm -f $SCRATCH_MNT/*
 
 status=0
 exit 
diff --git a/tests/generic/707 b/tests/generic/707
index fd02eacf9..3d8fac4bd 100755
--- a/tests/generic/707
+++ b/tests/generic/707
@@ -42,7 +42,7 @@ create_files()
 	# We use slightly longer file name to make directory grow faster and
 	# hopefully convert between various types
 	for (( i = 0; i < $files; i++ )); do
-		touch somewhatlongerfilename$i
+		echo -n > somewhatlongerfilename$i
 	done
 }
 
@@ -50,12 +50,13 @@ for (( i = 0; i <= $moves; i++ )); do
 	mkdir $SCRATCH_MNT/dir$i
 done
 
+start_dir=$PWD
 for (( l = 0; l < $loops; l++ )); do
 	mkdir $SCRATCH_MNT/dir0/dir
-	pushd $SCRATCH_MNT/dir0/dir &>/dev/null
+	cd $SCRATCH_MNT/dir0/dir
 	create_files &
 	BGPID=$!
-	popd &>/dev/null
+	cd $start_dir
 	for (( i = 0; i < $moves; i++ )); do
 		mv $SCRATCH_MNT/dir$i/dir $SCRATCH_MNT/dir$((i+1))/dir
 	done
-- 
2.45.2





[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux