Skip to contentSkip to conversation

generic/402: update test script style

PATCH In review Deepa Dinamani 2 participants 2 messages Oct 23, 2019 – Oct 24, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/402: update test script style

Removed test result checking, as test result already depends on output diff comparison with the golden output.

---
 tests/generic/402     | 33 +++++++--------------------------
 tests/generic/402.out |  2 +-
 2 files changed, 8 insertions(+), 27 deletions(-)
tests/generic/402 +7 -26
index dd136ec2..0392c258 100755
@@ -44,14 +44,11 @@ check_stat()
 	prev_timestamp="$timestamp;$timestamp"
 	if [ $prev_timestamp != $stat_timestamp ]; then
 		echo "$prev_timestamp != $stat_timestamp" | tee -a $seqres.full
-		return 1
 	fi
-	return 0
 }
 
 run_test_individual()
 {
-	fail=0
 	file=$1
 	timestamp=$2
 	update_time=$3
@@ -62,33 +59,24 @@ run_test_individual()
 		$XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file
 		if [ $? -ne 0 ]; then
 			echo "Failed to update times on $file" | tee -a $seqres.full
-			fail=1
 		fi
 	fi
 
 	tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
 	echo "Checking file: $file Updated timestamp is $tsclamp"  >> $seqres.full
-	if ! check_stat $file $tsclamp; then
-		fail=1
-	fi
-	return $fail
+	check_stat $file $tsclamp
 }
 
 run_test()
 {
-	fail=0
 	update_time=$1
 
 	n=1
 
 	for TIME in "${TIMESTAMPS[@]}"; do
-		if ! run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time; then
-			fail=1
-		fi
+		run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
 		((n++))
 	done
-
-	return $fail
 }
 
 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
@@ -108,8 +96,7 @@ declare -a TIMESTAMPS=(
 	$((tsmax+1))
 )
 
-_scratch_mount
-result=$?
+_scratch_mount || _fail "scratch mount failed"
 
 status=0
 
@@ -119,9 +106,7 @@ echo "In memory timestamps update test start" >> $seqres.full
 # update time on the file
 update_time=1
 
-if ! run_test $update_time; then
-	status=1
-fi
+run_test $update_time
 
 echo "In memory timestamps update complete" >> $seqres.full
 
@@ -140,13 +125,9 @@ update_time=0
 echo "On disk timestamps update test start" >> $seqres.full
 
 # Re-run test
-if ! run_test $update_time; then
-	status=1
-fi
+run_test $update_time
 
 echo "On disk timestamps update test complete" >> $seqres.full
 
-echo "inode timestamp tests completed status $status"
-
-# success, all done
-exit $status
+echo Silence is golden
+exit
tests/generic/402.out +1 -1
index 4500e6c7..28e1501c 100644
@@ -1,2 +1,2 @@
 QA output created by 402
-inode timestamp tests completed status 0
+Silence is golden
Signature · 1 line
2.17.1
#1 lore raw
Quoted 4 lines · Deepa Dinamani

Removed test result checking, as test result already depends on output diff comparison with the golden output.

Thanks! I've folded this into original patch.

Thanks,
Eryu

Quoted 109 lines
---
 tests/generic/402     | 33 +++++++--------------------------
 tests/generic/402.out |  2 +-
 2 files changed, 8 insertions(+), 27 deletions(-)
tests/generic/402 +7 -26
index dd136ec2..0392c258 100755
@@ -44,14 +44,11 @@ check_stat()
 	prev_timestamp="$timestamp;$timestamp"
 	if [ $prev_timestamp != $stat_timestamp ]; then
 		echo "$prev_timestamp != $stat_timestamp" | tee -a $seqres.full
-		return 1
 	fi
-	return 0
 }
 
 run_test_individual()
 {
-	fail=0
 	file=$1
 	timestamp=$2
 	update_time=$3
@@ -62,33 +59,24 @@ run_test_individual()
 		$XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file
 		if [ $? -ne 0 ]; then
 			echo "Failed to update times on $file" | tee -a $seqres.full
-			fail=1
 		fi
 	fi
 
 	tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
 	echo "Checking file: $file Updated timestamp is $tsclamp"  >> $seqres.full
-	if ! check_stat $file $tsclamp; then
-		fail=1
-	fi
-	return $fail
+	check_stat $file $tsclamp
 }
 
 run_test()
 {
-	fail=0
 	update_time=$1
 
 	n=1
 
 	for TIME in "${TIMESTAMPS[@]}"; do
-		if ! run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time; then
-			fail=1
-		fi
+		run_test_individual ${SCRATCH_MNT}/test_$n $TIME $update_time
 		((n++))
 	done
-
-	return $fail
 }
 
 _scratch_mkfs &>> $seqres.full 2>&1 || _fail "mkfs failed"
@@ -108,8 +96,7 @@ declare -a TIMESTAMPS=(
 	$((tsmax+1))
 )
 
-_scratch_mount
-result=$?
+_scratch_mount || _fail "scratch mount failed"
 
 status=0
 
@@ -119,9 +106,7 @@ echo "In memory timestamps update test start" >> $seqres.full
 # update time on the file
 update_time=1
 
-if ! run_test $update_time; then
-	status=1
-fi
+run_test $update_time
 
 echo "In memory timestamps update complete" >> $seqres.full
 
@@ -140,13 +125,9 @@ update_time=0
 echo "On disk timestamps update test start" >> $seqres.full
 
 # Re-run test
-if ! run_test $update_time; then
-	status=1
-fi
+run_test $update_time
 
 echo "On disk timestamps update test complete" >> $seqres.full
 
-echo "inode timestamp tests completed status $status"
-
-# success, all done
-exit $status
+echo Silence is golden
+exit
tests/generic/402.out +1 -1
index 4500e6c7..28e1501c 100644
@@ -1,2 +1,2 @@
 QA output created by 402
-inode timestamp tests completed status 0
+Silence is golden
Signature · 1 line
2.17.1