liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

test.nix (969B)


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