forked from M-Labs/nix-scripts
run KC705 tests in hacked fixed-output derivation
Unlike the previous RunCommand hack, this integrates with Hydra build monitoring.
This commit is contained in:
parent
a56931d547
commit
7406a34312
@ -1,34 +0,0 @@
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
import artiq
|
||||
|
||||
|
||||
with open(sys.argv[1], "r") as hydra_json_file:
|
||||
hydra_json = json.load(hydra_json_file)
|
||||
|
||||
drv = hydra_json["drvPath"]
|
||||
assert drv.startswith("/nix/store/")
|
||||
drv = drv[len("/nix/store/"):]
|
||||
hydra_log = "/var/lib/hydra/build-logs/" + drv[:2] + "/" + drv[2:]
|
||||
|
||||
with open(hydra_log, "w") as log:
|
||||
def run(*args, **kwargs):
|
||||
subprocess.run(args, stdout=log, stderr=log, **kwargs).check_returncode()
|
||||
|
||||
run("artiq_flash", "-t", "kc705", "-V", "nist_clock")
|
||||
|
||||
time.sleep(15)
|
||||
|
||||
# ping: socket: Operation not permitted
|
||||
#run("ping", "kc705-1", "-c10", "-w30")
|
||||
|
||||
env = {
|
||||
"ARTIQ_ROOT": artiq.__path__[0] + "/examples/kc705_nist_clock",
|
||||
"ARTIQ_LOW_LATENCY": "1"
|
||||
}
|
||||
env.update(os.environ)
|
||||
run("python", "-m", "unittest", "discover", "-v", "artiq.test.coredevice", env=env)
|
47
main.nix
47
main.nix
@ -17,23 +17,52 @@ let
|
||||
EOF
|
||||
echo \"5e.`cut -c1-8 <<< $REV`\" > $out/pkgs/artiq-version.nix
|
||||
'';
|
||||
generateTestOkHash = pkgs.runCommand "generate-test-ok-hash" { buildInputs = [ pkgs.nix ]; }
|
||||
''
|
||||
TMPDIR=`mktemp -d`
|
||||
cp ${generatedNix}/pkgs/artiq-version.nix $TMPDIR/passed
|
||||
HASH=`nix-hash --type sha256 --base32 $TMPDIR`
|
||||
echo \"$HASH\" > $out
|
||||
'';
|
||||
artiqpkgs = import "${generatedNix}/default.nix" { inherit pkgs; };
|
||||
artiqVersion = import "${generatedNix}/pkgs/artiq-version.nix";
|
||||
jobs = builtins.mapAttrs (key: value: pkgs.lib.hydraJob value) artiqpkgs;
|
||||
in
|
||||
jobs // {
|
||||
generated-nix = pkgs.lib.hydraJob generatedNix;
|
||||
generated-nix = pkgs.lib.hydraJob generatedNix; # used by sinara-systems
|
||||
channel = pkgs.releaseTools.channel rec {
|
||||
name = "main";
|
||||
src = generatedNix;
|
||||
constituents = builtins.attrValues jobs;
|
||||
};
|
||||
extended-tests = pkgs.runCommand "extended-tests" {
|
||||
propagatedBuildInputs = [
|
||||
(pkgs.python3.withPackages(ps: [ artiqpkgs.artiq artiqpkgs.artiq-board-kc705-nist_clock ]))
|
||||
artiqpkgs.binutils-or1k
|
||||
artiqpkgs.openocd
|
||||
pkgs.iputils
|
||||
];
|
||||
} "cp ${./extended-tests.py} $out;";
|
||||
|
||||
# HACK: Abuse fixed-output derivations to escape the sandbox and run the hardware
|
||||
# unit tests, all integrated in the Hydra interface.
|
||||
# One major downside of this hack is the tests are only run when generateTestOkHash
|
||||
# changes, i.e. when the ARTIQ version changes (and not the dependencies).
|
||||
# Impure derivations, when they land in Nix/Hydra, should improve the situation.
|
||||
kc705-tests = pkgs.stdenv.mkDerivation {
|
||||
name = "extended-tests";
|
||||
outputHashAlgo = "sha256";
|
||||
outputHashMode = "recursive";
|
||||
outputHash = import generateTestOkHash;
|
||||
buildInputs = [
|
||||
(pkgs.python3.withPackages(ps: [ artiqpkgs.artiq artiqpkgs.artiq-board-kc705-nist_clock ]))
|
||||
artiqpkgs.binutils-or1k
|
||||
pkgs.iputils
|
||||
];
|
||||
phases = [ "buildPhase" ];
|
||||
buildPhase =
|
||||
''
|
||||
artiq_flash -t kc705 -H rpi
|
||||
sleep 15
|
||||
# ping: socket: Operation not permitted
|
||||
#ping kc705-1 -c10 -w30
|
||||
export ARTIQ_ROOT=`python -c "import artiq; print(artiq.__path__[0])"`/examples/kc705_nist_clock",
|
||||
export ARTIQ_LOW_LATENCY=1
|
||||
python -m unittest discover -v artiq.test.coredevice
|
||||
mkdir $out
|
||||
cp ${generatedNix}/pkgs/artiq-version.nix $out/passed
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user