diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-01-05 11:18:43 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-01-05 11:18:43 +0000 |
commit | 51097933ab1413fe6a1e853d39a273a7b9969c26 (patch) | |
tree | e6585ff22117c15c96f5f46759dafe92775a87e4 /lib/build-vms.nix | |
parent | ff86799d42abf507bace415da4f8406871a763c8 (diff) | |
download | nixlib-51097933ab1413fe6a1e853d39a273a7b9969c26.tar nixlib-51097933ab1413fe6a1e853d39a273a7b9969c26.tar.gz nixlib-51097933ab1413fe6a1e853d39a273a7b9969c26.tar.bz2 nixlib-51097933ab1413fe6a1e853d39a273a7b9969c26.tar.lz nixlib-51097933ab1413fe6a1e853d39a273a7b9969c26.tar.xz nixlib-51097933ab1413fe6a1e853d39a273a7b9969c26.tar.zst nixlib-51097933ab1413fe6a1e853d39a273a7b9969c26.zip |
* Moved test-related stuff from lib/build-vms.nix to lib/testing.nix.
* Factored out some commonality between tests to make them a bit simpler to write. A test is a function { pkgs, ... }: -> { nodes, testScript } or { machine, testScript }. So it's no longer necessary to have a "vms" attribute in every test. svn path=/nixos/trunk/; revision=19220
Diffstat (limited to 'lib/build-vms.nix')
-rw-r--r-- | lib/build-vms.nix | 86 |
1 files changed, 6 insertions, 80 deletions
diff --git a/lib/build-vms.nix b/lib/build-vms.nix index 5c6315eb30c8..473bd01ad937 100644 --- a/lib/build-vms.nix +++ b/lib/build-vms.nix @@ -1,8 +1,4 @@ -{ nixos ? ./.. -, nixpkgs ? ../../nixpkgs -, services ? ../../nixos/services -, system ? builtins.currentSystem -}: +{ nixpkgs, services, system }: let pkgs = import nixpkgs { config = {}; inherit system; }; in @@ -55,12 +51,12 @@ rec { buildVM = nodes: configurations: - import "${nixos}/lib/eval-config.nix" { + import ./eval-config.nix { inherit nixpkgs services system; - modules = configurations ++ [ - "${nixos}/modules/virtualisation/qemu-vm.nix" # !!! - "${nixos}/modules/testing/test-instrumentation.nix" # !!! should only get added for automated test runs - ]; + modules = configurations ++ + [ ../modules/virtualisation/qemu-vm.nix # !!! + ../modules/testing/test-instrumentation.nix # !!! should only get added for automated test runs + ]; extraArgs = { inherit nodes; }; /* !!! bug in the module/option handling: this ignores the config from assignIPAddresses. Too much magic. @@ -117,74 +113,4 @@ rec { else []; - # Run an automated test suite in the given virtual network. - # `network' must be the result of a call to the - # `buildVirtualNetwork' function. `tests' is a Perl fragment - # describing the tests. - runTests = network: tests: - stdenv.mkDerivation { - name = "vm-test-run"; - inherit tests; - buildCommand = - '' - mkdir $out - cp ${./test-driver/Machine.pm} Machine.pm - ensureDir $out/nix-support - - ${perl}/bin/perl ${./test-driver/test-driver.pl} ${network}/vms/*/bin/run-*-vm - - for i in */coverage-data; do - ensureDir $out/coverage-data - mv $i $out/coverage-data/$(dirname $i) - done - - for i in $out/*.png; do - echo "report screenshot $i" >> $out/nix-support/hydra-build-products - done - ''; # */ - }; - - - # Generate a coverage report from the coverage data produced by - # runTests. - makeReport = x: runCommand "report" { buildInputs = [rsync]; } - '' - for d in ${x}/coverage-data/*; do - - echo "doing $d" - - ensureDir $TMPDIR/gcov/ - - for i in $(cd $d/nix/store && ls); do - if ! test -e $TMPDIR/gcov/nix/store/$i; then - echo "copying $i" - mkdir -p $TMPDIR/gcov/$(echo $i | cut -c34-) - rsync -rv /nix/store/$i/.build/* $TMPDIR/gcov/ - fi - done - - chmod -R u+w $TMPDIR/gcov - - find $TMPDIR/gcov -name "*.gcda" -exec rm {} \; - - for i in $(cd $d/nix/store && ls); do - rsync -rv $d/nix/store/$i/.build/* $TMPDIR/gcov/ - done - - find $TMPDIR/gcov -name "*.gcda" -exec chmod 644 {} \; - - echo "producing info..." - ${pkgs.lcov}/bin/geninfo --ignore-errors source,gcov $TMPDIR/gcov --output-file $TMPDIR/app.info - cat $TMPDIR/app.info >> $TMPDIR/full.info - done - - echo "making report..." - ensureDir $out/coverage - ${pkgs.lcov}/bin/genhtml --show-details $TMPDIR/full.info -o $out/coverage - cp $TMPDIR/full.info $out/coverage/ - - ensureDir $out/nix-support - echo "report coverage $out/coverage" >> $out/nix-support/hydra-build-products - ''; # */ - } |