summaryrefslogtreecommitdiff
path: root/contrib/cirrus/lib.sh.t
diff options
context:
space:
mode:
authorChris Evich <cevich@redhat.com>2019-05-23 10:29:50 -0400
committerChris Evich <cevich@redhat.com>2019-06-25 15:45:12 -0400
commitcd78825be7e5006140a49a26146f9123aeafd1d3 (patch)
treeb2391e5bd28656403e7165e32bc5afaff0636135 /contrib/cirrus/lib.sh.t
parent21978c99088c04bcc847eb12f829876708c0b9e2 (diff)
downloadpodman-cd78825be7e5006140a49a26146f9123aeafd1d3.tar.gz
podman-cd78825be7e5006140a49a26146f9123aeafd1d3.tar.bz2
podman-cd78825be7e5006140a49a26146f9123aeafd1d3.zip
Cirrus: More tests to verify cache_images
Signed-off-by: Chris Evich <cevich@redhat.com>
Diffstat (limited to 'contrib/cirrus/lib.sh.t')
-rwxr-xr-xcontrib/cirrus/lib.sh.t37
1 files changed, 36 insertions, 1 deletions
diff --git a/contrib/cirrus/lib.sh.t b/contrib/cirrus/lib.sh.t
index 1f05b3bb5..70246ef41 100755
--- a/contrib/cirrus/lib.sh.t
+++ b/contrib/cirrus/lib.sh.t
@@ -12,7 +12,7 @@ function check_result {
testnum=$(expr $testnum + 1)
MSG=$(echo "$1" | tr -d '*>\012'|sed -e 's/^ \+//')
if [ "$MSG" = "$2" ]; then
- echo "ok $testnum $3 = $MSG"
+ echo "ok $testnum $(echo $3) = $(echo $MSG)"
else
echo "not ok $testnum $3"
echo "# expected: $2"
@@ -84,5 +84,40 @@ BAR=1
test_rev "FOO BAR" 0 ''
###############################################################################
+# tests for test_okay()
+
+function test_item_test {
+ local exp_msg=$1
+ local exp_ret=$2
+ local item=$3
+ shift 3
+ local test_args="$@"
+ local msg
+ msg=$(item_test "$item" "$@")
+ local status=$?
+
+ check_result "$msg" "$exp_msg" "test_item $item $test_args"
+ check_result "$status" "$exp_ret" "test_item $item $test_args (actual rc $status)"
+}
+
+# negative tests
+test_item_test "FATAL: item_test() requires \$ITEM to be non-empty" 9 "" ""
+test_item_test "FATAL: item_test() requires \$TEST_ARGS to be non-empty" 9 "foo" ""
+test_item_test "not ok foo: -gt 5 ~= bar: too many arguments" 2 "foo" "-gt" "5" "~=" "bar"
+test_item_test "not ok bar: a -ge 10: a: integer expression expected" 2 "bar" "a" "-ge" "10"
+test_item_test "not ok basic logic: 0 -ne 0" 1 "basic logic" "0" "-ne" "0"
+
+# positive tests
+test_item_test "ok snafu" 0 "snafu" "foo" "!=" "bar"
+test_item_test "ok foobar" 0 "foobar" "one two three" "=" "one two three"
+test_item_test "ok oh boy" 0 "oh boy" "line 1
+line2" "!=" "line 1
+
+line2"
+test_item_test "ok okay enough" 0 "okay enough" "line 1
+line2" "=" "line 1
+line2"
+
+###############################################################################
exit $rc