add windows image test runner

stm32-no-overlay
Astro 2019-04-08 17:41:05 +02:00 committed by Sébastien Bourdeauducq
parent 9e23fb551d
commit 577966e11d
2 changed files with 80 additions and 0 deletions

View File

@ -6,3 +6,14 @@ result/bin/networked-installer.sh
```
Follow the instructions.
Then press **return** to automatically complete the installation via SSH. The virtual machine will be shut down when the process is complete.
Move the image `c.img` to one of Nix' `extra-sandbox-paths` (`nix.sandboxPaths` on NixOS).
# Running the tests
```shell
nix-build --arg diskImage "\"…/c.img\""
```

69
artiq/windows/default.nix Normal file
View File

@ -0,0 +1,69 @@
{ pkgs ? import <nixpkgs> {},
diskImage ? "/opt/windows/c.img",
qemuMem ? "2G",
artiqPkg ? (pkgs.fetchurl {
url = "https://nixbld.m-labs.hk/build/2316/download/1/artiq-5e.b8e2b82a-0.tar.bz2";
sha256 = "0gisv3a17rnwavsifpz4cfnqvlssv37pysi2qx41k67rmcpqcs98";
}),
}:
with pkgs;
let
qemu = qemu_kvm;
runQemu = extraArgs:
let
args = [
"-enable-kvm"
"-m" qemuMem
"-display" "none"
"-bios" "${OVMF.fd}/FV/OVMF.fd"
"-netdev" "user,id=n1,hostfwd=tcp::2022-:22" "-device" "e1000,netdev=n1"
];
argStr = builtins.concatStringsSep " " (args ++ extraArgs);
in "qemu-system-x86_64 ${argStr}";
sshUser = "user";
sshPassword = "user";
sshOpts = "-o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=$TMPDIR/known_hosts";
ssh = cmd: ''
echo "ssh windows \"${cmd}\""
sshpass -p${sshPassword} -- \
ssh -np 2022 ${sshOpts} \
${sshUser}@localhost \
"${cmd}"
'';
scp = src: target: ''
echo "Copy ${src} to ${target}"
sshpass -p${sshPassword} -- \
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);
in
stdenv.mkDerivation {
name = "windows-test";
src = ./.;
buildInputs = [ qemu sshpass openssh ];
buildPhase = ''
${runQemu [
"-boot" "order=c"
"-snapshot"
"-drive" "file=${diskImage},index=0,media=disk,cache=unsafe"
]} &
echo "Wait for Windows to boot"
sleep 10
${ssh "ver"}
${installCondaPkgs [artiqPkg]}
${ssh "miniconda\\scripts\\activate && miniconda\\python -m unittest discover -v artiq.test"}
${ssh "shutdown /p /f"}
'';
installPhase = ''
echo Done
'';
}