diff mbox

[1/2] testsuite: allow commands to use pipes

Message ID 20161121041421.34576-2-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Luc Van Oostenryck Nov. 21, 2016, 4:14 a.m. UTC
This can be usefull for filtering, transforming the normal
output in order to normalize it so that it can be compared
or to ignore things irrelevant to the test.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/test-pipe-cmd.c | 13 +++++++++++++
 validation/test-suite      |  6 +++---
 2 files changed, 16 insertions(+), 3 deletions(-)
 create mode 100644 validation/test-pipe-cmd.c
diff mbox

Patch

diff --git a/validation/test-pipe-cmd.c b/validation/test-pipe-cmd.c
new file mode 100644
index 00000000..8e86e9c3
--- /dev/null
+++ b/validation/test-pipe-cmd.c
@@ -0,0 +1,13 @@ 
+3
+2
+1
+/*
+ * check-name: test-pipe-cmd
+ * check-command: sparse $file | sort
+ * check-output-start
+
+1
+2
+3
+ * check-output-end
+ */
diff --git a/validation/test-suite b/validation/test-suite
index df5a7c60..9f4974c7 100755
--- a/validation/test-suite
+++ b/validation/test-suite
@@ -106,8 +106,8 @@  do_test()
 	cmd=`eval echo $default_path/$default_cmd`
 	get_value "check-command" $file
 	if [ "$?" -eq "0" ]; then
-		last_result=`echo $last_result | sed -e 's/^ *//'`
-		cmd=`eval echo $default_path/$last_result`
+		last_result=`echo "$last_result" | sed -e 's/^ *//'`
+		cmd=`eval echo "\"$default_path/$last_result\""`
 	fi
 
 	# check for disabled commands
@@ -142,7 +142,7 @@  do_test()
 
 
 	# grab the actual output & exit value
-	$cmd 1> $file.output.got 2> $file.error.got
+	eval $cmd 1> $file.output.got 2> $file.error.got
 	actual_exit_value=$?
 
 	for stream in output error; do