commit 34442b6069756c6dd2eeb8f576a921436df18ae8
parent b8a46fc05ee72df6f82a94b747918b4e2c21cfb0
Author: Daniel Barlow <dan@telent.net>
Date: Tue, 12 Mar 2024 23:41:46 +0000
failing test for ifwait
Diffstat:
4 files changed, 104 insertions(+), 0 deletions(-)
diff --git a/tests/ci.nix b/tests/ci.nix
@@ -8,4 +8,5 @@
min-copy-closure = import ./min-copy-closure/test.nix;
fennel = import ./fennel/test.nix;
tftpboot = import ./tftpboot/test.nix;
+ updown = import ./updown/test.nix;
}
diff --git a/tests/updown/configuration.nix b/tests/updown/configuration.nix
@@ -0,0 +1,55 @@
+{ config, pkgs, lib, ... } :
+let
+ inherit (pkgs.liminix.services) bundle oneshot longrun;
+ inherit (pkgs) serviceFns;
+ # EDIT: you can pick your preferred RFC1918 address space
+ # for NATted connections, if you don't like this one.
+ ipv4LocalNet = "10.8.0";
+ svc = config.system.service;
+
+in rec {
+ imports = [
+ ../../modules/bridge
+ ../../modules/dhcp6c
+ ../../modules/dnsmasq
+ ../../modules/firewall
+ ../../modules/hostapd
+ ../../modules/network
+ ../../modules/ssh
+ ../../modules/vlan
+ ../../modules/wlan.nix
+ ];
+ rootfsType = "jffs2";
+ hostname = "updown";
+
+ services.int = svc.network.address.build {
+ interface = svc.bridge.primary.build { ifname = "int"; };
+ family = "inet"; address = "${ipv4LocalNet}.1"; prefixLength = 16;
+ };
+
+ services.bridge = svc.bridge.members.build {
+ primary = services.int;
+ members = with config.hardware.networkInterfaces;
+ [ lan ];
+ };
+
+ services.sshd = svc.ssh.build { };
+
+ # users.root = {
+ # # EDIT: choose a root password and then use
+ # # "mkpasswd -m sha512crypt" to determine the hash.
+ # # It should start wirh $6$.
+ # passwd = "$6$6HG7WALLQQY1LQDE$428cnouMJ7wVmyK9.dF1uWs7t0z9ztgp3MHvN5bbeo0M4Kqg/u2ThjoSHIjCEJQlnVpDOaEKcOjXAlIClHWN21";
+ # openssh.authorizedKeys.keys = [
+ # # EDIT: you can add your ssh pubkey here
+ # # "ssh-rsa AAAAB3NzaC1....H6hKd user@example.com";
+ # ];
+ # };
+
+ defaultProfile.packages = with pkgs; [
+ min-collect-garbage
+# strace
+ # ethtool
+ tcpdump
+ ];
+}
diff --git a/tests/updown/script.expect b/tests/updown/script.expect
@@ -0,0 +1,29 @@
+set timeout 10
+
+spawn socat unix-connect:vm/monitor -
+set monitor_id $spawn_id
+
+expect "(qemu)"
+send "set_link virtio-net-pci.1 off\n"
+expect "(qemu)"
+send "set_link virtio-net-pci.0 off\n"
+expect "(qemu)"
+send "c\r\n"
+spawn socat unix-connect:vm/console -
+set console_id $spawn_id
+
+expect "BusyBox"
+expect "#" { send "PS1=RE\\ADY_\\ \r" }
+expect "READY_" { send "sleep 3\r" }
+expect "READY_" { send "ip link\r" }
+expect "READY_" { send "cat /sys/class/net/lan/operstate\r" }
+expect {
+ "down" { }
+ "up" { exit 1 }
+}
+expect "READY_" { send "s6-rc -a -u change\r" }
+expect {
+ "unable to take locks" { exit 1 }
+ "READY_" { send "hostname\r" }
+}
+expect "updown"
diff --git a/tests/updown/test.nix b/tests/updown/test.nix
@@ -0,0 +1,19 @@
+{
+ liminix
+, nixpkgs
+}:
+let img = (import liminix {
+ device = import "${liminix}/devices/qemu/";
+ liminix-config = ./configuration.nix;
+ }).outputs.vmroot;
+ pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
+in pkgs.runCommand "check" {
+ nativeBuildInputs = with pkgs; [
+ expect
+ socat
+ ] ;
+} ''
+mkdir vm
+${img}/run.sh --flag -S --background ./vm
+expect ${./script.expect} | tee $out
+''