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
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`.

View file

@ -661,7 +661,7 @@ function wait_snmp()
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
function endtest()
{
@ -679,7 +679,7 @@ function new(){
>&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()
{
unset CURLOPTS

View file

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

View file

@ -19,6 +19,7 @@ mkdir $dir/www/data
# Does not work with fcgi
if [ "${WITH_RESTCONF}" = "fcgi" ]; then
echo "...skipped: Must run with --with-restconf=native"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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
if ! [ -x "$(command -v ssh)" ]; then
echo "...ssh not installed"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
# Dont run this test with valgrind
if [ $valgrindtest -ne 0 ]; then
echo "...skipped "
rm -rf $dir
return 0 # skip
fi

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,6 +16,7 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
if ! ${HAVE_HTTP1}; then
echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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
echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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 ! ${HAVE_HTTP1}; then
echo "...skipped: must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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
if [ "${WITH_RESTCONF}" != "native" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
# Cant make it work in sum.sh...
if ! ${HAVE_HTTP1}; then
echo "...skipped: must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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
if [ "${WITH_RESTCONF}" = "native" -a ${HAVE_HTTP1} = false ]; then
echo "...skipped: Must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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
if [ "${WITH_RESTCONF}" != "native" ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
if ! ${HAVE_HTTP1}; then
echo "...skipped: HAVE_HTTP1 is false, must run with http/1"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi
fi
# Skip if valgrind restconf (actually valgrind version < 3.16 27 May 2020)
if [ $valgrindtest -eq 3 ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
@ -30,6 +33,7 @@ fi
ip netns 2> /dev/null
if [ $? -ne 0 ]; then
echo "...ip netns does not work"
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
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
if [ "${WITH_RESTCONF}" != "fcgi" -o "$RCPROTO" = https ]; then
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; fi # skip
fi
# 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}
SLEEP5=.5
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
echo "...skipped: YANG_PATCH JSON NYI"
rm -rf $dir
if [ -z "${CLIXON_YANG_PATCH}" -a "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=example

View file

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

View file

@ -9,6 +9,7 @@ APPNAME=example
if [ ${ENABLE_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled."
rm -rf $dir
if [ "$s" = $0 ]; then exit 0; else return 0; 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" \
new "Cleaning up"
# testexit
testexit
rm -rf $dir
new "endtest"
endtest

View file

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

View file

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

View file

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

View file

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

View file

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