forked from snabbco/snabb
-
Notifications
You must be signed in to change notification settings - Fork 2
/
release.nix
66 lines (53 loc) · 1.76 KB
/
release.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Run like this:
# nix-build /path/to/this/directory/release.nix -A manual
# ... and the files are produced in ./result/
{ pkgs ? (import <nixpkgs> {})
}:
with pkgs;
let
# see https://github.com/snabbco/snabb/blob/master/src/doc/testing.md
test_env = fetchurl {
url = "http://lab1.snabb.co:2008/~max/assets/vm-ubuntu-trusty-14.04-dpdk-snabb.tar.gz";
sha256 = "0323591i925jhd6wv8h268wc3ildjpa6j57n4p9yg9d6ikwkw06j";
};
requiredGetEnv = var: let
maybeEnv = builtins.getEnv var;
in if (maybeEnv != "") then maybeEnv else throw "Please export shell variable ${var}";
in rec {
manual = import ./src/doc {};
snabb = import ./default.nix {};
tests = stdenv.mkDerivation rec {
name = "snabb-tests";
src = snabb.src;
# allow sudo
__noChroot = true;
requiredSystemFeatures = [ "lugano" ];
buildInputs = [ git telnet tmux numactl bc iproute which qemu ];
buildPhase = ''
export PATH=$PATH:/var/setuid-wrappers/
export HOME=$TMPDIR
# make sure we reuse the snabb built in another derivation
ln -s ${snabb}/bin/snabb src/snabb
sed -i 's/testlog snabb/testlog/' src/Makefile
# setup the environment
mkdir ~/.test_env
tar xvzf ${test_env} -C ~/.test_env/
'';
doCheck = true;
checkPhase = ''
export SNABB_PCI0=${ requiredGetEnv "SNABB_PCI0" }
export SNABB_PCI_INTEL0=${ requiredGetEnv "SNABB_PCI_INTEL0" }
export SNABB_PCI_INTEL1=${ requiredGetEnv "SNABB_PCI_INTEL1" }
# run tests
sudo -E make test -C src/
'';
installPhase = ''
mkdir -p $out/nix-support
# keep the logs
cp src/testlog/* $out/
for f in $(ls $out/* | sort); do
echo "file log $f" >> $out/nix-support/hydra-build-products
done
'';
};
}