2019-04-08 23:41:05 +08:00
|
|
|
{ pkgs ? import <nixpkgs> {},
|
|
|
|
diskImage ? "/opt/windows/c.img",
|
|
|
|
qemuMem ? "2G",
|
2019-04-09 00:12:44 +08:00
|
|
|
testTimeout ? 120,
|
2019-04-13 21:50:58 +08:00
|
|
|
artiqPkg ? import ../conda-artiq.nix { inherit pkgs; },
|
2019-04-08 23:41:05 +08:00
|
|
|
}:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
let
|
2019-04-14 05:59:22 +08:00
|
|
|
artiqSrc = <artiqSrc>;
|
|
|
|
artiqVersion =
|
|
|
|
pkgs.runCommand "artiq-version" {
|
|
|
|
buildInputs = [ pkgs.nix pkgs.git ];
|
|
|
|
} ''
|
|
|
|
REV=`git --git-dir ${artiqSrc}/.git rev-parse HEAD`
|
|
|
|
echo \"5e.`cut -c1-8 <<< $REV`\" > $out
|
|
|
|
'';
|
|
|
|
|
|
|
|
generateTestOkHash =
|
|
|
|
pkgs.runCommand "generate-test-ok-hash" {
|
|
|
|
buildInputs = [ pkgs.nix ];
|
|
|
|
} ''
|
|
|
|
TMPDIR=`mktemp -d`
|
|
|
|
cp ${artiqVersion} $TMPDIR/passed
|
|
|
|
HASH=`nix-hash --type sha256 --base32 $TMPDIR`
|
|
|
|
echo \"$HASH\" > $out
|
|
|
|
'';
|
|
|
|
|
2019-04-14 05:33:31 +08:00
|
|
|
qemu = import ./qemu.nix {
|
|
|
|
inherit pkgs qemuMem;
|
|
|
|
diskImage = "c.img";
|
|
|
|
};
|
|
|
|
ssh = qemu.ssh;
|
|
|
|
scp = qemu.scp;
|
2019-04-11 22:22:17 +08:00
|
|
|
condaEnv = "artiq-env";
|
2019-04-13 21:50:58 +08:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "windows-test-conda-artiq";
|
2019-04-14 05:59:22 +08:00
|
|
|
|
|
|
|
outputHashAlgo = "sha256";
|
|
|
|
outputHashMode = "recursive";
|
|
|
|
outputHash = import generateTestOkHash;
|
|
|
|
__hydraRetry = false;
|
|
|
|
|
|
|
|
phases = [ "buildPhase" ];
|
|
|
|
buildInputs = qemu.inputs;
|
|
|
|
buildPhase = ''
|
2019-04-13 21:50:58 +08:00
|
|
|
# +1 day from last modification of the disk image
|
|
|
|
CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400))
|
2019-04-14 05:33:31 +08:00
|
|
|
${qemu.runQemu [
|
2019-04-13 21:50:58 +08:00
|
|
|
"-boot" "order=c"
|
|
|
|
"-snapshot"
|
|
|
|
"-drive" "file=${diskImage},index=0,media=disk,cache=unsafe"
|
|
|
|
"-rtc" "base=$CLOCK"
|
|
|
|
]} &
|
2019-04-10 03:01:51 +08:00
|
|
|
|
2019-04-13 21:50:58 +08:00
|
|
|
echo "Wait for Windows to boot"
|
|
|
|
sleep 10
|
|
|
|
${ssh "ver"}
|
2019-04-14 02:34:16 +08:00
|
|
|
for pkg in ${artiqPkg}/noarch/artiq*.tar.bz2 ; do
|
|
|
|
${scp "\$pkg" "artiq.tar.bz2"}
|
2019-04-14 05:34:23 +08:00
|
|
|
${ssh "anaconda\\scripts\\activate ${condaEnv} && conda install artiq.tar.bz2"}
|
2019-04-13 21:50:58 +08:00
|
|
|
done
|
2019-04-10 03:01:51 +08:00
|
|
|
|
2019-04-13 21:50:58 +08:00
|
|
|
# Allow tests to run for 2 minutes
|
|
|
|
${ssh "shutdown -s -t ${toString testTimeout}"}
|
2019-04-10 03:01:51 +08:00
|
|
|
|
2019-04-14 05:34:23 +08:00
|
|
|
${ssh "anaconda\\scripts\\activate ${condaEnv} && python -m unittest discover -v artiq.test"}
|
2019-04-10 03:01:51 +08:00
|
|
|
|
2019-04-13 21:50:58 +08:00
|
|
|
# Abort timeouted shutdown
|
|
|
|
${ssh "shutdown -a"}
|
|
|
|
# Power off immediately
|
|
|
|
${ssh "shutdown -p -f"}
|
2019-04-14 05:59:22 +08:00
|
|
|
|
|
|
|
mkdir $out
|
|
|
|
cp ${artiqVersion} $out/passed
|
2019-04-13 21:50:58 +08:00
|
|
|
'';
|
|
|
|
}
|