forked from M-Labs/nix-scripts
windows tests: rename default.nix to run-test.nix
default.nix will now run the tests outside of hydra.
This commit is contained in:
parent
448934fe6e
commit
d7917b4b5b
@ -12,8 +12,8 @@ Then press **return** to automatically complete the installation via SSH. The vi
|
|||||||
Move the image `c.img` to one of Nix' `extra-sandbox-paths` (`nix.sandboxPaths` on NixOS).
|
Move the image `c.img` to one of Nix' `extra-sandbox-paths` (`nix.sandboxPaths` on NixOS).
|
||||||
|
|
||||||
|
|
||||||
# Running the tests
|
# Running the tests manually
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
nix-build --arg diskImage "\"…/c.img\""
|
nix-build --pure --arg diskImage "\"…/c.img\"" -I artiqSrc=…/artiq
|
||||||
```
|
```
|
||||||
|
@ -2,61 +2,25 @@
|
|||||||
diskImage ? "/opt/windows/c.img",
|
diskImage ? "/opt/windows/c.img",
|
||||||
qemuMem ? "2G",
|
qemuMem ? "2G",
|
||||||
testTimeout ? 180,
|
testTimeout ? 180,
|
||||||
artiqPkg ? import ../conda-artiq.nix { inherit pkgs; },
|
|
||||||
testCommand ? "python -m unittest discover -v artiq.test",
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
|
||||||
let
|
let
|
||||||
escape = builtins.replaceStrings [ "\\" ] [ "\\\\" ];
|
windowsRunner = overrides:
|
||||||
qemu = import ./qemu.nix {
|
import ./run-test.nix {
|
||||||
inherit pkgs qemuMem;
|
inherit pkgs diskImage qemuMem testTimeout;
|
||||||
diskImage = "c.img";
|
|
||||||
};
|
};
|
||||||
# Double-escape because we produce a script from a shell heredoc
|
|
||||||
ssh = cmd: qemu.ssh (escape cmd);
|
|
||||||
scp = qemu.scp;
|
|
||||||
condaEnv = "artiq-env";
|
|
||||||
in
|
in
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "windows-test-runner";
|
name = "windows-test";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
propagatedBuildInputs = qemu.inputs;
|
phases = [ "installPhase" "checkPhase" ];
|
||||||
dontBuild = true;
|
installPhase = "touch $out";
|
||||||
installPhase = ''
|
doCheck = true;
|
||||||
mkdir -p $out/bin
|
checkPhase = ''
|
||||||
cat > $out/bin/run.sh << EOF
|
${windowsRunner { testCommand = "set ARTIQ_ROOT=%cd%\\anaconda\\envs\\artiq-env\\Lib\\site-packages\\artiq\\examples\\kc705_nist_clock&&set ARTIQ_LOW_LATENCY=1&&python -m unittest discover -v artiq.test"; }}/bin/run.sh
|
||||||
# +1 day from last modification of the disk image
|
|
||||||
CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400))
|
|
||||||
${qemu.runQemu true [
|
|
||||||
"-boot" "order=c"
|
|
||||||
"-snapshot"
|
|
||||||
"-drive" "file=${diskImage},index=0,media=disk,cache=unsafe"
|
|
||||||
"-rtc" "base=\\$CLOCK"
|
|
||||||
"-display" "none"
|
|
||||||
]} &
|
|
||||||
|
|
||||||
echo "Wait for Windows to boot"
|
|
||||||
sleep 10
|
|
||||||
${ssh "ver"}
|
|
||||||
for pkg in ${artiqPkg}/noarch/artiq*.tar.bz2 ; do
|
|
||||||
${scp "\\$pkg" "artiq.tar.bz2"}
|
|
||||||
${ssh "anaconda\\scripts\\activate ${condaEnv} && conda install artiq.tar.bz2"}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Allow tests to run for 2 minutes
|
|
||||||
${ssh "shutdown -s -t ${toString testTimeout}"}
|
|
||||||
|
|
||||||
${ssh "anaconda\\scripts\\activate ${condaEnv} && ${testCommand}"}
|
|
||||||
|
|
||||||
# Abort timeouted shutdown
|
|
||||||
${ssh "shutdown -a"}
|
|
||||||
# Power off immediately
|
|
||||||
${ssh "shutdown -p -f"}
|
|
||||||
EOF
|
|
||||||
chmod a+x $out/bin/run.sh
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
62
artiq/windows/run-test.nix
Normal file
62
artiq/windows/run-test.nix
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {},
|
||||||
|
diskImage ? "/opt/windows/c.img",
|
||||||
|
qemuMem ? "2G",
|
||||||
|
testTimeout ? 180,
|
||||||
|
artiqPkg ? import ../conda-artiq.nix { inherit pkgs; },
|
||||||
|
testCommand ? "python -m unittest discover -v artiq.test",
|
||||||
|
}:
|
||||||
|
|
||||||
|
with pkgs;
|
||||||
|
|
||||||
|
let
|
||||||
|
escape = builtins.replaceStrings [ "\\" ] [ "\\\\" ];
|
||||||
|
qemu = import ./qemu.nix {
|
||||||
|
inherit pkgs qemuMem;
|
||||||
|
diskImage = "c.img";
|
||||||
|
};
|
||||||
|
# Double-escape because we produce a script from a shell heredoc
|
||||||
|
ssh = cmd: qemu.ssh (escape cmd);
|
||||||
|
scp = qemu.scp;
|
||||||
|
condaEnv = "artiq-env";
|
||||||
|
in
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "windows-test-runner";
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
propagatedBuildInputs = qemu.inputs;
|
||||||
|
dontBuild = true;
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/bin
|
||||||
|
cat > $out/bin/run.sh << EOF
|
||||||
|
# +1 day from last modification of the disk image
|
||||||
|
CLOCK=$(date -Is -d @$(expr $(stat -c %Y ${diskImage}) + 86400))
|
||||||
|
${qemu.runQemu true [
|
||||||
|
"-boot" "order=c"
|
||||||
|
"-snapshot"
|
||||||
|
"-drive" "file=${diskImage},index=0,media=disk,cache=unsafe"
|
||||||
|
"-rtc" "base=\\$CLOCK"
|
||||||
|
"-display" "none"
|
||||||
|
]} &
|
||||||
|
|
||||||
|
echo "Wait for Windows to boot"
|
||||||
|
sleep 10
|
||||||
|
${ssh "ver"}
|
||||||
|
for pkg in ${artiqPkg}/noarch/artiq*.tar.bz2 ; do
|
||||||
|
${scp "\\$pkg" "artiq.tar.bz2"}
|
||||||
|
${ssh "anaconda\\scripts\\activate ${condaEnv} && conda install artiq.tar.bz2"}
|
||||||
|
done
|
||||||
|
|
||||||
|
# Allow tests to run for 2 minutes
|
||||||
|
${ssh "shutdown -s -t ${toString testTimeout}"}
|
||||||
|
|
||||||
|
${ssh "anaconda\\scripts\\activate ${condaEnv} && ${testCommand}"}
|
||||||
|
|
||||||
|
# Abort timeouted shutdown
|
||||||
|
${ssh "shutdown -a"}
|
||||||
|
# Power off immediately
|
||||||
|
${ssh "shutdown -p -f"}
|
||||||
|
EOF
|
||||||
|
chmod a+x $out/bin/run.sh
|
||||||
|
'';
|
||||||
|
}
|
2
main.nix
2
main.nix
@ -31,7 +31,7 @@ let
|
|||||||
artiqpkgs = import "${generatedNix}/default.nix" { inherit pkgs; };
|
artiqpkgs = import "${generatedNix}/default.nix" { inherit pkgs; };
|
||||||
artiqVersion = import "${generatedNix}/pkgs/artiq-version.nix";
|
artiqVersion = import "${generatedNix}/pkgs/artiq-version.nix";
|
||||||
windowsRunner = overrides:
|
windowsRunner = overrides:
|
||||||
import "${generatedNix}/windows" ({
|
import "${generatedNix}/windows/run-test.nix" ({
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
artiqPkg = artiqpkgs.conda-artiq;
|
artiqPkg = artiqpkgs.conda-artiq;
|
||||||
} // overrides);
|
} // overrides);
|
||||||
|
Loading…
Reference in New Issue
Block a user