mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
fstests: remove tmp files properly
Some tests and common helpers don't properly clean up tmp files and leave them behind in /tmp dir, and these tmp files are accumulating over time. Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
@@ -560,7 +560,7 @@ _scratch_do_mkfs()
|
|||||||
shift 2
|
shift 2
|
||||||
local extra_mkfs_options=$*
|
local extra_mkfs_options=$*
|
||||||
local mkfs_status
|
local mkfs_status
|
||||||
local tmp=`mktemp`
|
local tmp=`mktemp -u`
|
||||||
|
|
||||||
# save mkfs output in case conflict means we need to run again.
|
# save mkfs output in case conflict means we need to run again.
|
||||||
# only the output for the mkfs that applies should be shown
|
# only the output for the mkfs that applies should be shown
|
||||||
@@ -588,7 +588,7 @@ _scratch_do_mkfs()
|
|||||||
cat $tmp.mkfsstd
|
cat $tmp.mkfsstd
|
||||||
eval "cat $tmp.mkfserr | $mkfs_filter" >&2
|
eval "cat $tmp.mkfserr | $mkfs_filter" >&2
|
||||||
|
|
||||||
rm -f $tmp*
|
rm -f $tmp.mkfserr $tmp.mkfsstd
|
||||||
return $mkfs_status
|
return $mkfs_status
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,7 +669,7 @@ _scratch_mkfs_ext4()
|
|||||||
{
|
{
|
||||||
local mkfs_cmd="$MKFS_EXT4_PROG -F"
|
local mkfs_cmd="$MKFS_EXT4_PROG -F"
|
||||||
local mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \""
|
local mkfs_filter="grep -v -e ^Warning: -e \"^mke2fs \""
|
||||||
local tmp=`mktemp`
|
local tmp=`mktemp -u`
|
||||||
local mkfs_status
|
local mkfs_status
|
||||||
|
|
||||||
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
[ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
|
||||||
@@ -694,6 +694,7 @@ _scratch_mkfs_ext4()
|
|||||||
# output mkfs stdout and stderr
|
# output mkfs stdout and stderr
|
||||||
cat $tmp.mkfsstd
|
cat $tmp.mkfsstd
|
||||||
cat $tmp.mkfserr >&2
|
cat $tmp.mkfserr >&2
|
||||||
|
rm -f $tmp.mkfserr $tmp.mkfsstd
|
||||||
|
|
||||||
return $mkfs_status
|
return $mkfs_status
|
||||||
}
|
}
|
||||||
@@ -736,6 +737,7 @@ _test_mkfs()
|
|||||||
|
|
||||||
_mkfs_dev()
|
_mkfs_dev()
|
||||||
{
|
{
|
||||||
|
local tmp=`mktemp -u`
|
||||||
case $FSTYP in
|
case $FSTYP in
|
||||||
nfs*)
|
nfs*)
|
||||||
# do nothing for nfs
|
# do nothing for nfs
|
||||||
@@ -747,30 +749,30 @@ _mkfs_dev()
|
|||||||
# do nothing for pvfs2
|
# do nothing for pvfs2
|
||||||
;;
|
;;
|
||||||
udf)
|
udf)
|
||||||
$MKFS_UDF_PROG $MKFS_OPTIONS $* 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
|
$MKFS_UDF_PROG $MKFS_OPTIONS $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
|
||||||
;;
|
;;
|
||||||
btrfs)
|
btrfs)
|
||||||
$MKFS_BTRFS_PROG $MKFS_OPTIONS $* 2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
|
$MKFS_BTRFS_PROG $MKFS_OPTIONS $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
|
||||||
;;
|
;;
|
||||||
ext2|ext3|ext4)
|
ext2|ext3|ext4)
|
||||||
$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* \
|
$MKFS_PROG -t $FSTYP -- -F $MKFS_OPTIONS $* \
|
||||||
2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
|
2>$tmp.mkfserr 1>$tmp.mkfsstd
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* \
|
yes | $MKFS_PROG -t $FSTYP -- $MKFS_OPTIONS $* \
|
||||||
2>$tmp_dir.mkfserr 1>$tmp_dir.mkfsstd
|
2>$tmp.mkfserr 1>$tmp.mkfsstd
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
# output stored mkfs output
|
# output stored mkfs output
|
||||||
cat $tmp_dir.mkfserr >&2
|
cat $tmp.mkfserr >&2
|
||||||
cat $tmp_dir.mkfsstd
|
cat $tmp.mkfsstd
|
||||||
status=1
|
status=1
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm -f $tmp_dir.mkfserr $tmp_dir.mkfsstd
|
rm -f $tmp.mkfserr $tmp.mkfsstd
|
||||||
}
|
}
|
||||||
|
|
||||||
# remove all files in $SCRATCH_MNT, useful when testing on NFS/CIFS
|
# remove all files in $SCRATCH_MNT, useful when testing on NFS/CIFS
|
||||||
@@ -1431,6 +1433,7 @@ _do()
|
|||||||
(eval "echo '---' \"$_cmd\"") >>$seqres.full
|
(eval "echo '---' \"$_cmd\"") >>$seqres.full
|
||||||
(eval "$_cmd") >$tmp._out 2>&1; ret=$?
|
(eval "$_cmd") >$tmp._out 2>&1; ret=$?
|
||||||
cat $tmp._out | _fix_malloc >>$seqres.full
|
cat $tmp._out | _fix_malloc >>$seqres.full
|
||||||
|
rm -f $tmp._out
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
if [ $ret -eq 0 ]; then
|
if [ $ret -eq 0 ]; then
|
||||||
echo "done"
|
echo "done"
|
||||||
@@ -3565,8 +3568,10 @@ run_fsx()
|
|||||||
"$@" 2>&1 | tee -a $seqres.full >$tmp.fsx
|
"$@" 2>&1 | tee -a $seqres.full >$tmp.fsx
|
||||||
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
if [ ${PIPESTATUS[0]} -ne 0 ]; then
|
||||||
cat $tmp.fsx
|
cat $tmp.fsx
|
||||||
|
rm -f $tmp.fsx
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
rm -f $tmp.fsx
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR
|
# Test for the existence of a sysfs entry at /sys/fs/$FSTYP/DEV/$ATTR
|
||||||
|
|||||||
+2
-2
@@ -82,7 +82,7 @@ _scratch_mkfs_xfs()
|
|||||||
local mkfs_cmd="`_scratch_mkfs_xfs_opts`"
|
local mkfs_cmd="`_scratch_mkfs_xfs_opts`"
|
||||||
local mkfs_filter="sed -e '/less than device physical sector/d' \
|
local mkfs_filter="sed -e '/less than device physical sector/d' \
|
||||||
-e '/switching to logical sector/d'"
|
-e '/switching to logical sector/d'"
|
||||||
local tmp=`mktemp`
|
local tmp=`mktemp -u`
|
||||||
local mkfs_status
|
local mkfs_status
|
||||||
|
|
||||||
_scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
|
_scratch_do_mkfs "$mkfs_cmd" "$mkfs_filter" $* 2>$tmp.mkfserr 1>$tmp.mkfsstd
|
||||||
@@ -104,7 +104,7 @@ _scratch_mkfs_xfs()
|
|||||||
# output mkfs stdout and stderr
|
# output mkfs stdout and stderr
|
||||||
cat $tmp.mkfsstd
|
cat $tmp.mkfsstd
|
||||||
cat $tmp.mkfserr >&2
|
cat $tmp.mkfserr >&2
|
||||||
rm -f $tmp*
|
rm -f $tmp.mkfserr $tmp.mkfsstd
|
||||||
|
|
||||||
return $mkfs_status
|
return $mkfs_status
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
|
|||||||
|
|
||||||
_cleanup()
|
_cleanup()
|
||||||
{
|
{
|
||||||
rm -f $tmp.* $testfile
|
rm -f $tmp.* $TEMP_DIR/$TAR_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
# real QA test starts here
|
# real QA test starts here
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ seqres=$RESULT_DIR/$seq
|
|||||||
echo "QA output created by $seq"
|
echo "QA output created by $seq"
|
||||||
|
|
||||||
here=`pwd`
|
here=`pwd`
|
||||||
tmp=`mktemp -d`
|
tmp=/tmp/$$
|
||||||
status=0
|
status=0
|
||||||
trap "exit \$status" 0 1 2 3 15
|
trap "exit \$status" 0 1 2 3 15
|
||||||
chpid=0
|
chpid=0
|
||||||
|
|||||||
Reference in New Issue
Block a user