@ -121,21 +121,24 @@ rec {
call = f : f { inherit pkgs nixpkgs system ; } ;
complete = t : t // rec {
nodes =
nodes = buildVirtualNetwork (
if t ? nodes then t . nodes else
if t ? machine then { machine = t . machine ; }
else { } ;
vms = buildVirtualNetwork { inherit nodes ; } ;
else { } ) ;
testScript =
# Call the test script with the computed nodes.
if builtins . isFunction t . testScript
then t . testScript { inherit ( vms ) nodes ; }
then t . testScript { inherit nodes ; }
else t . testScript ;
# Generate a convenience wrapper for running the test driver
# interactively with the specified network.
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 " n i x o s - t e s t - d r i v e r "
{ buildInputs = [ makeWrapper ] ;
inherit testScript ;
@ -143,13 +146,18 @@ rec {
''
mkdir - p $ out/bin
echo " $ t e s t S c r i p t " > $ out/test-script
ln - s $ { vms } /bin /* $ o u t / b i n /
ln - s $ { testDriver } /bin /* $ o u t / b i n /
ln - s $ { testDriver } /bin/nixos-test-driver $ out/bin /
vms = " $ ( f o r i i n ${ toString vms } ; d o e c h o $ i / b i n / r u n - * - v m ; d o n e ) "
wrapProgram $ out/bin/nixos-test-driver \
- - add-flags " ${ vms } / v m s / * / b i n / r u n - * - v m " \
- - add-flags " $ v m s " \
- - run " t e s t S c r i p t = \" \$ ( c a t $ o u t / t e s t - s c r i p t ) \" " \
- - set testScript ' " $ t e s t S c r i p t " ' \
- - set VLANS ' " ${ toString ( map ( m : m . config . virtualisation . vlans ) ( lib . attrValues vms . nodes ) ) } " ' \
- - set VLANS ' " ${ toString vlans } " '
ln - s $ { testDriver } /bin/nixos-test-driver $ out/bin/nixos-run-vms
wrapProgram $ out/bin/nixos-run-vms \
- - add-flags " $ v m s " \
- - set tests ' " s t a r t A l l ; s l e e p 1 e 9 ; " ' \
- - set VLANS ' " ${ toString vlans } " '
'' ; # "
test = runTests driver ;