automated test for pppoe

This commit is contained in:
Daniel Barlow 2022-09-26 10:47:29 +01:00
parent f3f51ac6be
commit cbee488d22
3 changed files with 35 additions and 10 deletions

View file

@ -3,8 +3,9 @@
if test "$1" = "--background" ; then if test "$1" = "--background" ; then
socket=$2 socket=$2
echo "running in background, socket is $socket" pid="`dirname $socket`/`basename $socket .sock`.pid"
flags="--daemonize -chardev socket,id=sock,path=$2,server=on,wait=off,mux=on -mon chardev=sock,mode=readline -serial chardev:sock " echo "running in background, socket is $socket, pid $pid"
flags="--daemonize --pidfile $pid -chardev socket,id=sock,path=$2,server=on,wait=off,mux=on -mon chardev=sock,mode=readline -serial chardev:sock "
shift;shift shift;shift
else else
flags="-serial mon:stdio" flags="-serial mon:stdio"

View file

@ -0,0 +1,19 @@
set timeout 60
spawn socat unix-connect:foo.sock -
send "\r\n"
expect "login:" { send "root\r\n" }
expect "/ #"
set FINISHED 0
set EXIT "1"
while { $FINISHED < 5 } {
send "ip address show dev ppp0 | grep ppp0\r\n"
expect {
"192.168.100.1" { set FINISHED 10; set EXIT 0; }
"can't find device" { send_user "waiting ..." ; send "\r\n"; sleep 3 }
}
set FINISHED [ expr $FINISHED + 1 ]
}
exit $EXIT

View file

@ -1,20 +1,25 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -e
cleanup(){ cleanup(){
echo "do cleanup"; if test -e foo.pid && test -d /proc/`cat foo.pid` ; then
echo "killing qemu"
kill `cat foo.pid`
fi
} }
trap cleanup EXIT trap cleanup EXIT
trap 'echo "command $(eval echo $BASH_COMMAND) failed with exit code $?"; exit $?' ERR fatal(){
err=$?
echo "FAIL: command $(eval echo $BASH_COMMAND) exited with code $err"
exit $err
}
trap fatal ERR
NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu.nix>" -A outputs.default $* NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 nix-build '<liminix>' -I liminix-config=./configuration.nix --arg device "import <liminix/devices/qemu.nix>" -A outputs.default $*
if ! ( echo "cont" | socat - unix-connect:../support/ppp-server/qemu-monitor); then if ! ( echo "cont" | socat - unix-connect:../support/ppp-server/qemu-monitor); then
echo "need pppoe server running" echo "need pppoe server running"
exit 1 exit 1
fi fi
../../scripts/run-qemu.sh result/vmlinux result/squashfs ../../scripts/run-qemu.sh --background foo.sock result/vmlinux result/squashfs
nix-shell -p expect --run "expect getaddress.expect"