Valgrind tests for clixon_snmp.

This commit is contained in:
Kristofer Hallin 2022-04-27 21:03:47 +02:00 committed by Olof hagsand
parent 28514c6750
commit 366b1cb42f
3 changed files with 40 additions and 17 deletions

View file

@ -415,6 +415,30 @@ function chunked_framing()
printf "\n#%s\n%s\n##\n" ${length} "${str}"
}
# Start clixon_snmp
function start_snmp(){
cfg=$1
$clixon_snmp -f $cfg -D $DBG -l s &
if [ $? -ne 0 ]; then
err
fi
if [ $valgrindtest != 0 ]; then
checkvalgrind
fi
}
# Stop clixon_snmp and Valgrind if needed
function stop_snmp(){
if [ $valgrindtest != 0 ]; then
kill `ps aux | grep [v]algrind | awk '{print $2}' | tail -n1`
else
killall clixon_snmp
fi
}
# Start backend with all varargs.
# If valgrindtest == 2, start valgrind
function start_backend(){

View file

@ -18,6 +18,7 @@ function memonce(){
clixon_netconf=
clixon_backend=
clixon_restconf=
clixon_snmp=
case "$what" in
'cli')
valgrindtest=1
@ -43,8 +44,15 @@ function memonce(){
clixon_restconf="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile clixon_restconf"
;;
'snmp')
valgrindtest=1 # This means snmp valgrind test
sudo chmod 660 $valgrindfile
: ${DEMWAIT:=15} # valgrind backend needs some time to get up
clixon_snmp="/usr/bin/valgrind --num-callers=50 --leak-check=full --show-leak-kinds=all --suppressions=./valgrind-clixon.supp --track-fds=yes --trace-children=no --child-silent-after-fork=yes --log-file=$valgrindfile /usr/local/sbin/clixon_snmp"
;;
*)
echo "usage: $0 cli|netconf|restconf|backend" # valgrind memleak checks
echo "usage: $0 cli|netconf|restconf|backend|snmp" # valgrind memleak checks
rm -f $valgrindfile
exit -1
;;
@ -86,16 +94,16 @@ function println(){
}
if [ -z "$*" ]; then
cmds="backend restconf cli netconf"
cmds="backend restconf cli netconf snmp"
else
cmds=$*
fi
# First run sanity
for c in $cmds; do
if [ $c != cli -a $c != netconf -a $c != restconf -a $c != backend ]; then
if [ $c != cli -a $c != netconf -a $c != restconf -a $c != backend -a $c != snmp ]; then
echo "c:$c"
echo "usage: $0 [cli|netconf|restconf|backend]+"
echo "usage: $0 [cli|netconf|restconf|backend|snmp]+"
echo " with no args run all"
exit -1
fi

View file

@ -5,12 +5,6 @@ s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi
APPNAME=snmp
# Dont run this test with valgrind
if [ $valgrindtest -ne 0 ]; then
echo "...skipped "
return 0 # skip
fi
if [ ${WITH_NETSNMP} != "yes" ]; then
echo "Skipping test, Net-SNMP support not enabled."
if [ "$s" = $0 ]; then exit 0; else return 0; fi
@ -76,18 +70,15 @@ function testinit(){
sudo killall clixon_snmp
new "Starting clixon_snmp"
$clixon_snmp -f $cfg -D $DBG -l s &
start_snmp $cfg &
sleep 1
pgrep clixon_snmp
if [ $? != 0 ]; then
err "Failed to start clixon_snmp"
fi
# Wait for things to settle
sleep 3
}
function testexit(){
sudo killall snmpd
stop_snmp
}
new "SNMP tests"