diff mbox series

[PATCHv2,1/3] check: add CLI option to repeat and stop tests in case of failure

Message ID 4e3a0b44ed39e7a60457c46801630f610b44e308.1612951443.git.riteshh@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series fstests: -I <n> CLI option and some random fixes | expand

Commit Message

Ritesh Harjani Feb. 11, 2021, 3:31 a.m. UTC
Currently with -i <n> option the test can run for many iterations,
but in case if we want to stop the iteration in case of a failure,
it is much easier to have such an option which could check the failed
status and stop the test from further proceeding.

This patch adds such an option (-I <n>) thereby extending the -i <n> option
functionality.

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
---
 check | 8 ++++++++
 1 file changed, 8 insertions(+)

--
diff mbox series

Patch

diff --git a/check b/check
index c6ad1d6c0733..6760d066955d 100755
--- a/check
+++ b/check
@@ -27,6 +27,7 @@  brief_test_summary=false
 do_report=false
 DUMP_OUTPUT=false
 iterations=1
+istop=false

 # This is a global variable used to pass test failure text to reporting gunk
 _err_msg=""
@@ -68,6 +69,7 @@  check options
     -T			output timestamps
     -r			randomize test order
     -i <n>		iterate the test list <n> times
+    -I <n>		iterate the test list <n> times, but stops iterating further in case of any test failure
     -d			dump test output to stdout
     -b			brief test summary
     -R fmt[,fmt]	generate report in formats specified. Supported format: [xunit]
@@ -300,6 +302,7 @@  while [ $# -gt 0 ]; do
 	-n)	showme=true ;;
         -r)	randomize=true ;;
 	-i)	iterations=$2; shift ;;
+	-I) 	iterations=$2; istop=true; shift ;;
 	-T)	timestamp=true ;;
 	-d)	DUMP_OUTPUT=true ;;
 	-b)	brief_test_summary=true;;
@@ -926,6 +929,11 @@  function run_section()
 for ((iters = 0; iters < $iterations; iters++)) do
 	for section in $HOST_OPTIONS_SECTIONS; do
 		run_section $section
+		if [ "$sum_bad" != 0 ] && [ "$istop" = true ]; then
+			interrupt=false
+			status=`expr $sum_bad != 0`
+			exit
+		fi
 	done
 done