diff mbox

[3/6] testsuite: grep the output patterns only when needed

Message ID 20170528192906.1023-4-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show

Commit Message

Luc Van Oostenryck May 28, 2017, 7:29 p.m. UTC
For some testcase, it is checked if the output contains or not
some given pattern, or we're checking the number of time a
pattern is present in the output.
This is done with grep and some glue.

But for most testcases there is nothing to check and this
grepping is just wasted CPU cycles.

Fix this by using the already known tags to see if we need to
do this grepping or not.

This speedup the testsuite by another 15%.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/test-suite | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/validation/test-suite b/validation/test-suite
index ce2ca454c..e33d97804 100755
--- a/validation/test-suite
+++ b/validation/test-suite
@@ -244,22 +244,27 @@  do_test()
 	fi
 
 	# verify the 'check-output-contains/excludes' tags
-	has_each_patterns "$file" 'check-output-contains' $file.output.got
-	if [ "$?" -ne "0" ]; then
-		error "Actual output doesn't contain some of the expected patterns."
-		test_failed=1
+	if [ $check_output_contains -eq 1 ]; then
+		has_each_patterns "$file" 'check-output-contains' $file.output.got
+		if [ "$?" -ne "0" ]; then
+			error "Actual output doesn't contain some of the expected patterns."
+			test_failed=1
+		fi
 	fi
-	has_none_patterns "$file" 'check-output-excludes' $file.output.got
-	if [ "$?" -ne "0" ]; then
-		error "Actual output contains some patterns which are not expected."
-		test_failed=1
+	if [ $check_output_excludes -eq 1 ]; then
+		has_none_patterns "$file" 'check-output-excludes' $file.output.got
+		if [ "$?" -ne "0" ]; then
+			error "Actual output contains some patterns which are not expected."
+			test_failed=1
+		fi
 	fi
-
-	# verify the 'check-output-pattern-X-times' tags
-	nbr_patterns "$file" 'check-output-pattern' $file.output.got
-	if [ "$?" -ne "0" ]; then
-		error "Actual output doesn't contain the pattern the expected number."
-		test_failed=1
+	if [ $check_output_pattern -eq 1 ]; then
+		# verify the 'check-output-pattern-X-times' tags
+		nbr_patterns "$file" 'check-output-pattern' $file.output.got
+		if [ "$?" -ne "0" ]; then
+			error "Actual output doesn't contain the pattern the expected number."
+			test_failed=1
+		fi
 	fi
 
 	[ "$test_failed" -eq "$must_fail" ] || failed=1