commit db54c877d698c1f93bc66c8e5eeace4919f02a92
parent 54a1ab3529c9294d12e1a3f4e0a7c5c8897afd0d
Author: Daniel Barlow <dan@telent.net>
Date: Thu, 6 Apr 2023 20:58:26 +0100
add CI test for jffs2
Diffstat:
4 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/tests/ci.nix b/tests/ci.nix
@@ -3,4 +3,5 @@
pseudofiles = import ./pseudofiles/test.nix;
wlan = import ./wlan/test.nix;
pppoe = import ./pppoe/test.nix;
+ jffs2 = import ./jffs2/test.nix;
}
diff --git a/tests/jffs2/configuration.nix b/tests/jffs2/configuration.nix
@@ -0,0 +1,7 @@
+{ config, pkgs, lib, ... } :
+{
+ imports = [
+ ../../vanilla-configuration.nix
+ ../../modules/jffs2.nix
+ ];
+}
diff --git a/tests/jffs2/script.expect b/tests/jffs2/script.expect
@@ -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
+\ No newline at end of file
diff --git a/tests/jffs2/test.nix b/tests/jffs2/test.nix
@@ -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
+''