From e116e517910a38b28c668c5a0c5ebaf734b08ba6 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Tue, 25 Jan 2022 15:56:57 +0100 Subject: [PATCH] Test: added BE conditional for exiting backend (run your own backend) in multiple places where it was not in place. --- test/test_augment_trans.sh | 16 ++++++------ test/test_autocli_extension.sh | 16 ++++++------ test/test_autocli_listkey_compress.sh | 16 ++++++------ test/test_autocli_sub.sh | 16 ++++++------ test/test_autocli_treeref.sh | 16 ++++++------ test/test_cli_apipath.sh | 16 ++++++------ test/test_leaf_default.sh | 36 ++++++++++++++++----------- test/test_upgrade_simple.sh | 33 +++++++++++++----------- test/test_yang.sh | 20 +++++++-------- 9 files changed, 102 insertions(+), 83 deletions(-) diff --git a/test/test_augment_trans.sh b/test/test_augment_trans.sh index 0d497527..20e5fa9b 100755 --- a/test/test_augment_trans.sh +++ b/test/test_augment_trans.sh @@ -125,14 +125,16 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO&1)" 255 "Unknown command" -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg fi -# kill backend -stop_backend -f $cfg rm -rf $dir diff --git a/test/test_autocli_sub.sh b/test/test_autocli_sub.sh index 1d0199e7..50830e8e 100755 --- a/test/test_autocli_sub.sh +++ b/test/test_autocli_sub.sh @@ -152,14 +152,16 @@ EOF new "set p1 i2" expectpart "$(cat $fin | $clixon_cli -f $cfg 2>&1)" 0 'p142i1abc
' -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg fi -# kill backend -stop_backend -f $cfg rm -rf $dir diff --git a/test/test_autocli_treeref.sh b/test/test_autocli_treeref.sh index a3e09d22..c85d4023 100755 --- a/test/test_autocli_treeref.sh +++ b/test/test_autocli_treeref.sh @@ -199,14 +199,16 @@ expectpart "$(echo "show $top config parameter a value ?" | $clixon_cli -f $cfg #--------- @add:show+@add:nonconfig -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg fi -# kill backend -stop_backend -f $cfg rm -rf $dir diff --git a/test/test_cli_apipath.sh b/test/test_cli_apipath.sh index f9e3661b..f491f677 100755 --- a/test/test_cli_apipath.sh +++ b/test/test_cli_apipath.sh @@ -112,14 +112,16 @@ expectpart "$($clixon_cli -1 -f $cfg err x)" 255 "Config error: api-path syntax new "err x a" expectpart "$($clixon_cli -1 -f $cfg err x a 99)" 255 "Config error: api-path syntax error \"/example:x/m1=%s\": rpc malformed-message List key m1 length mismatch : Invalid argument" -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg fi -# kill backend -stop_backend -f $cfg endtest diff --git a/test/test_leaf_default.sh b/test/test_leaf_default.sh index 3b818b04..c971c231 100755 --- a/test/test_leaf_default.sh +++ b/test/test_leaf_default.sh @@ -228,11 +228,13 @@ if [ $? -ne 0 ]; then err "<${DATASTORE_TOP}>$SXML88" "$moreret" fi -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi fi # From startup 2, only presence p4, s4/np5 should be filled in @@ -258,11 +260,13 @@ wait_backend new "get startup config with presence" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XML]]>]]>$" -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi fi # Only single x list element @@ -288,11 +292,13 @@ wait_backend new "get startup config with list default" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^$XMLafalsefalse]]>]]>$" -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi fi rm -rf $dir diff --git a/test/test_upgrade_simple.sh b/test/test_upgrade_simple.sh index b30d33df..7837d16d 100755 --- a/test/test_upgrade_simple.sh +++ b/test/test_upgrade_simple.sh @@ -73,14 +73,16 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO $dir/$APPNAME.yang @@ -107,7 +109,6 @@ EOF # Now start again from running with modstate enabled and new revision if [ $BE -ne 0 ]; then - new "start backend -s running -f $cfg" start_backend -s running -f $cfg @@ -118,14 +119,16 @@ fi new "netconf get config" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f $cfg fi -# kill backend -stop_backend -f $cfg rm -rf $dir diff --git a/test/test_yang.sh b/test/test_yang.sh index c884a2f4..c0aa9a5c 100755 --- a/test/test_yang.sh +++ b/test/test_yang.sh @@ -278,19 +278,17 @@ expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO< new "netconf submodule discard-changes" expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" -if [ "$BE" -eq 0 ]; then - exit # BE +if [ $BE -ne 0 ]; then + new "Kill backend" + # Check if premature kill + pid=$(pgrep -u root -f clixon_backend) + if [ -z "$pid" ]; then + err "backend already dead" + fi + # kill backend + stop_backend -f "$cfg" fi -new "Kill backend" -# Check if premature kill -pid=$(pgrep -u root -f clixon_backend) -if [ -z "$pid" ]; then - err "backend already dead" -fi -# kill backend -stop_backend -f "$cfg" - rm -rf "$dir" new "endtest"