[LTP] [PATCH] df01.sh: put output file to tmp dir
Murphy Zhou
jencce.kernel@gmail.com
Sun Jun 4 11:49:36 CEST 2023
Because the output file itself will consume disk space.
This may affects the df numbers. The chance is higher
in large block size filesystems.
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
---
testcases/commands/df/df01.sh | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index 5af4f68e6..919df9818 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -12,6 +12,7 @@ TST_CNT=12
TST_SETUP=setup
TST_TESTFUNC=test
TST_NEEDS_ROOT=1
+OUTPUT=$(mktemp)
setup()
{
@@ -57,15 +58,15 @@ df_test()
df_verify()
{
- $@ >output 2>&1
+ $@ >$OUTPUT 2>&1
if [ $? -ne 0 ]; then
- grep -q -E "unrecognized option | invalid option" output
+ grep -q -E "unrecognized option | invalid option" $OUTPUT
if [ $? -eq 0 ]; then
tst_res TCONF "'$@' not supported."
return 32
else
tst_res TFAIL "'$@' failed."
- cat output
+ cat $OUTPUT
return 1
fi
fi
@@ -86,12 +87,12 @@ df_check()
used=$((($used * $bsize + 512) / 1024))
fi
- grep $TST_DEVICE output | grep -q "${total}.*${used}"
+ grep $TST_DEVICE $OUTPUT | grep -q "${total}.*${used}"
if [ $? -ne 0 ]; then
echo "total: ${total}, used: ${used}"
- echo "df saved output:"
- cat output
- echo "df output:"
+ echo "df saved $OUTPUT:"
+ cat $OUTPUT
+ echo "df $OUTPUT:"
$@
return 1
fi
@@ -175,7 +176,7 @@ test12()
return
fi
- grep $TST_DEVICE output | grep -q $TST_MNTPOINT
+ grep $TST_DEVICE $OUTPUT | grep -q $TST_MNTPOINT
if [ $? -ne 0 ]; then
tst_res TPASS "'$cmd' passed."
else
@@ -185,3 +186,4 @@ test12()
. tst_test.sh
tst_run
+rm -f $OUTPUT
--
2.31.1
More information about the ltp
mailing list