2023-02-05 18:37:31 +01:00
|
|
|
{
|
|
|
|
liminix
|
|
|
|
, nixpkgs
|
|
|
|
}:
|
|
|
|
let img = (import liminix {
|
|
|
|
device = import "${liminix}/devices/qemu/";
|
|
|
|
liminix-config = ./configuration.nix;
|
|
|
|
}).outputs.default;
|
2023-02-08 19:10:11 +01:00
|
|
|
pkgs = import <nixpkgs> { overlays = [(import ../../overlay.nix)]; };
|
2023-09-20 19:33:08 +02:00
|
|
|
inherit (pkgs.pkgsBuildBuild) routeros run-liminix-vm;
|
2023-02-05 18:37:31 +01:00
|
|
|
in pkgs.runCommand "check" {
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
python3Packages.scapy
|
|
|
|
expect
|
|
|
|
jq
|
|
|
|
socat
|
2023-02-08 23:16:39 +01:00
|
|
|
routeros.routeros
|
2023-09-20 19:33:08 +02:00
|
|
|
run-liminix-vm
|
2023-02-05 18:37:31 +01:00
|
|
|
] ;
|
|
|
|
} ''
|
|
|
|
serverstatedir=$(mktemp -d -t routeros-XXXXXX)
|
|
|
|
# python scapy drags in matplotlib which doesn't enjoy running in
|
|
|
|
# a sandbox with no $HOME, hence this environment variable
|
|
|
|
export MPLCONFIGDIR=$(mktemp -d -t routeros-XXXXXX)
|
|
|
|
|
2023-05-08 00:01:24 +02:00
|
|
|
. ${../test-helpers.sh}
|
2023-02-05 18:37:31 +01:00
|
|
|
|
|
|
|
routeros $serverstatedir
|
2023-02-08 23:16:39 +01:00
|
|
|
mkdir vm
|
2023-09-20 19:33:08 +02:00
|
|
|
run-liminix-vm --background ./vm ${img}/vmlinux ${img}/rootfs
|
2023-02-05 18:37:31 +01:00
|
|
|
expect ${./getaddress.expect}
|
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
response=$(python ${./test-dhcp-service.py})
|
|
|
|
echo "$response" | jq -e 'select((.router == "192.168.19.1") and (.server_id=="192.168.19.1"))'
|
|
|
|
echo $response > $out
|
|
|
|
''
|