add CI test for jffs2

This commit is contained in:
Daniel Barlow 2023-04-06 20:58:26 +01:00
parent 54a1ab3529
commit db54c877d6
4 changed files with 63 additions and 0 deletions

View file

@ -3,4 +3,5 @@
pseudofiles = import ./pseudofiles/test.nix; pseudofiles = import ./pseudofiles/test.nix;
wlan = import ./wlan/test.nix; wlan = import ./wlan/test.nix;
pppoe = import ./pppoe/test.nix; pppoe = import ./pppoe/test.nix;
jffs2 = import ./jffs2/test.nix;
} }

View file

@ -0,0 +1,7 @@
{ config, pkgs, lib, ... } :
{
imports = [
../../vanilla-configuration.nix
../../modules/jffs2.nix
];
}

11
tests/jffs2/script.expect Normal file
View file

@ -0,0 +1,11 @@
set timeout 10
spawn socat unix-connect:vm/console -
send "\r\n"
expect "login:" { send "root\r\n" }
expect "#"
send "echo HELLO WORLD > /hello\r\n"
expect "#"
send "cat /hello\r\n"
expect 'HELLO WORLD'
close

44
tests/jffs2/test.nix Normal file
View file

@ -0,0 +1,44 @@
{
liminix
, nixpkgs
}:
let img = (import liminix {
device = import "${liminix}/devices/qemu/";
liminix-config = ./configuration.nix;
}).outputs.jffs2boot;
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
inherit (pkgs.pkgsBuildBuild) routeros mips-vm;
in pkgs.runCommand "check" {
nativeBuildInputs = with pkgs; [
mips-vm
expect
socat
] ;
} ''
serverstatedir=$(mktemp -d -t routeros-XXXXXX)
killpid(){
if test -e $1 && test -d /proc/`cat $1` ; then
pid=$(cat $1)
kill $pid
fi
}
cleanup(){
killpid $serverstatedir/pid
test -n "$MPLCONFIGDIR" && test -d "$MPLCONFIGDIR" && rm -rf "$MPLCONFIGDIR"
killpid foo.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}/rootfs ${img}/initramfs
expect ${./script.expect} >$out
''