diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-01-06 14:37:23 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2010-01-06 14:37:23 +0000 |
commit | 1b21115f61c668c8ca3cd47cda3840f2be3b0032 (patch) | |
tree | fe2f1ff741bc95692dad7cbc0dc99d0753017fca /lib | |
parent | 816f12da885b1ac8c961ac628c932297a9f5cd2f (diff) | |
download | nixpkgs-1b21115f61c668c8ca3cd47cda3840f2be3b0032.tar nixpkgs-1b21115f61c668c8ca3cd47cda3840f2be3b0032.tar.gz nixpkgs-1b21115f61c668c8ca3cd47cda3840f2be3b0032.tar.bz2 nixpkgs-1b21115f61c668c8ca3cd47cda3840f2be3b0032.tar.lz nixpkgs-1b21115f61c668c8ca3cd47cda3840f2be3b0032.tar.xz nixpkgs-1b21115f61c668c8ca3cd47cda3840f2be3b0032.tar.zst nixpkgs-1b21115f61c668c8ca3cd47cda3840f2be3b0032.zip |
* Support creating a virtual disk in the test driver.
svn path=/nixos/trunk/; revision=19263
Diffstat (limited to 'lib')
-rw-r--r-- | lib/test-driver/Machine.pm | 21 | ||||
-rw-r--r-- | lib/test-driver/test-driver.pl | 9 |
2 files changed, 23 insertions, 7 deletions
diff --git a/lib/test-driver/Machine.pm b/lib/test-driver/Machine.pm index ad39ed62a01..92d390b15c0 100644 --- a/lib/test-driver/Machine.pm +++ b/lib/test-driver/Machine.pm @@ -7,6 +7,7 @@ use Socket; use IO::Handle; use POSIX qw(dup2); use FileHandle; +use Cwd; # Stuff our PID in the multicast address/port to prevent collissions @@ -24,6 +25,8 @@ sub new { $startCommand = "qemu-system-x86_64 -m 384 -no-kvm-irqchip " . "-net nic,model=virtio -net user \$QEMU_OPTS "; + $startCommand .= "-drive file=" . Cwd::abs_path($args->{hda}) . ",if=virtio,boot=on " + if defined $args->{hda}; $startCommand .= "-cdrom $args->{cdrom} " if defined $args->{cdrom}; #-drive file=$NIX_DISK_IMAGE,if=virtio,boot=on @@ -186,13 +189,17 @@ sub execute { sub mustSucceed { - my ($self, $command) = @_; - my ($status, $out) = $self->execute($command); - if ($status != 0) { - $self->log("output: $out"); - die "command `$command' did not succeed (exit code $status)"; + my ($self, @commands) = @_; + my $res; + foreach my $command (@commands) { + my ($status, $out) = $self->execute($command); + if ($status != 0) { + $self->log("output: $out"); + die "command `$command' did not succeed (exit code $status)"; + } + $res .= $out; } - return $out; + return $res; } @@ -266,7 +273,7 @@ sub shutdown { my ($self) = @_; return unless $self->{booted}; - $self->execute("poweroff -f &"); + $self->execute("poweroff"); $self->waitForShutdown; } diff --git a/lib/test-driver/test-driver.pl b/lib/test-driver/test-driver.pl index 6bac1f1dd39..2ccc6bd4b9a 100644 --- a/lib/test-driver/test-driver.pl +++ b/lib/test-driver/test-driver.pl @@ -52,6 +52,15 @@ sub runTests { } +# Create an empty qcow2 virtual disk with the given name and size (in +# MiB). +sub createDisk { + my ($name, $size) = @_; + system("qemu-img create -f qcow2 $name ${size}M") == 0 + or die "cannot create image of size $size"; +} + + END { foreach my $vm (values %vms) { if ($vm->{pid}) { |