extract common shell fns in tests

This commit is contained in:
Daniel Barlow 2023-05-07 23:01:24 +01:00
parent d8cc6ab61c
commit 55387b0ee3
5 changed files with 24 additions and 78 deletions

View file

@ -15,29 +15,6 @@ in pkgs.runCommand "check" {
socat
] ;
} ''
serverstatedir=$(mktemp -d -t routeros-XXXXXX)
killpid(){
if test -e $1 && test -d /proc/`cat $1` ; then
pid=$(cat $1)
kill $pid
fi
}
cleanup(){
killpid $serverstatedir/pid
test -n "$MPLCONFIGDIR" && test -d "$MPLCONFIGDIR" && rm -rf "$MPLCONFIGDIR"
killpid foo.pid
}
trap cleanup EXIT
fatal(){
err=$?
echo "FAIL: command $(eval echo $BASH_COMMAND) exited with code $err"
exit $err
}
trap fatal ERR
mkdir vm
mips-vm --background ./vm ${img}/vmlinux ${img}/rootfs
expect ${./script.expect} >$out