test script parameter interfence

This commit is contained in:
Olof Hagsand 2019-07-28 19:00:12 +00:00
parent 70ebfa4d80
commit dbfd92846c
2 changed files with 44 additions and 46 deletions

View file

@ -158,7 +158,7 @@ expectwait "$clixon_netconf -qf $cfg" '<rpc><create-subscription xmlns="urn:ietf
#NOW=$(date +"%Y-%m-%dT%H:%M:%S") #NOW=$(date +"%Y-%m-%dT%H:%M:%S")
#sleep 10 #sleep 10
#expectwait "$clixon_netconf -qf $cfg" "<rpc><create-subscription xmlns=\"urn:ietf:params:xml:ns:netmod:notification\"><stream>EXAMPLE</stream><startTime>$NOW</startTime></create-subscription></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]><notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>20' 10 #expectwait "$clixon_netconf -qf $cfg" "<rpc><create-subscription xmlns=\"urn:ietf:params:xml:ns:netmod:notification\"><stream>EXAMPLE</stream><startTime>$NOW</startTime></create-subscription></rpc>]]>]]>" '^<rpc-reply><ok/></rpc-reply>]]>]]><notification xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0"><eventTime>20' 10
sleep 2 sleep 1
# #
# 2. Restconf RFC8040 stream testing # 2. Restconf RFC8040 stream testing
@ -167,11 +167,11 @@ new "2. Restconf RFC8040 stream testing"
new "restconf event stream discovery RFC8040 Sec 6.2" 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"}\]}\]}' 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" 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"}' 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 # Restconf stream subscription RFC8040 Sec 6.3
# Start Subscription w error # Start Subscription w error
new "restconf monitor event nonexist stream" new "restconf monitor event nonexist stream"
@ -191,7 +191,7 @@ if [ $nr -lt 1 -o $nr -gt 2 ]; then
err 2 "$nr" err 2 "$nr"
fi fi
sleep 2 sleep 1
# 2b) start subscription 8s - stoptime after 5s - expect 1-2 notifications # 2b) start subscription 8s - stoptime after 5s - expect 1-2 notifications
new "2b) start subscriptions 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" err 1 "$nr"
fi fi
sleep 2 sleep 1
# 2c # 2c
new "2c) start sub 8s - replay from start -8s - expect 3-4 notifications" 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" err 4 "$nr"
fi fi
sleep 2 sleep 1
# 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications # 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" 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" err 6 "$nr"
fi fi
sleep 2 sleep 1
# 2e) start sub 8s - replay from -90s w retention 60s - expect 10 notifications # 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" 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" err 10 "$nr"
fi fi
sleep 2 sleep 1
# Try parallell # Try parallell
# start background job # start background job

View file

@ -6,41 +6,39 @@
# Magic line must be first in script (see README.md) # Magic line must be first in script (see README.md)
s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
: ${clixon_util_xml:=clixon_util_xml -o} # -o is output : ${clixon_util_xml:="clixon_util_xml"}
sleep 1 # mysterious fail, maybe this helps?
new "xml parse" new "xml parse"
expecteof "$clixon_util_xml" 0 "<a><b/></a>" "^<a><b/></a>$" expecteof "$clixon_util_xml -o" 0 "<a><b/></a>" "^<a><b/></a>$"
new "xml parse to json" new "xml parse to json"
expecteof "$clixon_util_xml -j" 0 "<a><b/></a>" '{"a":{"b":null}}' expecteof "$clixon_util_xml -oj" 0 "<a><b/></a>" '{"a":{"b":null}}'
new "xml parse strange names" new "xml parse strange names"
expecteof "$clixon_util_xml" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->" expecteof "$clixon_util_xml -o" 0 "<_-><b0.><c-.-._/></b0.></_->" "<_-><b0.><c-.-._/></b0.></_->"
new "xml parse name errors" new "xml parse name errors"
expecteof "$clixon_util_xml" 255 "<-a/>" "" expecteof "$clixon_util_xml -o" 255 "<-a/>" ""
new "xml parse name errors" new "xml parse name errors"
expecteof "$clixon_util_xml" 255 "<9/>" "" expecteof "$clixon_util_xml -o" 255 "<9/>" ""
new "xml parse name errors" new "xml parse name errors"
expecteof "$clixon_util_xml" 255 "<a%/>" "" expecteof "$clixon_util_xml -o" 255 "<a%/>" ""
LF=' LF='
' '
new "xml parse content with CR LF -> LF, CR->LF (see https://www.w3.org/TR/REC-xml/#sec-line-ends)" new "xml parse content with CR LF -> LF, CR->LF (see https://www.w3.org/TR/REC-xml/#sec-line-ends)"
ret=$(echo "<x>a b${LF}c ${LF}d</x>" | $clixon_util_xml) ret=$(echo "<x>a b${LF}c ${LF}d</x>" | $clixon_util_xml -o)
if [ "$ret" != "<x>a${LF}b${LF}c${LF}d</x>" ]; then if [ "$ret" != "<x>a${LF}b${LF}c${LF}d</x>" ]; then
err '<x>a$LFb$LFc</x>' "$ret" err '<x>a$LFb$LFc</x>' "$ret"
fi fi
new "xml simple CDATA" new "xml simple CDATA"
expecteofx "$clixon_util_xml" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>' expecteofx "$clixon_util_xml -o" 0 '<a><![CDATA[a text]]></a>' '<a><![CDATA[a text]]></a>'
new "xml simple CDATA to json" new "xml simple CDATA to json"
expecteofx "$clixon_util_xml -j" 0 '<a><![CDATA[a text]]></a>' '{"a":"a text"}' expecteofx "$clixon_util_xml -o -j" 0 '<a><![CDATA[a text]]></a>' '{"a":"a text"}'
new "xml complex CDATA" new "xml complex CDATA"
XML=$(cat <<EOF XML=$(cat <<EOF
@ -57,7 +55,7 @@ XML=$(cat <<EOF
EOF EOF
) )
expecteof "$clixon_util_xml" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext> expecteof "$clixon_util_xml -o" 0 "$XML" "^<a><description>An example of escaped CENDs</description><sometext>
<![CDATA[ They're saying \"x < y\" & that \"z > y\" so I guess that means that z > x ]]> <![CDATA[ They're saying \"x < y\" & that \"z > y\" so I guess that means that z > x ]]>
</sometext><data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data><alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative></a>$" </sometext><data><![CDATA[This text contains a CEND ]]]]><![CDATA[>]]></data><alternative><![CDATA[This text contains a CEND ]]]><![CDATA[]>]]></alternative></a>$"
@ -66,89 +64,89 @@ JSON=$(cat <<EOF
EOF EOF
) )
new "xml complex CDATA to json" new "xml complex CDATA to json"
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON" expecteofx "$clixon_util_xml -oj" 0 "$XML" "$JSON"
XML=$(cat <<EOF XML=$(cat <<EOF
<message>Less than: &lt; , greater than: &gt; ampersand: &amp; </message> <message>Less than: &lt; , greater than: &gt; ampersand: &amp; </message>
EOF EOF
) )
new "xml encode <>&" new "xml encode <>&"
expecteof "$clixon_util_xml" 0 "$XML" "$XML" expecteof "$clixon_util_xml -o" 0 "$XML" "$XML"
new "xml encode <>& to json" 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 <<EOF XML=$(cat <<EOF
<message>single-quote character ' represented as &apos; and double-quote character as &quot;</message> <message>single-quote character ' represented as &apos; and double-quote character as &quot;</message>
EOF EOF
) )
new "xml single and double quote" new "xml single and double quote"
expecteof "$clixon_util_xml" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>" expecteof "$clixon_util_xml -o" 0 "$XML" "<message>single-quote character ' represented as ' and double-quote character as \"</message>"
JSON=$(cat <<EOF JSON=$(cat <<EOF
{"message":"single-quote character ' represented as ' and double-quote character as \""} {"message":"single-quote character ' represented as ' and double-quote character as \""}
EOF EOF
) )
new "xml single and double quotes to json" new "xml single and double quotes to json"
expecteofx "$clixon_util_xml -j" 0 "$XML" "$JSON" expecteofx "$clixon_util_xml -oj" 0 "$XML" "$JSON"
new "xml backspace" new "xml backspace"
expecteofx "$clixon_util_xml" 0 "<a>a\b</a>" "<a>a\b</a>" expecteofx "$clixon_util_xml -o" 0 "<a>a\b</a>" "<a>a\b</a>"
new "xml backspace to json" new "xml backspace to json"
expecteofx "$clixon_util_xml -j" 0 "<a>a\b</a>" '{"a":"a\\b"}' expecteofx "$clixon_util_xml -oj" 0 "<a>a\b</a>" '{"a":"a\\b"}'
new "Double quotes for attributes" new "Double quotes for attributes"
expecteof "$clixon_util_xml" 0 '<x a="t"/>' '<x a="t"/>' expecteof "$clixon_util_xml -o" 0 '<x a="t"/>' '<x a="t"/>'
new "Single quotes for attributes (returns double quotes but at least parses right)" new "Single quotes for attributes (returns double quotes but at least parses right)"
expecteof "$clixon_util_xml" 0 "<x a='t'/>" '<x a="t"/>' expecteof "$clixon_util_xml -o" 0 "<x a='t'/>" '<x a="t"/>'
new "Mixed quotes" new "Mixed quotes"
expecteof "$clixon_util_xml" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>' expecteof "$clixon_util_xml -o" 0 "<x a='t' b=\"q\"/>" '<x a="t" b="q"/>'
new "XMLdecl version" new "XMLdecl version"
expecteof "$clixon_util_xml" 0 '<?xml version="1.0"?><a/>' '<a/>' expecteof "$clixon_util_xml -o" 0 '<?xml version="1.0"?><a/>' '<a/>'
new "XMLdecl version, single quotes" new "XMLdecl version, single quotes"
expecteof "$clixon_util_xml" 0 "<?xml version='1.0'?><a/>" '<a/>' expecteof "$clixon_util_xml -o" 0 "<?xml version='1.0'?><a/>" '<a/>'
new "XMLdecl version no element" new "XMLdecl version no element"
expecteof "$clixon_util_xml" 255 '<?xml version="1.0"?>' '' expecteof "$clixon_util_xml -o" 255 '<?xml version="1.0"?>' ''
new "XMLdecl no version" new "XMLdecl no version"
expecteof "$clixon_util_xml" 255 '<?xml ?><a/>' '' expecteof "$clixon_util_xml -o" 255 '<?xml ?><a/>' ''
new "XMLdecl misspelled version" new "XMLdecl misspelled version"
expecteof "$clixon_util_xml -l o" 255 '<?xml verion="1.0"?><a/>' '' expecteof "$clixon_util_xml -ol o" 255 '<?xml verion="1.0"?><a/>' ''
new "XMLdecl version + encoding" new "XMLdecl version + encoding"
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>' expecteof "$clixon_util_xml -o" 0 '<?xml version="1.0" encoding="UTF-16"?><a/>' '<a/>'
new "XMLdecl version + misspelled encoding" new "XMLdecl version + misspelled encoding"
expecteof "$clixon_util_xml -l o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e' expecteof "$clixon_util_xml -ol o" 255 '<?xml version="1.0" encding="UTF-16"?><a/>' 'syntax error: at or before: e'
new "XMLdecl version + standalone" new "XMLdecl version + standalone"
expecteof "$clixon_util_xml" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>' expecteof "$clixon_util_xml -o" 0 '<?xml version="1.0" standalone="yes"?><a/>' '<a/>'
new "PI - Processing instruction empty" new "PI - Processing instruction empty"
expecteof "$clixon_util_xml" 0 '<?foo ?><a/>' '<a/>' expecteof "$clixon_util_xml -o" 0 '<?foo ?><a/>' '<a/>'
new "PI some content" new "PI some content"
expecteof "$clixon_util_xml" 0 '<?foo something else ?><a/>' '<a/>' expecteof "$clixon_util_xml -o" 0 '<?foo something else ?><a/>' '<a/>'
new "prolog element misc*" new "prolog element misc*"
expecteof "$clixon_util_xml" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>' expecteof "$clixon_util_xml -o" 0 '<?foo something ?><a/><?bar more stuff ?><!-- a comment-->' '<a/>'
# We allow it as an internal necessity for parsing of xml fragments # We allow it as an internal necessity for parsing of xml fragments
#new "double element error" #new "double element error"
#expecteof "$clixon_util_xml" 255 '<a/><b/>' '' #expecteof "$clixon_util_xml" 255 '<a/><b/>' ''
new "namespace: DefaultAttName" new "namespace: DefaultAttName"
expecteof "$clixon_util_xml" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>' expecteof "$clixon_util_xml -o" 0 '<x xmlns="n1">hello</x>' '<x xmlns="n1">hello</x>'
new "namespace: PrefixedAttName" new "namespace: PrefixedAttName"
expecteof "$clixon_util_xml" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$' expecteof "$clixon_util_xml -o" 0 '<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>' '^<x xmlns:n2="urn:example:des"><n2:y>hello</n2:y></x>$'
new "First example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208" new "First example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
XML=$(cat <<EOF XML=$(cat <<EOF
@ -162,7 +160,7 @@ XML=$(cat <<EOF
</html:html> </html:html>
EOF 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" new "Second example 6.1 from https://www.w3.org/TR/2009/REC-xml-names-20091208"
XML=$(cat <<EOF XML=$(cat <<EOF
@ -175,7 +173,7 @@ XML=$(cat <<EOF
</bk:book> </bk:book>
EOF EOF
) )
expecteof "$clixon_util_xml" 0 "$XML" "$XML" expecteof "$clixon_util_xml -o" 0 "$XML" "$XML"
rm -rf $dir rm -rf $dir