Test: moved unsetting of vars to endtest

This commit is contained in:
Olof hagsand 2023-02-15 13:59:21 +01:00
parent 585823a609
commit 204c704b3a
90 changed files with 59 additions and 328 deletions

View file

@ -679,16 +679,47 @@ function wait_snmp()
# End of single test, final tests before normal exit of test
# Note this is a single test started by new, not a total test suite
# Unset common variables that may affect next test if run in sequence by
# eg all.sh or mem.sh
function endtest()
{
if [ $valgrindtest -eq 1 ]; then
checkvalgrind
fi
# Unset common variables. More specific should be unset at end of script
unset RCPROTO
unset HAVE_LIBNGHTTP2
unset HVER
unset AUTOCLI
unset CURLOPTS
unset RESTCONFIG
unset LOGDST
unset fyang
unset ret
unset count
unset nr
unset format
unset perfnr
unset perfreq
unset pid
unset validatexml
unset xpath
unset clixon_util_datastore
unset clixon_util_json
unset clixon_util_xml
unset clixon_util_path
unset clixon_util_socket
unset clixon_util_stream
unset clixon_util_xpath
unset clixon_util_xml
unset clixon_util_xml_mod
}
# Increment test number and print a nice string
function new(){
endtest # finalize previous test
if [ $valgrindtest -eq 1 ]; then
checkvalgrind
fi
testnr=`expr $testnr + 1`
testi=`expr $testi + 1`
testname=$1

View file

@ -270,12 +270,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# unset conditional parameters
unset format
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -255,10 +255,6 @@ expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /modb:x6/yy=b$rnd,b$rnd)" 0
new "api-path double string key k1=a$rnd,b$rnd in modb + augmented in moda"
expectpart "$($clixon_util_path -f $xml6 -y $ydir -p /modb:x6/yy=b$rnd,b$rnd/moda:y=a1,a1/z=foo1)" 0 "0: <z>foo1</z>"
# unset conditional parameters
unset nr
unset clixon_util_path
rm -rf $dir
new "endtest"

View file

@ -358,9 +358,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -8,6 +8,8 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example
echo "AUTOCLI:$AUTOCLI"
# include err() and new() functions and creates $dir
cfg=$dir/conf_yang.xml
@ -139,8 +141,7 @@ cat <<EOF > $cfg
<CLICON_FEATURE>ietf-netconf:startup</CLICON_FEATURE>
<CLICON_YANG_DIR>${YANG_INSTALLDIR}</CLICON_YANG_DIR>
<CLICON_YANG_DIR>$IETFRFC</CLICON_YANG_DIR>
<CLICON_YANG_MAIN_DIR>$dir</CLICON_YANG_MAIN_DIR>
<CLICON_BACKEND_DIR>/usr/local/lib/$APPNAME/backend</CLICON_BACKEND_DIR>
<CLICON_YANG_MAIN_FILE>$fyang</CLICON_YANG_MAIN_FILE>
<CLICON_CLI_MODE>$APPNAME</CLICON_CLI_MODE>
<CLICON_CLI_DIR>/usr/local/lib/$APPNAME/cli</CLICON_CLI_DIR>
<CLICON_CLISPEC_DIR>$dir</CLICON_CLISPEC_DIR>

View file

@ -268,7 +268,5 @@ fi
rm -rf $dir
unset format
new "endtest"
endtest

View file

@ -485,9 +485,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -177,8 +177,5 @@ fi
rm -rf $dir
unset count
unset ret
new "endtest"
endtest

View file

@ -141,7 +141,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
unset nr
rm -rf $dir
new "endtest"

View file

@ -163,8 +163,5 @@ fi
rm -rf $dir
unset count
unset ret
new "endtest"
endtest

View file

@ -183,12 +183,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# unset conditional parameters
unset format
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -475,8 +475,7 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"
endtest

View file

@ -233,9 +233,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
new "Endtest"
endtest

View file

@ -161,9 +161,6 @@ diff $mydir/kalle_db $mydir/candidate_db
new "datastore lock"
expectpart "$($clixon_util_datastore $conf lock 756)" 0 ""
# unset conditional parameters
unset clixon_util_datastore
unset ret
rm -rf $mydir

View file

@ -264,9 +264,5 @@ fi
rm -rf $dir
unset format
unset pid
unset ret
new "endtest"
endtest

View file

@ -110,9 +110,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -334,8 +334,7 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
unset ret
endtest
rm -rf $dir
new "endtest"
endtest

View file

@ -94,8 +94,9 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
unset ret
rm -rf $dir
new "endtest"
endtest
rm -rf $dir

View file

@ -303,10 +303,6 @@ for proto in $protos; do
done
done
# unset conditional parameters
unset RCPROTO
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -401,9 +401,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
new "Endtest"
endtest

View file

@ -214,10 +214,11 @@ testrun "$x0" "<e>32</e>"
new "adv list add leaf-list"
testrun "$x0" "<e>32</e>"
endtest
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml_mod
new "endtest"
endtest

View file

@ -325,8 +325,5 @@ done
rm -rf $dir
unset nr
unset clixon_util_path # for other script reusing it
new "endtest"
endtest

View file

@ -97,7 +97,6 @@ new "instance-id top-level parameter/next/parameter"
expectpart "$($clixon_util_path -f $xml1 -y $ydir -p /ex:table/ex:parameter/ex:next/ex:parameter)" 0 "0: <parameter><name>a</name><value>11</value></parameter>" "1: <parameter><name>b</name><value>22</value></parameter>" "2: <parameter><name>a</name><value>33</value></parameter>"
rm -rf $dir
unset clixon_util_path # for other script reusing it
new "endtest"
endtest

View file

@ -140,9 +140,5 @@ expecteofx "$clixon_util_json -j -y $fyang" 0 "$JSON" "$JSON"
rm -rf $dir
# unset conditional parameters
unset clixon_util_json
unset clixon_util_xml
new "endtest"
endtest

View file

@ -94,9 +94,5 @@ testrun "three list" '{"json:c":{"l2":[{"name":1,"value":"x"},{"name":2,"value":
rm -rf $dir
# unset conditional parameters
unset clixon_util_json
unset clixon_util_xml
new "endtest"
endtest

View file

@ -194,9 +194,5 @@ expecteofx "$clixon_util_xml -ovJjy $fyang" 255 "$JSON" "" 2> /dev/null
rm -rf $dir
# unset conditional parameters
unset clixon_util_json
unset clixon_util_xml
new "endtest"
endtest

View file

@ -198,9 +198,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -225,8 +225,5 @@ testrun except $USER IPv4 127.0.0.1 "$ERROR" ""
rm -rf $dir
# unset conditional parameters
unset clixon_util_socket
new "endtest"
endtest

View file

@ -330,9 +330,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -166,9 +166,6 @@ if [ $BE -ne 0 ]; then # Bring your own backend
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -297,9 +297,6 @@ if [ $BE -ne 0 ]; then # Bring your own backend
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -295,9 +295,6 @@ if [ $BE -ne 0 ]; then # Bring your own backend
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -229,13 +229,10 @@ for db in startup init; do
done
endtest
rm -rf $dir
# Set by restconf_config
unset RESTCONFIG
new "endtest"
endtest
# unset conditional parameters
unset format
unset ret

View file

@ -272,9 +272,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -324,10 +324,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
unset ret
rm -rf $dir
new "endtest"

View file

@ -299,9 +299,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -234,9 +234,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -225,7 +225,4 @@ testrun $CRED $REALUSER $PSEUDO $RECOVERY false false
new "endtest"
endtest
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir

View file

@ -177,12 +177,12 @@ EOF
continue
fi
# Mask netconf header and footer
sed -i -e "s/<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">//" /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e 's/<\/data><\/rpc-reply>]]>]]>//' /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e "s/<rpc-reply $DEFAULTNS><data xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring\">//" $dir/ex.yang
sed -i -e 's/<\/data><\/rpc-reply>]]>]]>//' $dir/ex.yang
# Decode XML
sed -i -e 's/&gt;/>/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e 's/&lt;/</g' /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e 's/\&amp;/\&/g' /var/tmp/test_netconf_monitoring.sh/ex.yang
sed -i -e 's/&gt;/>/g' $dir/ex.yang
sed -i -e 's/&lt;/</g' $dir/ex.yang
sed -i -e 's/\&amp;/\&/g' $dir/ex.yang
new "get-schema check yang $b"
diff $dir/ex.yang $f
if [ $? -ne 0 ]; then

View file

@ -457,8 +457,5 @@ fi
rm -rf $dir
# unset conditional parameters
unset format
new "endtest"
endtest

View file

@ -176,10 +176,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
unset validatexml
unset perfnr
unset xpath
rm -rf $dir
new "endtest"

View file

@ -429,7 +429,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
unset RESTCONFIG
unset validatexml
rm -rf $dir

View file

@ -173,9 +173,6 @@ if [ -n "$(type expect 2> /dev/null)" ]; then
fi # expect
unset validatexml
unset perfnr
unset xpath
unset xpath0
rm -rf $dir

View file

@ -162,10 +162,5 @@ fi
rm -rf $dir
# unset conditional parameters
unset format
unset perfnr
unset perfreq
new "endtest"
endtest

View file

@ -25,9 +25,5 @@ expecteof_file "time -p $clixon_util_json" 0 "$fjson" 2>&1 | awk '/real/ {print
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml
unset perfnr
new "endtest"
endtest

View file

@ -242,10 +242,5 @@ fi
rm -rf $dir
# unset conditional parameters
unset format
unset perfnr
unset perfreq
new "endtest"
endtest

View file

@ -240,20 +240,8 @@ if [ $BE -ne 0 ]; then
# kill backend
stop_backend -f $cfg
fi
rm -rf $dir
# Set by restconf_config
unset RESTCONFIG
unset HAVE_LIBNGHTTP2
unset RCPROTO
unset HVER
unset CURLOPTS
# unset conditional parameters
unset format
unset perfnr
unset perfreq
unset ret
new "endtest"
endtest

View file

@ -256,16 +256,5 @@ if [ $BE -ne 0 ]; then
fi
rm -rf $dir
# Set by restconf_config
unset RESTCONFIG
unset HAVE_LIBNGHTTP2
unset RCPROTO
# unset conditional parameters
unset format
unset perfnr
unset perfreq
unset ret
new "endtest"
endtest

View file

@ -161,9 +161,5 @@ done
rm -rf $dir
# unset conditional parameters
unset perfnr
unset format
new "endtest"
endtest

View file

@ -223,13 +223,5 @@ fi
rm -rf $dir
# unset conditional parameters
unset format
unset perfnr
unset perfreq
# Set by restconf_config
unset RESTCONFIG
new "endtest"
endtest

View file

@ -202,13 +202,5 @@ fi
rm -rf $dir
# Set by restconf_config
unset RESTCONFIG
# unset conditional parameters
unset format
unset perfnr
unset perfreq
new "endtest"
endtest

View file

@ -26,9 +26,5 @@ expecteof_file "time -p $clixon_util_xml" 0 "$fxml" 2>&1 | awk '/real/ {print $2
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml
unset perfnr
new "endtest"
endtest

View file

@ -696,14 +696,8 @@ for proto in $protos; do
done
done
# unset conditional parameters
unset HVER
unset RCPROTO
# Set by restconf_config
unset RESTCONFIG
unset RESTCONFIG1
unset ret
rm -rf $dir

View file

@ -288,8 +288,6 @@ if [ $BE -ne 0 ]; then
fi
# unset conditional parameters
unset RCPROTO
unset HVER
unset RESTCONFIG1
unset MSGANON
unset MSGWILMA

View file

@ -130,13 +130,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
unset nr
unset HAVE_LIBNGHTTP2
unset CURLOPTS
unset HVER
rm -rf $dir
new "endtest"

View file

@ -346,13 +346,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
unset HVER
unset RCPROTO
unset CURLOPTS
unset HAVE_LIBNGHTTP2
rm -rf $dir
new "endtest"

View file

@ -192,10 +192,6 @@ testrun false
new "enable plain http/2"
testrun true
# Set by restconf_config
unset RESTCONFIG
unset RCPROTO
rm -rf $dir
new "endtest"

View file

@ -499,13 +499,9 @@ new "endtest"
endtest
# Set by restconf_config
unset HVER
unset LOGDST
unset LOGDST_CMD
unset pid
unset RESTCONFIG
unset RESTCONFDBG
unset RCPROTO
unset retx
rm -rf $dir

View file

@ -474,13 +474,10 @@ new "endtest"
endtest
# Set by restconf_config
unset LOGDST
unset LOGDST_CMD
unset RESTCONFIG1
unset RESTCONFIG2
unset RESTCONFDBG
unset RCPROTO
unset HVER
rm -rf $dir

View file

@ -270,9 +270,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -227,9 +227,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -200,13 +200,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# unset conditional parameters
unset RCPROTO
# Set by restconf_config
unset result
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -317,13 +317,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
# unset conditional parameters
unset clixon_util_stream
unset nr
new "Endtest"
endtest

View file

@ -257,10 +257,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
unset ret
rm -rf $dir
new "endtest"

View file

@ -280,9 +280,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -347,7 +347,5 @@ testrun
rm -rf $dir
# unset conditional parameters
unset RCPROTO
new "endtest"
endtest

View file

@ -136,9 +136,6 @@ if [ -f $dir/startup_db ]; then
err "startup should not exist"
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -327,9 +327,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -303,9 +303,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -376,9 +376,6 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -93,8 +93,5 @@ new "non-index search latency j=$rndi"
rm -rf $dir
unset nr
unset clixon_util_path # for other script reusing it
new "endtest"
endtest

View file

@ -100,8 +100,5 @@ testrun IPv4 127.0.0.1
rm -rf $dir
# unset conditional parameters
unset clixon_util_socket
new "endtest"
endtest

View file

@ -232,8 +232,5 @@ fi
rm -rf $dir
# unset conditional parameters
unset format
new "endtest"
endtest

View file

@ -286,9 +286,6 @@ if [ $BE -ne 0 ]; then
sudo pkill -u root -f clixon_backend
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -459,7 +459,5 @@ fi
rm -rf $dir
unset nr
new "endtest"
endtest

View file

@ -144,7 +144,5 @@ fi
rm -rf $dir
unset nr
new "endtest"
endtest

View file

@ -330,8 +330,5 @@ fi
rm -rf $dir
# unset conditional parameters
unset format
new "endtest"
endtest

View file

@ -147,6 +147,7 @@ done
done
rm -rf $dir
# unset specific variables set in this script
unset j
unset xml
unset xmltag

View file

@ -383,8 +383,5 @@ fi # valgrindtest
rm -rf $dir
new "endtest"
unset ret
endtest

View file

@ -214,8 +214,5 @@ expecteof "$clixon_util_xml -o" 0 "$XML" '^<bk:book xmlns:bk="urn:loc.gov:books"
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml
new "endtest"
endtest

View file

@ -124,7 +124,6 @@ testrun merge "$x0a<a><x>1</x></a><a><x>2</x></a>$x0b" "$x0a<a><x>2</x></a><a><x
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml_mod
unset retx
new "endtest"

View file

@ -47,8 +47,5 @@ expecteof "$clixon_util_xml -y $fyang -vo" 255 '<a xmlns="urn:example:example"><
rm -rf $dir
# unset conditional parameters
unset clixon_util_xml
new "endtest"
endtest

View file

@ -452,8 +452,5 @@ expectpart "$($clixon_util_xpath -D $DBG -f $dir/1.xml -n ex:urn:example:clixon
rm -rf $dir
# unset conditional parameters
unset clixon_util_xpath
new "endtest"
endtest

View file

@ -64,8 +64,5 @@ expectpart "$($clixon_util_xpath -c -y $ydir -p /i:x/j:y -n i:urn:example:c -n j
rm -rf $dir
# unset conditional parameters
unset clixon_util_xpath
new "endtest"
endtest

View file

@ -84,8 +84,5 @@ expectpart "$($clixon_util_xpath -If $xml1 -y $ydir -p /a:x/a:z[a:k='2'] -n b:ur
rm -rf $dir
# unset conditional parameters
unset clixon_util_xpath
new "endtest"
endtest

View file

@ -279,9 +279,6 @@ testrun false true
new "4. startup, treat unknown as anydata----"
testrun true true
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
new "endtest"

View file

@ -177,7 +177,5 @@ fi
rm -rf $dir
unset ret
new "endtest"
endtest

View file

@ -143,12 +143,7 @@ if [ $BE -ne 0 ]; then
stop_backend -f $cfg
fi
# Set by restconf_config
unset RESTCONFIG
rm -rf $dir
unset ret
new "endtest"
endtest

View file

@ -249,7 +249,5 @@ fi
rm -rf $dir
unset ret
new "endtest"
endtest

View file

@ -649,7 +649,5 @@ fi
rm -rf $dir
unset ret
new "endtest"
endtest