liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 320d436c65e3c0884167cfa1d82749864b982b35
parent befc75b060bd7479c57e968264864bf04f76ee69
Author: Daniel Barlow <dan@telent.net>
Date:   Wed,  8 Feb 2023 23:19:18 +0000

add wlan test to ci

Diffstat:
Mtests/ci.nix | 1+
Dtests/wlan/run.sh | 25-------------------------
Atests/wlan/test.nix | 39+++++++++++++++++++++++++++++++++++++++
Mtests/wlan/wait-for-wlan.expect | 2+-
4 files changed, 41 insertions(+), 26 deletions(-)

diff --git 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 @@ -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" diff --git a/tests/wlan/test.nix 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 <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 +'' diff --git 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 "/ #"