diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-02-19 15:12:57 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-02-19 15:12:57 +0100 |
commit | 87f611ed69b2ba16d2a36ed439a685a36a49937c (patch) | |
tree | ba0c7736defe70bf87374763215f330ec7eb27ad /source4 | |
parent | 12ea7dd32513b2f299e24ae1645b821f8e6597e6 (diff) | |
download | samba-87f611ed69b2ba16d2a36ed439a685a36a49937c.tar.gz samba-87f611ed69b2ba16d2a36ed439a685a36a49937c.tar.bz2 samba-87f611ed69b2ba16d2a36ed439a685a36a49937c.zip |
Start and kill kvm instance properly.
(This used to be commit 78e49765a2ec5fac485dbf56143716e151b4b562)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/selftest/config.mk | 3 | ||||
-rwxr-xr-x | source4/selftest/selftest.pl | 2 | ||||
-rw-r--r-- | source4/selftest/target/Kvm.pm | 45 |
3 files changed, 35 insertions, 15 deletions
diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index ff470df527..306a11469c 100644 --- a/source4/selftest/config.mk +++ b/source4/selftest/config.mk @@ -13,6 +13,9 @@ test:: everything kvmtest:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --target=kvm --image=$(KVM_IMAGE) +kvmquicktest:: everything + $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --quick --target=kvm --image=$(KVM_IMAGE) + testone:: everything $(SELFTEST) $(DEFAULT_TEST_OPTIONS) --one $(TESTS) diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index 8647dee9d2..a989d1a851 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -303,7 +303,7 @@ Samba3 Specific: --bindir=PATH path to binaries Kvm Specific: - --image=PATH path to KVM image + --image=PATH path to KVM image Behaviour: --quick run quick overall test diff --git a/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm index 74b726d183..7fa7e02184 100644 --- a/source4/selftest/target/Kvm.pm +++ b/source4/selftest/target/Kvm.pm @@ -11,9 +11,9 @@ use FindBin qw($RealBin); use POSIX; sub new($$$$) { - my ($classname, $image) = @_; + my ($classname, $dc_image) = @_; my $self = { - image => $image + dc_image => $dc_image, }; bless $self; return $self; @@ -23,6 +23,10 @@ sub teardown_env($$) { my ($self, $envvars) = @_; + print "Killing kvm instance $envvars->{KVM_PID}\n"; + + kill 9, $envvars->{KVM_PID}; + return 0; } @@ -37,22 +41,26 @@ sub check_env($$) { my ($self, $envvars) = @_; + # FIXME: Check whether $self->{pid} is still running + return 1; } -sub start($) +sub start($$$) { - my ($self) = @_; + my ($self, $path, $image) = @_; - my $pidfile = "kvm.pid"; + my $pidfile = "$path/kvm.pid"; my $opts = ($ENV{KVM_OPTIONS} or ""); - system("kvm $opts -daemonize -pidfile $pidfile -vnc unix:kvm.vnc -snapshot $self->{image}"); + system("kvm $opts -daemonize -pidfile $pidfile -vnc unix:$path/kvm.vnc -snapshot $image"); open(PID, $pidfile); - $self->{pid} = <PID>; + <PID> =~ /([0-9]+)/; + my ($pid) = $1; close(PID); + return $pid; } sub setup_env($$$) @@ -60,21 +68,30 @@ sub setup_env($$$) my ($self, $envname, $path) = @_; if ($envname eq "dc") { - unless (defined($self->{pid})) { - $self->start(); + $self->{dc_pid} = $self->start($path, $self->{dc_image}); + if ($envname eq "dc") { + return { + KVM_PID => $self->{dc_pid}, + USERNAME => "Administrator", + PASSWORD => "penguin", + DOMAIN => "SAMBA", + REALM => "SAMBA", + SERVER => "", + SERVER_IP => "", + NETBIOSNAME => "", + NETBIOSALIAS => "", + }; + } else { + return undef; } - } elsif ($envname eq "member") { + } else { return undef; } - - die("No implemented yet"); } sub stop($) { my ($self) = @_; - - kill $self->{pid}; } 1; |