From dbfd92846c795e3cf0b108eb7d411d16c13e698d Mon Sep 17 00:00:00 2001 From: Olof Hagsand Date: Sun, 28 Jul 2019 19:00:12 +0000 Subject: [PATCH] test script parameter interfence --- test/test_stream.sh | 16 +++++----- test/test_xml.sh | 74 ++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/test/test_stream.sh b/test/test_stream.sh index 70713344..30a6418e 100755 --- a/test/test_stream.sh +++ b/test/test_stream.sh @@ -158,7 +158,7 @@ expectwait "$clixon_netconf -qf $cfg" 'EXAMPLE$NOW]]>]]>" '^]]>]]>20' 10 -sleep 2 +sleep 1 # # 2. Restconf RFC8040 stream testing @@ -167,11 +167,11 @@ new "2. Restconf RFC8040 stream testing" new "restconf event stream discovery RFC8040 Sec 6.2" expectfn "curl -s -X GET http://localhost/restconf/data/ietf-restconf-monitoring:restconf-state/streams" 0 '{"ietf-restconf-monitoring:streams":{"stream":\[{"name":"EXAMPLE","description":"Example event stream","replay-support":true,"access":\[{"encoding":"xml","location":"https://localhost/streams/EXAMPLE"}\]}\]}' -sleep 2 +sleep 1 new "restconf subscribe RFC8040 Sec 6.3, get location" expectfn "curl -s -X GET http://localhost/restconf/data/ietf-restconf-monitoring:restconf-state/streams/stream=EXAMPLE/access=xml/location" 0 '{"ietf-restconf-monitoring:location":"https://localhost/streams/EXAMPLE"}' -sleep 2 +sleep 1 # Restconf stream subscription RFC8040 Sec 6.3 # Start Subscription w error new "restconf monitor event nonexist stream" @@ -191,7 +191,7 @@ if [ $nr -lt 1 -o $nr -gt 2 ]; then err 2 "$nr" fi -sleep 2 +sleep 1 # 2b) start subscription 8s - stoptime after 5s - expect 1-2 notifications new "2b) start subscriptions 8s - stoptime after 5s - expect 1-2 notifications" @@ -206,7 +206,7 @@ if [ $nr -lt 1 -o $nr -gt 2 ]; then err 1 "$nr" fi -sleep 2 +sleep 1 # 2c new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications" @@ -221,7 +221,7 @@ if [ $nr -lt 3 -o $nr -gt 4 ]; then err 4 "$nr" fi -sleep 2 +sleep 1 # 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications new "2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications" @@ -236,7 +236,7 @@ if [ $nr -lt 4 -o $nr -gt 10 ]; then err 6 "$nr" fi -sleep 2 +sleep 1 # 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications new "2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications" @@ -252,7 +252,7 @@ if [ $nr -lt 9 -o $nr -gt 14 ]; then err 10 "$nr" fi -sleep 2 +sleep 1 # Try parallell # start background job diff --git a/test/test_xml.sh b/test/test_xml.sh index 8b51ccb1..fa1b2939 100755 --- a/test/test_xml.sh +++ b/test/test_xml.sh @@ -6,41 +6,39 @@ # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi -: ${clixon_util_xml:=clixon_util_xml -o} # -o is output - -sleep 1 # mysterious fail, maybe this helps? +: ${clixon_util_xml:="clixon_util_xml"} new "xml parse" -expecteof "$clixon_util_xml" 0 "" "^$" +expecteof "$clixon_util_xml -o" 0 "" "^$" new "xml parse to json" -expecteof "$clixon_util_xml -j" 0 "" '{"a":{"b":null}}' +expecteof "$clixon_util_xml -oj" 0 "" '{"a":{"b":null}}' new "xml parse strange names" -expecteof "$clixon_util_xml" 0 "<_->" "<_->" +expecteof "$clixon_util_xml -o" 0 "<_->" "<_->" new "xml parse name errors" -expecteof "$clixon_util_xml" 255 "<-a/>" "" +expecteof "$clixon_util_xml -o" 255 "<-a/>" "" new "xml parse name errors" -expecteof "$clixon_util_xml" 255 "<9/>" "" +expecteof "$clixon_util_xml -o" 255 "<9/>" "" new "xml parse name errors" -expecteof "$clixon_util_xml" 255 "" "" +expecteof "$clixon_util_xml -o" 255 "" "" LF=' ' new "xml parse content with CR LF -> LF, CR->LF (see https://www.w3.org/TR/REC-xml/#sec-line-ends)" -ret=$(echo "a b${LF}c ${LF}d" | $clixon_util_xml) +ret=$(echo "a b${LF}c ${LF}d" | $clixon_util_xml -o) if [ "$ret" != "a${LF}b${LF}c${LF}d" ]; then err 'a$LFb$LFc' "$ret" fi new "xml simple CDATA" -expecteofx "$clixon_util_xml" 0 '' '' +expecteofx "$clixon_util_xml -o" 0 '' '' new "xml simple CDATA to json" -expecteofx "$clixon_util_xml -j" 0 '' '{"a":"a text"}' +expecteofx "$clixon_util_xml -o -j" 0 '' '{"a":"a text"}' new "xml complex CDATA" XML=$(cat <An example of escaped CENDs +expecteof "$clixon_util_xml -o" 0 "$XML" "^An example of escaped CENDs y\" so I guess that means that z > x ]]> ]]>]]>$" @@ -66,89 +64,89 @@ JSON=$(cat <Less than: < , greater than: > ampersand: & EOF ) new "xml encode <>&" -expecteof "$clixon_util_xml" 0 "$XML" "$XML" +expecteof "$clixon_util_xml -o" 0 "$XML" "$XML" new "xml encode <>& to json" -expecteof "$clixon_util_xml -j" 0 "$XML" '{"message":"Less than: < , greater than: > ampersand: & "}' +expecteof "$clixon_util_xml -oj" 0 "$XML" '{"message":"Less than: < , greater than: > ampersand: & "}' XML=$(cat <single-quote character ' represented as ' and double-quote character as " EOF ) new "xml single and double quote" -expecteof "$clixon_util_xml" 0 "$XML" "single-quote character ' represented as ' and double-quote character as \"" +expecteof "$clixon_util_xml -o" 0 "$XML" "single-quote character ' represented as ' and double-quote character as \"" JSON=$(cat <a\b" "a\b" +expecteofx "$clixon_util_xml -o" 0 "a\b" "a\b" new "xml backspace to json" -expecteofx "$clixon_util_xml -j" 0 "a\b" '{"a":"a\\b"}' +expecteofx "$clixon_util_xml -oj" 0 "a\b" '{"a":"a\\b"}' new "Double quotes for attributes" -expecteof "$clixon_util_xml" 0 '' '' +expecteof "$clixon_util_xml -o" 0 '' '' new "Single quotes for attributes (returns double quotes but at least parses right)" -expecteof "$clixon_util_xml" 0 "" '' +expecteof "$clixon_util_xml -o" 0 "" '' new "Mixed quotes" -expecteof "$clixon_util_xml" 0 "" '' +expecteof "$clixon_util_xml -o" 0 "" '' new "XMLdecl version" -expecteof "$clixon_util_xml" 0 '' '' +expecteof "$clixon_util_xml -o" 0 '' '' new "XMLdecl version, single quotes" -expecteof "$clixon_util_xml" 0 "" '' +expecteof "$clixon_util_xml -o" 0 "" '' new "XMLdecl version no element" -expecteof "$clixon_util_xml" 255 '' '' +expecteof "$clixon_util_xml -o" 255 '' '' new "XMLdecl no version" -expecteof "$clixon_util_xml" 255 '' '' +expecteof "$clixon_util_xml -o" 255 '' '' new "XMLdecl misspelled version" -expecteof "$clixon_util_xml -l o" 255 '' '' +expecteof "$clixon_util_xml -ol o" 255 '' '' new "XMLdecl version + encoding" -expecteof "$clixon_util_xml" 0 '' '' +expecteof "$clixon_util_xml -o" 0 '' '' new "XMLdecl version + misspelled encoding" -expecteof "$clixon_util_xml -l o" 255 '' 'syntax error: at or before: e' +expecteof "$clixon_util_xml -ol o" 255 '' 'syntax error: at or before: e' new "XMLdecl version + standalone" -expecteof "$clixon_util_xml" 0 '' '' +expecteof "$clixon_util_xml -o" 0 '' '' new "PI - Processing instruction empty" -expecteof "$clixon_util_xml" 0 '' '' +expecteof "$clixon_util_xml -o" 0 '' '' new "PI some content" -expecteof "$clixon_util_xml" 0 '' '' +expecteof "$clixon_util_xml -o" 0 '' '' new "prolog element misc*" -expecteof "$clixon_util_xml" 0 '' '' +expecteof "$clixon_util_xml -o" 0 '' '' # We allow it as an internal necessity for parsing of xml fragments #new "double element error" #expecteof "$clixon_util_xml" 255 '' '' new "namespace: DefaultAttName" -expecteof "$clixon_util_xml" 0 'hello' 'hello' +expecteof "$clixon_util_xml -o" 0 'hello' 'hello' new "namespace: PrefixedAttName" -expecteof "$clixon_util_xml" 0 'hello' '^hello$' +expecteof "$clixon_util_xml -o" 0 'hello' '^hello$' new "First example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208" XML=$(cat < EOF ) -expecteof "$clixon_util_xml" 0 "$XML" "$XML" +expecteof "$clixon_util_xml -o" 0 "$XML" "$XML" new "Second example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208" XML=$(cat < EOF ) -expecteof "$clixon_util_xml" 0 "$XML" "$XML" +expecteof "$clixon_util_xml -o" 0 "$XML" "$XML" rm -rf $dir