aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMat Martineau <mathew.j.martineau@linux.intel.com>2016-10-20 16:55:46 -0700
committerDavid Howells <dhowells@redhat.com>2016-12-13 14:05:39 +0000
commit623c9ada222cf61d8447ff0d659a0c8f06243d89 (patch)
tree7f8be30a113a03d02d4b4e6431d57aac0505afa6
parent016f58e7751f8e3180f076c35688c3bd2319bf48 (diff)
downloadkeyutils-623c9ada222cf61d8447ff0d659a0c8f06243d89.tar.gz
TEST: Add expect_multiline toolbox function
expect_payload only looks at the last line of the output file, so it doesn't work for commands that output multiple lines. expect_multiline counts the lines in the expected value and extracts that number of lines from the output file for comparison and assignment. Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--tests/toolbox.inc.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/toolbox.inc.sh b/tests/toolbox.inc.sh
index 7c91759..7f19a02 100644
--- a/tests/toolbox.inc.sh
+++ b/tests/toolbox.inc.sh
@@ -672,6 +672,25 @@ function expect_payload ()
###############################################################################
#
+# extract multiline output from the log file
+#
+###############################################################################
+function expect_multiline ()
+{
+ my_varname=$1
+ my_linecount="`echo \"$2\" | wc -l`"
+
+ my_payload=$(tail -$my_linecount $OUTPUTFILE)
+ eval $my_varname="\"$my_payload\""
+
+ if [ $# != 2 -o "x$my_payload" != "x$2" ]
+ then
+ failed
+ fi
+}
+
+###############################################################################
+#
# revoke a key
#
###############################################################################