homogenize the way we kill background processes
kill_bg : -takes the PID of the process to kill -differentiates the sudo case from the non-sudo case
This commit is contained in:
parent
083c37802a
commit
08c28f2513
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -16,7 +17,7 @@ sleep 2
|
||||
|
||||
echo "Closing native node"
|
||||
sleep 2
|
||||
kill -9 ${CPID}
|
||||
kill_bg $CPID
|
||||
|
||||
if grep -q "=check-me= FAILED" $CODE.log ; then
|
||||
echo "==== make.log ====" ; cat make.log;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -38,8 +39,8 @@ HOPS=`wc $BASENAME.scriptlog -l | cut -f 1 -d ' '`
|
||||
|
||||
echo "Closing simulation and tunslip6"
|
||||
sleep 1
|
||||
kill -9 $JPID
|
||||
kill -9 $MPID
|
||||
kill_bg $JPID
|
||||
kill_bg $MPID
|
||||
sleep 1
|
||||
rm COOJA.testlog
|
||||
rm COOJA.log
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -22,7 +23,7 @@ STATUS=${PIPESTATUS[0]}
|
||||
|
||||
echo "Closing native node"
|
||||
sleep 2
|
||||
pgrep hello-world | sudo xargs kill -9
|
||||
kill_bg $CPID
|
||||
|
||||
if [ $STATUS -eq 0 ] ; then
|
||||
cp $BASENAME.log $BASENAME.testlog
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -38,7 +39,7 @@ done
|
||||
|
||||
echo "Closing native node"
|
||||
sleep 2
|
||||
pgrep coap-example | sudo xargs kill -9
|
||||
kill_bg $CPID
|
||||
|
||||
if [ $TESTCOUNT -eq $OKCOUNT ] ; then
|
||||
printf "%-32s TEST OK %3d/%d\n" "$BASENAME" "$OKCOUNT" "$TESTCOUNT" | tee $BASENAME.testlog;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -44,8 +45,8 @@ REPLIES=`grep -c 'icmp_seq=' $BASENAME.scriptlog`
|
||||
|
||||
echo "Closing simulation and tunslip6"
|
||||
sleep 1
|
||||
kill -9 $JPID
|
||||
kill -9 $MPID
|
||||
kill_bg $JPID
|
||||
kill_bg $MPID
|
||||
sleep 1
|
||||
rm COOJA.testlog
|
||||
rm COOJA.log
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -43,8 +44,8 @@ REPLIES=`grep -c 'icmp_seq=' $BASENAME.scriptlog`
|
||||
|
||||
echo "Closing simulation and nbr"
|
||||
sleep 1
|
||||
kill -9 $JPID
|
||||
kill -9 $MPID
|
||||
kill_bg $JPID
|
||||
kill_bg $MPID
|
||||
sleep 1
|
||||
rm COOJA.testlog
|
||||
rm COOJA.log
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -32,11 +33,11 @@ done
|
||||
|
||||
echo "Closing native node"
|
||||
sleep 1
|
||||
pgrep ipso | sudo xargs kill -9
|
||||
kill_bg $CPID
|
||||
|
||||
echo "Closing leshan"
|
||||
sleep 1
|
||||
pgrep java | sudo xargs kill -9
|
||||
kill_bg $LESHID
|
||||
|
||||
|
||||
if grep -q 'OK' leshan.err ; then
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
source ../utils.sh
|
||||
|
||||
# Contiki directory
|
||||
CONTIKI=$1
|
||||
@ -33,11 +34,11 @@ done
|
||||
|
||||
echo "Closing standalone example"
|
||||
sleep 1
|
||||
pgrep lwm2m-example | sudo xargs kill -9
|
||||
kill_bg $CPID
|
||||
|
||||
echo "Closing leshan"
|
||||
sleep 1
|
||||
pgrep java | sudo xargs kill -9
|
||||
kill_bg $LESHID
|
||||
|
||||
|
||||
if grep -q 'OK' leshan.err ; then
|
||||
|
20
tests/utils.sh
Executable file
20
tests/utils.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
function echo_run( )
|
||||
{
|
||||
echo $@
|
||||
$@
|
||||
}
|
||||
|
||||
function kill_bg( )
|
||||
{
|
||||
PID=$1
|
||||
CMD=$(ps -p $PID -o cmd=)
|
||||
SUDO=
|
||||
TOKILL=$PID
|
||||
if [[ ${CMD:0:5} == "sudo " ]] ; then
|
||||
SUDO="sudo "
|
||||
TOKILL=$(ps --ppid $PID -o pid=)
|
||||
fi
|
||||
echo_run ${SUDO}kill -9 $TOKILL
|
||||
}
|
Loading…
Reference in New Issue
Block a user