From 320d436c65e3c0884167cfa1d82749864b982b35 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Wed, 8 Feb 2023 23:19:18 +0000 Subject: [PATCH] add wlan test to ci --- tests/ci.nix | 1 + tests/wlan/run.sh | 25 --------------------- tests/wlan/test.nix | 39 +++++++++++++++++++++++++++++++++ tests/wlan/wait-for-wlan.expect | 2 +- 4 files changed, 41 insertions(+), 26 deletions(-) delete mode 100755 tests/wlan/run.sh create mode 100644 tests/wlan/test.nix diff --git a/tests/ci.nix b/tests/ci.nix index a2cf78f..2ab6b67 100644 --- a/tests/ci.nix +++ b/tests/ci.nix @@ -1,5 +1,6 @@ { smoke = import ./smoke/test.nix; pseudofiles = import ./pseudofiles/test.nix; + wlan = import ./wlan/test.nix; pppoe = import ./pppoe/test.nix; } diff --git a/tests/wlan/run.sh b/tests/wlan/run.sh deleted file mode 100755 index dd9568e..0000000 --- a/tests/wlan/run.sh +++ /dev/null @@ -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 '' -I liminix-config=./configuration.nix --arg device "import " -A outputs.default $* - - - -../../scripts/run-qemu.sh \ - --background foo.sock \ - result/vmlinux result/squashfs \ - -nix-shell -p expect --run "expect wait-for-wlan.expect" diff --git a/tests/wlan/test.nix b/tests/wlan/test.nix new file mode 100644 index 0000000..b5f0682 --- /dev/null +++ b/tests/wlan/test.nix @@ -0,0 +1,39 @@ +{ + liminix +, nixpkgs +}: +let img = (import liminix { + device = import "${liminix}/devices/qemu/"; + liminix-config = ./configuration.nix; + }).outputs.default; + pkgs = import { 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 +'' diff --git a/tests/wlan/wait-for-wlan.expect b/tests/wlan/wait-for-wlan.expect index 4e2f8a0..d3b8576 100644 --- a/tests/wlan/wait-for-wlan.expect +++ b/tests/wlan/wait-for-wlan.expect @@ -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 "/ #"