From 390ec419d69cc4b5564a1ea0177808563e7ad399 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sun, 8 May 2022 15:19:27 -0400 Subject: [PATCH] cleanup and generalize, avoid /tmp --- tests/w-racer.sh | 60 ++++++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/tests/w-racer.sh b/tests/w-racer.sh index 0bbd92f..224a6ab 100755 --- a/tests/w-racer.sh +++ b/tests/w-racer.sh @@ -5,6 +5,9 @@ # Scratch device to mount on /n/scratch. # Users can set $SCRATCH_DEV and export it, else we default to /dev/sdb test -z "$SCRATCH_DEV" && SCRATCH_DEV=/dev/sdb +SCRATCH_DIR=/n/scratch +LOWER_DIR=/n/lower +TMP_DIR=/n/tmp # TODO: define TMP_DIR, SCRATCH_DIR, and LOWER_DIR, and don't hardcode them below # TODO: TMP_DIR shoyld be /n/tmp, ensure to "runcmd mkdir -p $TMP_DIR" @@ -33,26 +36,26 @@ function cleanup # cleanup case "$type" in wrapfs ) - runcmd umount /tmp + runcmd umount $TMP_DIR runcmd rmmod wrapfs ;; bind ) - runcmd umount /tmp + runcmd umount $TMP_DIR ;; esac #read n case "$lowertype" in ext2 | ext3 | ext4 | reiserfs | xfs ) - runcmd umount /n/scratch + runcmd umount $SCRATCH_DIR ;; tmpfs ) - runcmd umount /n/scratch + runcmd umount $SCRATCH_DIR runcmd swapoff $SCRATCH_DEV ;; nfs ) - runcmd umount /n/scratch - runcmd exportfs -u localhost:/n/lower - runcmd umount /n/lower + runcmd umount $SCRATCH_DIR + runcmd exportfs -u localhost:$LOWER_DIR + runcmd umount $LOWER_DIR ;; esac } @@ -71,6 +74,11 @@ case "$1" in ;; esac +# ensure that all dirs exist as needed +runcmd mkdir -p $SCRATCH_DIR +runcmd mkdir -p $LOWER_DIR +runcmd mkdir -p $TMP_DIR + runcmd2 ./w-install.sh #runcmd2 ./j-syslog.sh @@ -88,59 +96,57 @@ fi case "$lowertype" in ext2 | ext3 | ext4 | reiserfs ) runcmd mkfs -t $lowertype -q $SCRATCH_DEV <<< y - runcmd mount -t $lowertype $SCRATCH_DEV /n/scratch + runcmd mount -t $lowertype $SCRATCH_DEV $SCRATCH_DIR ;; xfs ) runcmd mkfs -t $lowertype -q -f $SCRATCH_DEV <<< y - runcmd mount -t $lowertype $SCRATCH_DEV /n/scratch + runcmd mount -t $lowertype $SCRATCH_DEV $SCRATCH_DIR ;; tmpfs ) runcmd mkswap $SCRATCH_DEV runcmd swapon $SCRATCH_DEV runcmd swapon -s - runcmd mount -t $lowertype -o size=3000m tmpfs /n/scratch + runcmd mount -t $lowertype -o size=3000m tmpfs $SCRATCH_DIR ;; nfs ) - runcmd mkdir -p /n/lower + runcmd mkdir -p $LOWER_DIR runcmd mkfs -t ext3 -q $SCRATCH_DEV <<< y - runcmd mount -t ext3 $SCRATCH_DEV /n/lower - runcmd exportfs -o no_root_squash,rw localhost:/n/lower - runcmd mount -t $lowertype localhost:/n/lower /n/scratch + runcmd mount -t ext3 $SCRATCH_DEV $LOWER_DIR + runcmd exportfs -o no_root_squash,rw localhost:$LOWER_DIR + runcmd mount -t $lowertype localhost:$LOWER_DIR $SCRATCH_DIR ;; esac case "$type" in wrapfs ) - runcmd mount -t wrapfs /n/scratch /tmp + runcmd mount -t wrapfs $SCRATCH_DIR $TMP_DIR ;; bind ) - runcmd mount -o bind /n/scratch /tmp + runcmd mount -o bind $SCRATCH_DIR $TMP_DIR ;; esac -# (df /tmp /n/scratch ; df -i /tmp /n/scratch) > /var/tmp/.racer0.$$ - -# run actual racer tests (30 seconds) -runcmd find /tmp -ls -runcmd df /tmp -runcmd df -i /tmp -runcmd ../racer/racer-fsl.sh /tmp/r ${2:-60} +# run actual racer tests (60 seconds default) +runcmd find $TMP_DIR -ls +runcmd df $TMP_DIR +runcmd df -i $TMP_DIR +runcmd ../racer/racer-fsl.sh $TMP_DIR/r ${2:-60} runcmd sync if test $? != 0 ; then ps -ef | grep bash - set -x; find /tmp/r -ls ; set +x + set -x; find $TMP_DIR/r -ls ; set +x echo "*** RACER FAILED ***!!!! (hit enter to continue)..." sleep 5 fi #runcmd ../racer/fs_racer2.sh -t ${2:-30} #runcmd sleep 1 runcmd sync -runcmd find /tmp -ls +runcmd find $TMP_DIR -ls runcmd sync #runcmd sleep 1 -runcmd df /tmp +runcmd df $TMP_DIR runcmd sync #runcmd sleep 1 -runcmd df -i /tmp +runcmd df -i $TMP_DIR runcmd sync #runcmd sleep 1 -- 2.43.0