Skip to content

Commit

Permalink
nixos/tests/storage: Fix exporting storage.xml
Browse files Browse the repository at this point in the history
Using copyFileFromHost() doesn't work if the file contains single
quotes, because they're not escaped properly.

So let's move to a more robust way to provide storage.xml to the
guests (via environment.etc), because apart from that escaping issue we
really don't need anything like copyFileFromHost() anymore because every
subtest now resides in its own derivation.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
  • Loading branch information
aszlig committed Dec 27, 2016
1 parent d6f428c commit 8504661
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions nixos/tests/storage.nix
Expand Up @@ -11,6 +11,13 @@ let
pkgs.nixpart pkgs.file pkgs.btrfs-progs pkgs.xfsprogs pkgs.lvm2
];
virtualisation.emptyDiskImages = [ 4096 4096 ];
environment.etc."storage.xml".text = let
config = (import ../lib/eval-config.nix {
modules = pkgs.lib.singleton attrs.config;
}).config;
in builtins.toXML {
inherit (config) storage fileSystems swapDevices;
};
};

testScript = ''
Expand Down Expand Up @@ -44,14 +51,7 @@ let
}
sub nixpart {
$machine->copyFileFromHost('${let
config = (import ../lib/eval-config.nix {
modules = pkgs.lib.singleton attrs.config;
}).config;
in pkgs.writeText "storage.xml" (builtins.toXML {
inherit (config) storage fileSystems swapDevices;
})}', "/storage.xml");
$machine->succeed("nixpart -v --from-xml /storage.xml");
$machine->succeed("nixpart -v --from-xml /etc/storage.xml");
ensureSanity;
}
Expand Down Expand Up @@ -94,7 +94,7 @@ let
die;
}
# Try to remount with nixpart
$machine->succeed("nixpart -vm --from-xml /storage.xml");
$machine->succeed("nixpart -vm --from-xml /etc/storage.xml");
ensureMountPoint("/mnt");
# Check if our beloved canaries are dead
chomp $canaries;
Expand Down

0 comments on commit 8504661

Please sign in to comment.