Skip to contentSkip to conversation

df01.sh: put output file to tmp dir

PATCH In review Murphy Zhou 1 participant 2 messages Jun 4, 2023 – Jun 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 df01.sh: put output file to tmp dir

Because the output file itself will consume disk space. This may affects the df numbers. The chance is higher in large block size filesystems.

---
 testcases/commands/df/df01.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
testcases/commands/df/df01.sh +10 -8
index 5af4f68e6..919df9818 100755
@@ -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
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Please ignore this. I read it wrong.

Quoted 75 lines · Murphy Zhou

Because the output file itself will consume disk space. This may affects the df numbers. The chance is higher in large block size filesystems.

---
 testcases/commands/df/df01.sh | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
testcases/commands/df/df01.sh +10 -9
index 5af4f68e6..919df9818 100755
@@ -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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp