liminix

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

test.nix (1013B)


      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 mips-vm;
     11 in pkgs.runCommand "check" {
     12   nativeBuildInputs = with pkgs; [
     13     python3Packages.scapy
     14     expect
     15     jq
     16     socat
     17     routeros.routeros
     18     mips-vm
     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 
     26 . ${../test-helpers.sh}
     27 
     28 routeros $serverstatedir
     29 mkdir vm
     30 mips-vm --background ./vm ${img}/vmlinux ${img}/rootfs
     31 expect ${./getaddress.expect}
     32 
     33 set -o pipefail
     34 response=$(python ${./test-dhcp-service.py})
     35 echo "$response" | jq -e 'select((.router ==  "192.168.19.1") and (.server_id=="192.168.19.1"))'
     36 echo $response > $out
     37 ''