[SCM] Samba Shared Repository - branch v4-0-test updated - release-4-0-0alpha2-929-g02cb396

Jelmer Vernooij jelmer at samba.org
Tue Feb 19 17:05:36 GMT 2008


The branch, v4-0-test has been updated
       via  02cb396d42976efc03fcb0082e914eb17ae72e11 (commit)
       via  89fd6e9d0c3d0cb2fa3b8109e82f377cd7877a2e (commit)
       via  228710e2656f8635697cdf4b7ce0c931683fbf86 (commit)
       via  8ef295bb9cba4a47ff19894364e9d5f4dc15a935 (commit)
       via  a021408c9d78260b9abf7ebec4230b7958033a38 (commit)
       via  a54507dbd6bfaafb42eb95ec8a57897096b19583 (commit)
       via  78e49765a2ec5fac485dbf56143716e151b4b562 (commit)
       via  732d2bba83c68d337a4a0290245ba8b3eb0635dd (commit)
       via  3a5e2f9ba3131a2a264e21640db8bea255fe9ea3 (commit)
       via  2b8d5db1bb21ab3deaa8edbaddceaf23f83b8180 (commit)
       via  6308c134b225dfa8574aa1370a7874ed6e572ccc (commit)
       via  e4efbb2906f4f3876986e21c12b58791c3526bed (commit)
      from  d10cbb533c18a6d74160477d34a81bbd4cd6c7c8 (commit)

http://gitweb.samba.org/?samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 02cb396d42976efc03fcb0082e914eb17ae72e11
Merge: 89fd6e9d0c3d0cb2fa3b8109e82f377cd7877a2e d10cbb533c18a6d74160477d34a81bbd4cd6c7c8
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 18:05:09 2008 +0100

    Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-trivial

commit 89fd6e9d0c3d0cb2fa3b8109e82f377cd7877a2e
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 18:03:02 2008 +0100

    Only set "interfaces = " line for client when necessary.

commit 228710e2656f8635697cdf4b7ce0c931683fbf86
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 17:26:02 2008 +0100

    Add kvm name.

commit 8ef295bb9cba4a47ff19894364e9d5f4dc15a935
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 17:23:38 2008 +0100

    Allow loading kvm snapshots.

commit a021408c9d78260b9abf7ebec4230b7958033a38
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 16:49:29 2008 +0100

    Allow connecting to screen.

commit a54507dbd6bfaafb42eb95ec8a57897096b19583
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 16:28:32 2008 +0100

    Start dhcp server for kvm machine.

commit 78e49765a2ec5fac485dbf56143716e151b4b562
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 15:12:57 2008 +0100

    Start and kill kvm instance properly.

commit 732d2bba83c68d337a4a0290245ba8b3eb0635dd
Merge: 3a5e2f9ba3131a2a264e21640db8bea255fe9ea3 d0dfdab85ac751c62b0a6d6e6b1ff128940098ed
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 14:33:05 2008 +0100

    Merge branch 'v4-0-trivial' into v4-0-kvmtest

commit 3a5e2f9ba3131a2a264e21640db8bea255fe9ea3
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 04:44:30 2008 +0100

    kvm fixes.

commit 2b8d5db1bb21ab3deaa8edbaddceaf23f83b8180
Merge: 6308c134b225dfa8574aa1370a7874ed6e572ccc f6760fd161f568ef13a841a0210f130160a16c01
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 04:37:09 2008 +0100

    Merge branch 'v4-0-trivial' into v4-0-kvmtest

commit 6308c134b225dfa8574aa1370a7874ed6e572ccc
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 03:29:03 2008 +0100

    Add Kvm start code.

commit e4efbb2906f4f3876986e21c12b58791c3526bed
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Tue Feb 19 02:44:31 2008 +0100

    Add framework for Kvm test.

-----------------------------------------------------------------------

Summary of changes:
 source/selftest/config.mk     |    6 ++
 source/selftest/selftest.pl   |   21 +++++-
 source/selftest/target/Kvm.pm |  153 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 176 insertions(+), 4 deletions(-)
 create mode 100644 source/selftest/target/Kvm.pm


Changeset truncated at 500 lines:

diff --git a/source/selftest/config.mk b/source/selftest/config.mk
index 7f8f211..4e9d31b 100644
--- a/source/selftest/config.mk
+++ b/source/selftest/config.mk
@@ -10,6 +10,12 @@ SELFTEST = $(LD_LIBPATH_OVERRIDE) $(PERL) $(srcdir)/selftest/selftest.pl --prefi
 test:: everything
 	$(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS)
 
+kvmtest:: everything
+	$(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate --target=kvm --image=$(KVM_IMAGE)
+
+kvmquicktest:: everything
+	$(SELFTEST) $(DEFAULT_TEST_OPTIONS) --immediate --quick --target=kvm --image=$(KVM_IMAGE)
+
 testone:: everything
 	$(SELFTEST) $(DEFAULT_TEST_OPTIONS) --one $(TESTS)
 
diff --git a/source/selftest/selftest.pl b/source/selftest/selftest.pl
index aab2ca8..c17e790 100755
--- a/source/selftest/selftest.pl
+++ b/source/selftest/selftest.pl
@@ -13,7 +13,7 @@ selftest - Samba test runner
 
 selftest --help
 
-selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
+selftest [--srcdir=DIR] [--builddir=DIR] [--target=samba4|samba3|win|kvm] [--socket-wrapper] [--quick] [--exclude=FILE] [--include=FILE] [--one] [--prefix=prefix] [--immediate] [--testlist=FILE] [TESTS]
 
 =head1 DESCRIPTION
 
@@ -43,7 +43,7 @@ Change directory to run tests in. Default is 'st'.
 
 Show errors as soon as they happen rather than at the end of the test run.
 		
-=item I<--target samba4|samba3|win>
+=item I<--target samba4|samba3|win|kvm>
 
 Specify test target against which to run. Default is 'samba4'.
 
@@ -144,6 +144,7 @@ my $opt_expected_failures = undef;
 my @opt_exclude = ();
 my @opt_include = ();
 my $opt_verbose = 0;
+my $opt_image = undef;
 my $opt_testenv = 0;
 my $ldap = undef;
 my $opt_analyse_cmd = undef;
@@ -280,7 +281,7 @@ Usage: $Script [OPTIONS] PREFIX
 
 Generic options:
  --help                     this help page
- --target=samba4|samba3|win Samba version to target
+ --target=samba[34]|win|kvm Samba version to target
  --testlist=FILE			file to read available tests from
 
 Paths:
@@ -301,6 +302,9 @@ Samba4 Specific:
 Samba3 Specific:
  --bindir=PATH              path to binaries
 
+Kvm Specific:
+ --image=PATH               path to KVM image
+
 Behaviour:
  --quick                    run quick overall test
  --one                      abort when the first test fails
@@ -334,6 +338,7 @@ my $result = GetOptions (
 		'resetup-environment' => \$opt_resetup_env,
 		'bindir:s' => \$opt_bindir,
 		'format=s' => \$opt_format,
+		'image=s' => \$opt_image,
 		'testlist=s' => \@testlists
 	    );
 
@@ -442,6 +447,12 @@ if ($opt_target eq "samba4") {
 	$testenv_default = "dc";
 	require target::Windows;
 	$target = new Windows();
+} elsif ($opt_target eq "kvm") {
+	die("Kvm tests will not run with socket wrapper enabled.") 
+		if ($opt_socket_wrapper);
+	require target::Kvm;
+	die("No image specified") unless ($opt_image);
+	$target = new Kvm($opt_image);
 }
 
 sub read_test_regexes($)
@@ -522,11 +533,13 @@ sub write_clientconf($$)
 	if (defined($vars->{WINBINDD_SOCKET_DIR})) {
 		print CF "\twinbindd socket directory = $vars->{WINBINDD_SOCKET_DIR}\n";
 	}
+	if ($opt_socket_wrapper) {
+		print CF "\tinterfaces = $interfaces\n";
+	}
 	print CF "
 	private dir = $prefix_abs/client/private
 	js include = $srcdir_abs/scripting/libjs
 	name resolve order = bcast
-	interfaces = $interfaces
 	panic action = $srcdir_abs/script/gdb_backtrace \%PID\% \%PROG\%
 	max xmit = 32K
 	notify:inotify = false
diff --git a/source/selftest/target/Kvm.pm b/source/selftest/target/Kvm.pm
new file mode 100644
index 0000000..253f3b5
--- /dev/null
+++ b/source/selftest/target/Kvm.pm
@@ -0,0 +1,153 @@
+#!/usr/bin/perl
+# Start a KVM machine and run a number of tests against it.
+# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer at samba.org>
+# Published under the GNU GPL, v3 or later.
+
+package Kvm;
+
+use strict;
+use Cwd qw(abs_path);
+use FindBin qw($RealBin);
+use POSIX;
+
+sub new($$$$) {
+	my ($classname, $dc_image) = @_;
+	my $self = { 
+		dc_image => $dc_image,
+	};
+	bless $self;
+	return $self;
+}
+
+sub write_kvm_ifup($$$)
+{
+	my ($self, $path, $ip_prefix) = @_;
+	open(SCRIPT, ">$path/kvm-ifup");
+
+	print SCRIPT <<__EOF__;
+#!/bin/sh
+
+PREFIX=$ip_prefix
+
+/sbin/ifconfig \$1 \$PREFIX.1 up
+
+cat <<EOF>$path/udhcpd.conf
+interface \$1
+start 		\$PREFIX.20
+end		\$PREFIX.20
+max_leases 1
+lease_file	$path/udhcpd.leases
+pidfile	$path/udhcpd.pid
+EOF
+
+touch $path/udhcpd.leases
+
+/usr/sbin/udhcpd $path/udhcpd.conf
+
+exit 0
+__EOF__
+	close(SCRIPT);
+	chmod(0755, "$path/kvm-ifup");
+
+	return ("$path/kvm-ifup", "$path/udhcpd.pid", "$ip_prefix.20");
+}
+
+sub teardown_env($$)
+{
+	my ($self, $envvars) = @_;
+
+	print "Killing kvm instance $envvars->{KVM_PID}\n";
+
+	kill 9, $envvars->{KVM_PID};
+
+	print "Killing dhcpd instance $envvars->{DHCPD_PID}\n";
+	kill 9, $envvars->{DHCPD_PID};
+
+	return 0;
+}
+
+sub getlog_env($$)
+{
+	my ($self, $envvars) = @_;
+
+	return "";
+}
+
+sub check_env($$)
+{
+	my ($self, $envvars) = @_;
+
+	# FIXME: Check whether $self->{pid} is still running
+
+	return 1;
+}
+
+sub read_pidfile($)
+{
+	my ($path) = @_;
+
+	open(PID, $path);
+	<PID> =~ /([0-9]+)/;
+	my ($pid) = $1;
+	close(PID);
+	return $pid;
+}
+
+sub start($$$)
+{
+	my ($self, $path, $image) = @_;
+
+	my $pidfile = "$path/kvm.pid";
+
+	my $opts = (defined($ENV{KVM_OPTIONS})?$ENV{KVM_OPTIONS}:"-nographic");
+
+	if (defined($ENV{KVM_SNAPSHOT})) {
+		$opts .= " -loadvm $ENV{KVM_SNAPSHOT}";
+	}
+
+	my ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9");
+
+	system("kvm -name \"Samba 4 Test Subject\" $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net tap,script=$ifup_script");
+
+	return (read_pidfile($pidfile), read_pidfile($dhcpd_pidfile), $ip_address);
+}
+
+sub setup_env($$$)
+{
+	my ($self, $envname, $path) = @_;
+
+	if ($envname eq "dc") {
+		($self->{dc_pid}, $self->{dc_dhcpd_pid}, $self->{dc_ip}) = $self->start($path, $self->{dc_image});
+
+		sub choose_var($$) { 
+			my ($name, $default) = @_; 
+			return defined($ENV{"KVM_DC_$name"})?$ENV{"KVM_DC_$name"}:$default; 
+		}
+
+		if ($envname eq "dc") {
+			return {
+				KVM_PID => $self->{dc_pid},
+				DHCPD_PID => $self->{dc_dhcpd_pid},
+				USERNAME => choose_var("USERNAME", "Administrator"),
+				PASSWORD => choose_var("PASSWORD", "penguin"),
+				DOMAIN => choose_var("DOMAIN", "SAMBA"), 
+				REALM => choose_var("REALM", "SAMBA"), 
+				SERVER => choose_var("SERVER", "DC"), 
+				SERVER_IP => $self->{dc_ip},
+				NETBIOSNAME => choose_var("NETBIOSNAME", "DC"), 
+				NETBIOSALIAS => choose_var("NETBIOSALIAS", "DC"), 
+			};
+		} else {
+			return undef;
+		}
+	} else {
+		return undef;
+	}
+}
+
+sub stop($)
+{
+	my ($self) = @_;
+}
+
+1;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list