* Test whether nix-env -i works.

svn path=/nixos/trunk/; revision=19265
This commit is contained in:
Eelco Dolstra 2010-01-06 16:46:21 +00:00
parent cbca2f72df
commit 1d549cf6df

View File

@ -12,11 +12,16 @@ rec {
../modules/testing/test-instrumentation.nix
{ key = "serial";
boot.kernelParams = [ "console=tty1" "console=ttyS0" ];
boot.loader.grub.timeout = pkgs.lib.mkOverride 0 {} 0;
boot.loader.grub.timeout = pkgs.lib.mkOverride 0 {} 0;
# The test cannot access the network, so any sources we
# need must be included in the ISO.
isoImage.storeContents = [ pkgs.hello.src ];
}
];
}).config.system.build.isoImage;
# The test script boots the CD, installs NixOS on an empty hard
# disk, and then reboot from the hard disk.
testScript =
''
createDisk("harddisk", 4 * 1024);
@ -30,6 +35,13 @@ rec {
$machine->waitForJob("rogue");
$machine->waitForJob("nixos-manual");
# Test nix-env.
$machine->mustSucceed("source /etc/profile");
$machine->mustFail("hello");
$machine->mustSucceed("nix-env -i hello");
$machine->mustSucceed("hello") =~ /Hello, world/
or die "bad `hello' output";
# Partition the disk.
$machine->mustSucceed(
"parted /dev/vda mklabel msdos",
@ -43,6 +55,15 @@ rec {
"mount LABEL=nixos /mnt",
);
# Create a NixOS configuration.
$machine->mustSucceed(
"mkdir -p /mnt/etc/nixos",
"nixos-hardware-scan > /mnt/etc/nixos/hardware.nix",
);
my $cfg = $machine->mustSucceed("cat /mnt/etc/nixos/hardware.nix");
print STDERR "Result of the hardware scan:$cfg\n";
$machine->shutdown;
# Now see if we can boot the installation.
@ -50,4 +71,5 @@ rec {
$machine->mustSucceed("echo hello");
$machine->shutdown;
'';
}