Test: remove testdir also if skip test

This commit is contained in:
Olof hagsand 2022-09-03 13:07:26 +02:00
parent 71fc85af0b
commit 5e2643c382
26 changed files with 69 additions and 18 deletions

View file

@ -164,7 +164,10 @@ Clixon snmp frontend tests require a running netsnmpd and converted YANG files f
Netsnmpd is 5.9 or later and can be started via systemd. For the tests Netsnmpd is 5.9 or later and can be started via systemd. For the tests
to run, the systems IFMIB should be disabled: `-I -ifTable,ifNumber,ifXTable,`, etc. to run, the systems IFMIB should be disabled: `-I -ifTable,ifNumber,ifXTable,`, etc.
One way to start snmpd on Ubuntu, known to be working for the tests are: snmpd -Lo -p /var/run/snmpd.pid -I -ifXTable -I -ifTable -I -system_mib -I -sysORTable -I -snmpNotifyFilterTable -I -snmpNotifyTable -I -snmpNotifyFilterProfileTable One way to start snmpd on Ubuntu, known to be working for the tests is:
```
snmpd -c /etc/snmp/snmpd.conf -Lo -p /var/run/snmpd.pid -I -ifXTable -I -ifTable -I -system_mib -I -sysORTable -I -snmpNotifyFilterTable -I -snmpNotifyTable -I -snmpNotifyFilterProfileTable
```
Converted YANG files are available at `https://github.com/clicon/mib-yangs` or alternatively use `smidump` version 0.5 or later. Clixon expects them to be at `/usr/local/share/mib-yangs/` by default, or configured by `--with-mib-generated-yang-dir=DIR`. Converted YANG files are available at `https://github.com/clicon/mib-yangs` or alternatively use `smidump` version 0.5 or later. Clixon expects them to be at `/usr/local/share/mib-yangs/` by default, or configured by `--with-mib-generated-yang-dir=DIR`.

View file

@ -661,7 +661,7 @@ function wait_snmp()
done done
} }
# End of test, final tests before normal exit of test # 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 # Note this is a single test started by new, not a total test suite
function endtest() function endtest()
{ {
@ -679,7 +679,7 @@ function new(){
>&2 echo "Test $testi($testnr) [$1]" >&2 echo "Test $testi($testnr) [$1]"
} }
# End of complete test-suite, eg a test file # End of complete test-suite, eg a test file, mem.sh
function endsuite() function endsuite()
{ {
unset CURLOPTS unset CURLOPTS

View file

@ -27,6 +27,7 @@ fi
if [ ! -d "$OPENCONFIG" ]; then if [ ! -d "$OPENCONFIG" ]; then
# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" # err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?"
echo "...skipped: OPENCONFIG not set" echo "...skipped: OPENCONFIG not set"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
OCDIR=$OPENCONFIG/release/models OCDIR=$OPENCONFIG/release/models

View file

@ -19,6 +19,7 @@ mkdir $dir/www/data
# Does not work with fcgi # Does not work with fcgi
if [ "${WITH_RESTCONF}" = "fcgi" ]; then if [ "${WITH_RESTCONF}" = "fcgi" ]; then
echo "...skipped: Must run with --with-restconf=native" echo "...skipped: Must run with --with-restconf=native"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -7,12 +7,14 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Skip it if no openssh # Skip it if no openssh
if ! [ -x "$(command -v ssh)" ]; then if ! [ -x "$(command -v ssh)" ]; then
echo "...ssh not installed" echo "...ssh not installed"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi fi
# Dont run this test with valgrind # Dont run this test with valgrind
if [ $valgrindtest -ne 0 ]; then if [ $valgrindtest -ne 0 ]; then
echo "...skipped " echo "...skipped "
rm -rf $dir
return 0 # skip return 0 # skip
fi fi

View file

@ -20,6 +20,7 @@ new "openconfig"
if [ ! -d "$OPENCONFIG" ]; then if [ ! -d "$OPENCONFIG" ]; then
# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" # err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?"
echo "...skipped: OPENCONFIG not set" echo "...skipped: OPENCONFIG not set"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -14,6 +14,7 @@ new "openconfig"
if [ ! -d "$OPENCONFIG" ]; then if [ ! -d "$OPENCONFIG" ]; then
# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" # err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?"
echo "...skipped: OPENCONFIG not set" echo "...skipped: OPENCONFIG not set"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -14,6 +14,7 @@ new "openconfig"
if [ ! -d "$OPENCONFIG" ]; then if [ ! -d "$OPENCONFIG" ]; then
# err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?" # err "Hmm Openconfig dir does not seem to exist, try git clone https://github.com/openconfig/public?"
echo "...skipped: OPENCONFIG not set" echo "...skipped: OPENCONFIG not set"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -10,12 +10,14 @@ APPNAME=example
if [ -z "$(type expect 2> /dev/null)" ]; then if [ -z "$(type expect 2> /dev/null)" ]; then
echo "...skipped: Expect not installed" echo "...skipped: Expect not installed"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
# Skip test if valgrind # Skip test if valgrind
if [ $valgrindtest -ne 0 ]; then if [ $valgrindtest -ne 0 ]; then
echo "...skipped for valgrind " echo "...skipped for valgrind "
rm -rf $dir
return 0 # skip return 0 # skip
fi fi

View file

@ -13,6 +13,7 @@ APPNAME=example
# Dont run this test with valgrind # Dont run this test with valgrind
if [ $valgrindtest -ne 0 ]; then if [ $valgrindtest -ne 0 ]; then
echo "...skipped " echo "...skipped "
rm -rf $dir
return 0 # skip return 0 # skip
fi fi

View file

@ -16,6 +16,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
if ! ${HAVE_HTTP1}; then if ! ${HAVE_HTTP1}; then
echo "...skipped: Must run with http/1" echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -8,6 +8,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
if ! ${HAVE_HTTP1}; then if ! ${HAVE_HTTP1}; then
echo "...skipped: Must run with http/1" echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -29,6 +29,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
#if ! ${HAVE_HTTP1}; then #if ! ${HAVE_HTTP1}; then
echo "...skipped: must run with http/1" echo "...skipped: must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -12,12 +12,14 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Only works with native # Only works with native
if [ "${WITH_RESTCONF}" != "native" ]; then if [ "${WITH_RESTCONF}" != "native" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi fi
# Cant make it work in sum.sh... # Cant make it work in sum.sh...
if ! ${HAVE_HTTP1}; then if ! ${HAVE_HTTP1}; then
echo "...skipped: must run with http/1" echo "...skipped: must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -17,6 +17,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Does not work with native http/2-only # Does not work with native http/2-only
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
echo "...skipped: Must run with http/1" echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -28,6 +28,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Does not work with native http/2-only # Does not work with native http/2-only
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
echo "...skipped: Must run with http/1" echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi

View file

@ -13,16 +13,19 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Skip if other than native # Skip if other than native
if [ "${WITH_RESTCONF}" != "native" ]; then if [ "${WITH_RESTCONF}" != "native" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi fi
if ! ${HAVE_HTTP1}; then if ! ${HAVE_HTTP1}; then
echo "...skipped: HAVE_HTTP1 is false, must run with http/1" echo "...skipped: HAVE_HTTP1 is false, must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
# Skip if valgrind restconf (actually valgrind version < 3.16 27 May 2020) # Skip if valgrind restconf (actually valgrind version < 3.16 27 May 2020)
if [ $valgrindtest -eq 3 ]; then if [ $valgrindtest -eq 3 ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi fi
@ -30,6 +33,7 @@ fi
ip netns 2> /dev/null ip netns 2> /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "...ip netns does not work" echo "...ip netns does not work"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi fi

View file

@ -29,11 +29,15 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Skip it other than fcgi and http # Skip it other than fcgi and http
if [ "${WITH_RESTCONF}" != "fcgi" -o "$RCPROTO" = https ]; then if [ "${WITH_RESTCONF}" != "fcgi" -o "$RCPROTO" = https ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi fi
# Skip regardless, broken in 5.7 # Skip regardless, broken in 5.7
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip if true; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
: ${SLEEP2:=1} : ${SLEEP2:=1}
SLEEP5=.5 SLEEP5=.5
APPNAME=example APPNAME=example

View file

@ -9,6 +9,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
# Enable if YANG_PATCH # Enable if YANG_PATCH
echo "...skipped: YANG_PATCH JSON NYI" echo "...skipped: YANG_PATCH JSON NYI"
rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example APPNAME=example

View file

@ -8,6 +8,7 @@
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
echo "...skipped: YANG_PATCH XML NYI" echo "...skipped: YANG_PATCH XML NYI"
rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example APPNAME=example

View file

@ -9,6 +9,7 @@ APPNAME=example
if [ ${ENABLE_NETSNMP} != "yes" ]; then if [ ${ENABLE_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled." echo "Skipping test, Net-SNMP support not enabled."
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
@ -510,7 +511,9 @@ expectpart "$($snmpwalk $ENTITY_OID)" 0 "SNMPv2-SMI::mib-2.47.1.1.1.1.1.1 = INTE
"SNMPv2-SMI::mib-2.47.1.1.1.1.16.2 = INTEGER: 0" \ "SNMPv2-SMI::mib-2.47.1.1.1.1.16.2 = INTEGER: 0" \
new "Cleaning up" new "Cleaning up"
# testexit testexit
rm -rf $dir
new "endtest" new "endtest"
endtest endtest

View file

@ -9,6 +9,7 @@ APPNAME=example
if [ ${ENABLE_NETSNMP} != "yes" ]; then if [ ${ENABLE_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled." echo "Skipping test, Net-SNMP support not enabled."
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
@ -282,5 +283,7 @@ expectpart "$($snmpgetnext $OID19)" 0 "$OID20 = INTEGER: 1"
new "Cleaning up" new "Cleaning up"
testexit testexit
rm -rf $dir
new "endtest" new "endtest"
endtest endtest

View file

@ -9,6 +9,7 @@ APPNAME=example
if [ ${ENABLE_NETSNMP} != "yes" ]; then if [ ${ENABLE_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled." echo "Skipping test, Net-SNMP support not enabled."
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
@ -162,19 +163,21 @@ EOF
function testinit(){ function testinit(){
new "test params: -f $cfg -- -sS $fstate" new "test params: -f $cfg -- -sS $fstate"
if [ $BE -ne 0 ]; then if [ $BE -ne 0 ]; then
# Kill old backend and start a new one # Kill old backend and start a new one
new "kill old backend" new "kill old backend"
sudo clixon_backend -zf $cfg sudo clixon_backend -zf $cfg
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err "Failed to start backend" err "Failed to start backend"
fi
sudo pkill -f clixon_backend
new "Starting backend"
start_backend -s init -f $cfg -- -sS $fstate
fi fi
if true; then
sudo pkill -f clixon_backend rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi
new "Starting backend" fi
start_backend -s init -f $cfg -- -sS $fstate
fi
new "wait backend" new "wait backend"
wait_backend wait_backend
@ -195,9 +198,11 @@ function testexit(){
stop_snmp stop_snmp
} }
new "SNMP tests" new "SNMP tests"
testinit testinit
# IF-MIB::interfaces # IF-MIB::interfaces
MIB=".1.3.6.1.2.1" MIB=".1.3.6.1.2.1"
for (( i=1; i<23; i++ )); do for (( i=1; i<23; i++ )); do
@ -465,5 +470,7 @@ expectpart "$($snmpwalk IF-MIB::ifRcvAddressTable)" 0 "IF-MIB::ifRcvAddressAddre
testexit testexit
rm -rf $dir
new "endtest" new "endtest"
endtest endtest

View file

@ -9,6 +9,7 @@ APPNAME=example
# XXX skip for now # XXX skip for now
if [ ${ENABLE_NETSNMP} != "yes" ]; then if [ ${ENABLE_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled." echo "Skipping test, Net-SNMP support not enabled."
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
@ -222,5 +223,7 @@ testrun_removeRows
new "Cleaning up" new "Cleaning up"
testexit testexit
rm -rf $dir
new "endtest" new "endtest"
endtest endtest

View file

@ -8,9 +8,9 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example APPNAME=example
# XXX skip for now
if [ ${ENABLE_NETSNMP} != "yes" ]; then if [ ${ENABLE_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled." echo "Skipping test, Net-SNMP support not enabled."
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
@ -244,5 +244,7 @@ expectpart "$($clixon_cli -1 -f $cfg show config xml)" 0 "<$name>active</$name>"
new "Cleaning up" new "Cleaning up"
testexit testexit
rm -rf $dir
new "endtest" new "endtest"
endtest endtest

View file

@ -9,6 +9,7 @@ APPNAME=example
if [ ${ENABLE_NETSNMP} != "yes" ]; then if [ ${ENABLE_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled." echo "Skipping test, Net-SNMP support not enabled."
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi fi
@ -235,5 +236,7 @@ expectpart "$($snmpwalkstr system)" 0 "SNMPv2-MIB::sysDescr = STRING: System des
new "Cleaning up" new "Cleaning up"
testexit testexit
rm -rf $dir
new "endtest" new "endtest"
endtest endtest