add wlan test to ci

module-based-network
Daniel Barlow 2023-02-08 23:19:18 +00:00
parent befc75b060
commit 320d436c65
4 changed files with 41 additions and 26 deletions

View File

@ -1,5 +1,6 @@
{
smoke = import ./smoke/test.nix;
pseudofiles = import ./pseudofiles/test.nix;
wlan = import ./wlan/test.nix;
pppoe = import ./pppoe/test.nix;
}

View File

@ -1,25 +0,0 @@
#!/usr/bin/env sh
cleanup(){
if test -e foo.pid && test -d /proc/`cat foo.pid` ; then
echo "killing qemu"
kill `cat foo.pid`
fi
}
trap cleanup EXIT
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>" -A outputs.default $*
../../scripts/run-qemu.sh \
--background foo.sock \
result/vmlinux result/squashfs \
nix-shell -p expect --run "expect wait-for-wlan.expect"

39
tests/wlan/test.nix Normal file
View File

@ -0,0 +1,39 @@
{
liminix
, nixpkgs
}:
let img = (import liminix {
device = import "${liminix}/devices/qemu/";
liminix-config = ./configuration.nix;
}).outputs.default;
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
inherit (pkgs.pkgsBuildBuild) mips-vm;
in pkgs.runCommand "check" {
nativeBuildInputs = with pkgs; [
expect
mips-vm
socat
] ;
} ''
killpid(){
if test -e $1 && test -d /proc/`cat $1` ; then
pid=$(cat $1)
kill $pid
fi
}
cleanup(){
killpid ./vm/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}/squashfs
expect ${./wait-for-wlan.expect} > output && mv output $out
''

View File

@ -1,6 +1,6 @@
set timeout 60
spawn socat unix-connect:foo.sock -
spawn socat unix-connect:vm/console -
send "\r\n"
expect "login:" { send "root\r\n" }
expect "/ #"