windows tests: run for all artiq conda pkgs

This commit is contained in:
Astro 2019-04-09 20:41:46 +02:00 committed by Sébastien Bourdeauducq
parent 937a27dd48
commit b79576247f
1 changed files with 47 additions and 41 deletions

View File

@ -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)