Author: rob
Date: Mon Jun 6 19:18:04 2011
New Revision: 27355
URL: https://svn.nixos.org/websvn/nix/?rev=27355&sc=1
Log:
adapt code to new nixos/lib, should refactor, but lazy for now
Modified:
hydra-config/gnu/trunk/tests/default.nix
Modified: hydra-config/gnu/trunk/tests/default.nix
==============================================================================
--- hydra-config/gnu/trunk/tests/default.nix Mon Jun 6 18:07:29 2011
(r27354)
+++ hydra-config/gnu/trunk/tests/default.nix Mon Jun 6 19:18:04 2011
(r27355)
@@ -22,34 +22,61 @@
with import "${nixos}/lib/testing.nix" { inherit nixpkgs system; };
with import "${nixos}/lib/build-vms.nix" { inherit nixpkgs system; };
-
+with pkgs;
let
+ gnuify = name: configFunction:
+ builtins.trace "node `${name}'"
+ (args: (configFunction args) // gnuConfigOptions);
+
call = f: f { inherit nixpkgs system pkgs; };
apply = testFun: complete (call testFun);
complete = t: t // rec {
- nodes =
+ nodes = buildVirtualNetwork ( pkgs.lib.mapAttrs gnuify (
if t ? nodes then t.nodes else
if t ? machine then { machine = t.machine; }
- else { };
- vms = buildVirtualNetwork {
- # Build a network of nodes that use `gnuConfigOptions', i.e., the
- # latest GNU packages and a GNU configuration.
- nodes =
- let gnuify = name: configFunction:
- builtins.trace "node `${name}'"
- (args: (configFunction args) // gnuConfigOptions);
- in
- pkgs.lib.mapAttrs gnuify nodes;
- };
-
- test = (runTests vms t.testScript) // {
- meta.schedulingPriority = "5";
- };
+ else { } ));
+
+ testScript =
+ # Call the test script with the computed nodes.
+ if builtins.isFunction t.testScript
+ then t.testScript { inherit nodes; }
+ else t.testScript;
+
+ vlans = map (m: m.config.virtualisation.vlans) (lib.attrValues nodes);
+
+ vms = map (m: m.config.system.build.vm) (lib.attrValues nodes);
+
+ # Generate onvenience wrappers for running the test driver
+ # interactively with the specified network, and for starting the
+ # VMs from the command line.
+ driver = runCommand "nixos-test-driver"
+ { buildInputs = [ makeWrapper];
+ inherit testScript;
+ }
+ ''
+ mkdir -p $out/bin
+ echo "$testScript" > $out/test-script
+ ln -s ${testDriver}/bin/nixos-test-driver $out/bin/
+ vms="$(for i in ${toString vms}; do echo $i/bin/run-*-vm; done)"
+ wrapProgram $out/bin/nixos-test-driver \
+ --add-flags "$vms" \
+ --run "testScript=\"\$(cat $out/test-script)\"" \
+ --set testScript '"$testScript"' \
+ --set VLANS '"${toString vlans}"'
+ ln -s ${testDriver}/bin/nixos-test-driver $out/bin/nixos-run-vms
+ wrapProgram $out/bin/nixos-run-vms \
+ --add-flags "$vms" \
+ --set tests '"startAll; sleep 1e9;"' \
+ --set VLANS '"${toString vlans}"'
+ ''; # "
+
+ test = runTests driver;
report = makeReport test;
};
+
in
{
version = apply (import ./version.nix);
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits