From b79576247f23deefc8bfbb006c71d4d26570ab22 Mon Sep 17 00:00:00 2001 From: Stephan Maka Date: Tue, 9 Apr 2019 20:41:46 +0200 Subject: [PATCH] windows tests: run for all artiq conda pkgs --- artiq/windows/default.nix | 88 +++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/artiq/windows/default.nix b/artiq/windows/default.nix index 7d2b66a..ff14798 100644 --- a/artiq/windows/default.nix +++ b/artiq/windows/default.nix @@ -2,11 +2,7 @@ diskImage ? "/opt/windows/c.img", qemuMem ? "2G", testTimeout ? 120, - # This artiqPkg should be a current build passed by the caller - artiqPkg ? (pkgs.fetchurl { - url = "https://nixbld.m-labs.hk/build/2316/download/1/artiq-5e.b8e2b82a-0.tar.bz2"; - sha256 = "0gisv3a17rnwavsifpz4cfnqvlssv37pysi2qx41k67rmcpqcs98"; - }), + artiq ? import ./.. { inherit pkgs; }, }: with pkgs; @@ -40,40 +36,50 @@ let scp -P 2022 ${sshOpts} \ "${src}" "${sshUser}@localhost:${target}" ''; - installCondaPkgs = condaPkgs: - builtins.concatStringsSep "\n" (map (pkg: '' - F="$(basename ${pkg})" - ${scp pkg "$F"} - ${ssh "miniconda\\Scripts\\conda install $F"} - ${ssh "del $F"} - '') condaPkgs); + installCondaPkg = pkg: '' + F="$(basename ${pkg})" + ${scp pkg "$F"} + ${ssh "miniconda\\Scripts\\conda install $F"} + ${ssh "del $F"} + ''; + makeTest = name: artiqPkg: + stdenv.mkDerivation { + name = "windows-test-${name}"; + src = ./.; + buildInputs = [ qemu sshpass openssh ]; + buildPhase = '' + # +1 day from last modification of the disk image + CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400)) + ${runQemu [ + "-boot" "order=c" + "-snapshot" + "-drive" "file=${diskImage},index=0,media=disk,cache=unsafe" + "-rtc" "base=$CLOCK" + ]} & + echo "Wait for Windows to boot" + sleep 10 + ${ssh "ver"} + for pkg in ${artiqPkg}/noarch/*.tar.bz2 ; do + ${installCondaPkg "$pkg"} + done + # Allow tests to run for 2 minutes + ${ssh "shutdown -s -t ${toString testTimeout}"} + ${ssh "miniconda\\scripts\\activate && miniconda\\python -m unittest discover -v artiq.test"} + # Abort timeouted shutdown + ${ssh "shutdown -a"} + # Power off immediately + ${ssh "shutdown -p -f"} + ''; + installPhase = '' + echo Done + ''; + }; + condaPackageNames = + builtins.filter (name: builtins.match "conda-.+" name != null) + (builtins.attrNames artiq); in -stdenv.mkDerivation { - name = "windows-test"; - src = ./.; - buildInputs = [ qemu sshpass openssh ]; - buildPhase = '' - # +1 day from last modification of the disk image - CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400)) - ${runQemu [ - "-boot" "order=c" - "-snapshot" - "-drive" "file=${diskImage},index=0,media=disk,cache=unsafe" - "-rtc" "base=$CLOCK" - ]} & - echo "Wait for Windows to boot" - sleep 10 - ${ssh "ver"} - ${installCondaPkgs [artiqPkg]} - # Allow tests to run for 2 minutes - ${ssh "shutdown -s -t $ {toString testTimeout}"} - ${ssh "miniconda\\scripts\\activate && miniconda\\python -m unittest discover -v artiq.test"} - # Abort timeouted shutdown - ${ssh "shutdown -a"} - # Power off immediately - ${ssh "shutdown -p -f"} - ''; - installPhase = '' - echo Done - ''; -} + builtins.listToAttrs + (map (pkgName: { + name = pkgName; + value = makeTest pkgName artiq.${pkgName}; + }) condaPackageNames)