test.nix (1083B)
1 let 2 img = 3 (import <liminix> { 4 device = import <liminix/devices/qemu>; 5 liminix-config = ./configuration.nix; 6 }).outputs.default; 7 pkgs = import <nixpkgs> { overlays = [ (import ../../overlay.nix) ]; }; 8 inherit (pkgs.pkgsBuildBuild) routeros; 9 in 10 pkgs.runCommand "check" 11 { 12 nativeBuildInputs = with pkgs; [ 13 python3Packages.scapy 14 expect 15 jq 16 socat 17 routeros.routeros 18 ]; 19 } 20 '' 21 serverstatedir=$(mktemp -d -t routeros-XXXXXX) 22 # python scapy drags in matplotlib which doesn't enjoy running in 23 # a sandbox with no $HOME, hence this environment variable 24 export MPLCONFIGDIR=$(mktemp -d -t routeros-XXXXXX) 25 export XDG_CONFIG_HOME=/tmp 26 export XDG_CACHE_HOME=/tmp 27 28 . ${../test-helpers.sh} 29 30 routeros $serverstatedir 31 mkdir vm 32 ${img}/run.sh --background ./vm 33 expect ${./getaddress.expect} 34 35 set -o pipefail 36 response=$(python ${./test-dhcp-service.py}) 37 echo "$response" | jq -e 'select((.router == "192.168.19.1") and (.server_id=="192.168.19.1"))' 38 echo $response > $out 39 ''