automated test for pppoe
This commit is contained in:
parent
f3f51ac6be
commit
cbee488d22
3 changed files with 35 additions and 10 deletions
|
@ -3,8 +3,9 @@
|
|||
|
||||
if test "$1" = "--background" ; then
|
||||
socket=$2
|
||||
echo "running in background, socket is $socket"
|
||||
flags="--daemonize -chardev socket,id=sock,path=$2,server=on,wait=off,mux=on -mon chardev=sock,mode=readline -serial chardev:sock "
|
||||
pid="`dirname $socket`/`basename $socket .sock`.pid"
|
||||
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
|
||||
else
|
||||
flags="-serial mon:stdio"
|
||||
|
|
19
tests/pppoe/getaddress.expect
Normal file
19
tests/pppoe/getaddress.expect
Normal 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
|
|
@ -1,20 +1,25 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
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 '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 $*
|
||||
|
||||
|
||||
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"
|
||||
exit 1
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue