diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-02-25 12:58:09 +0100 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-02-25 12:58:09 +0100 |
commit | 584c4a518f4d18452b6515db132e4f75fba733a1 (patch) | |
tree | bbe367f36f092f233d7aefb61d75d5d1e1e85031 /source4/selftest | |
parent | 03ab8f9d79f2a06b357b2f5d392ea8b5be263c5e (diff) | |
parent | 71943b209b181e1e4a65ab477b83780add7051ae (diff) | |
download | samba-584c4a518f4d18452b6515db132e4f75fba733a1.tar.gz samba-584c4a518f4d18452b6515db132e4f75fba733a1.tar.bz2 samba-584c4a518f4d18452b6515db132e4f75fba733a1.zip |
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-gmake3
Conflicts:
source/build/smb_build/header.pm
source/build/smb_build/makefile.pm
source/lib/ldb/include/ldb_private.h
(This used to be commit 1a646af0647f021d99473a8991c35e616a423ea6)
Diffstat (limited to 'source4/selftest')
-rw-r--r-- | source4/selftest/config.mk | 6 | ||||
-rwxr-xr-x | source4/selftest/samba4_tests.sh | 12 | ||||
-rwxr-xr-x | source4/selftest/selftest.pl | 50 | ||||
-rw-r--r-- | source4/selftest/target/Kvm.pm | 167 | ||||
-rw-r--r-- | source4/selftest/target/Samba4.pm | 7 |
5 files changed, 228 insertions, 14 deletions
diff --git a/source4/selftest/config.mk b/source4/selftest/config.mk index 7f8f211588..4e9d31b684 100644 --- a/source4/selftest/config.mk +++ b/source4/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/source4/selftest/samba4_tests.sh b/source4/selftest/samba4_tests.sh index d86c46432e..32386e5b9e 100755 --- a/source4/selftest/samba4_tests.sh +++ b/source4/selftest/samba4_tests.sh @@ -50,8 +50,9 @@ plansmbtorturetest() { name=$1 env=$2 shift 2 + other_args="$*" modname=`normalize_testname $name` - cmdline="$VALGRIND $smb4torture $* $name" + cmdline="$VALGRIND $smb4torture $other_args $name" plantest "$modname" "$env" $cmdline } @@ -215,12 +216,13 @@ done plantest "rpc.echo on ncacn_np over smb2" dc $smb4torture ncacn_np:"\$SERVER[smb2]" -U"\$USERNAME"%"\$PASSWORD" -W \$DOMAIN RPC-ECHO "$*" # Tests against the NTVFS POSIX backend +NTVFSARGS="--option=torture:sharedelay=100000" smb2=`$smb4torture --list | grep "^SMB2-" | xargs` raw=`$smb4torture --list | grep "^RAW-" | xargs` base=`$smb4torture --list | grep "^BASE-" | xargs` for t in $base $raw $smb2; do - plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" + plansmbtorturetest "$t" dc $ADDARGS //\$SERVER/tmp -U"\$USERNAME"%"\$PASSWORD" $NTVFSARGS done rap=`$smb4torture --list | grep "^RAP-" | xargs` @@ -230,13 +232,13 @@ done # Tests against the NTVFS CIFS backend for t in $base $raw; do - plantest "ntvfs.cifs.`normalize_testname $t`" dc $VALGRIND $smb4torture //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $t + plantest "ntvfs.cifs.`normalize_testname $t`" dc $VALGRIND $smb4torture //\$NETBIOSNAME/cifs -U"\$USERNAME"%"\$PASSWORD" $NTVFSARGS $t done # Local tests for t in `$smb4torture --list | grep "^LOCAL-" | xargs`; do - plansmbtorturetest "$t" none $VALGRIND $smb4torture ncalrpc: "$*" + plansmbtorturetest "$t" none ncalrpc: "$*" done if test -f $samba4bindir/tdbtorture @@ -293,7 +295,7 @@ plantest "wbinfo -a against member server with domain creds" member $VALGRIND $s NBT_TESTS=`$smb4torture --list | grep "^NBT-" | xargs` for t in $NBT_TESTS; do - plansmbtorturetest "$t" dc //\$SERVER/_none_ $f -U\$USERNAME%\$PASSWORD + plansmbtorturetest "$t" dc //\$SERVER/_none_ -U\$USERNAME%\$PASSWORD done WB_OPTS="--option=\"torture:strict mode=yes\"" diff --git a/source4/selftest/selftest.pl b/source4/selftest/selftest.pl index aab2ca8f07..73d03f3d4c 100755 --- a/source4/selftest/selftest.pl +++ b/source4/selftest/selftest.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl # Bootstrap Samba and run a number of tests against it. -# Copyright (C) 2005-2007 Jelmer Vernooij <jelmer@samba.org> +# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@samba.org> # Published under the GNU GPL, v3 or later. =pod @@ -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; @@ -203,7 +204,7 @@ sub getlog_env($); sub setup_pcap($) { - my ($state, $name) = @_; + my ($name) = @_; return unless ($opt_socket_wrapper_pcap); return unless defined($ENV{SOCKET_WRAPPER_PCAP_DIR}); @@ -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,37 @@ 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, undef); +} + +# +# Start a Virtual Distributed Ethernet Switch +# Returns the pid of the switch. +# +sub start_vde_switch($) +{ + my ($path) = @_; + + system("vde_switch --pidfile $path/vde.pid --sock $path/vde.sock --daemon"); + + open(PID, "$path/vde.pid"); + <PID> =~ /([0-9]+)/; + my $pid = $1; + close(PID); + + return $pid; +} + +# Stop a Virtual Distributed Ethernet Switch +sub stop_vde_switch($) +{ + my ($pid) = @_; + kill 9, $pid; } sub read_test_regexes($) @@ -522,11 +558,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/source4/selftest/target/Kvm.pm b/source4/selftest/target/Kvm.pm new file mode 100644 index 0000000000..3b17a2909c --- /dev/null +++ b/source4/selftest/target/Kvm.pm @@ -0,0 +1,167 @@ +#!/usr/bin/perl +# Start a KVM machine and run a number of tests against it. +# Copyright (C) 2005-2008 Jelmer Vernooij <jelmer@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, $vdesocket) = @_; + my $self = { + dc_image => $dc_image, + vdesocket => $vdesocket, + }; + 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}; + + if (defined($envvars->{DHCPD_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 $netopts; + my $dhcp_pid; + my $ip_address; + + if ($self->{vdesocket}) { + $netopts = "vde,socket=$self->{vdesocket}"; + } else { + my $ifup_script, $dhcpd_pidfile; + ($ifup_script, $dhcpd_pidfile, $ip_address) = $self->write_kvm_ifup($path, "192.168.9"); + $netopts = "tap,script=$ifup_script"; + $dhcp_pid = read_pidfile($dhcpd_pidfile); + } + + system("kvm -name \"Samba 4 Test Subject\" $opts -monitor unix:$path/kvm.monitor,server,nowait -daemonize -pidfile $pidfile -snapshot $image -net nic -net $netopts"); + + return (read_pidfile($pidfile), $dhcp_pid, $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; diff --git a/source4/selftest/target/Samba4.pm b/source4/selftest/target/Samba4.pm index 563aca876e..37e3cbe354 100644 --- a/source4/selftest/target/Samba4.pm +++ b/source4/selftest/target/Samba4.pm @@ -676,10 +676,10 @@ nogroup:x:65534:nobody push (@provision_options, "NSS_WRAPPER_GROUP=\"$nsswrap_group\""); if (defined($ENV{PROVISION_EJS})) { push (@provision_options, "$self->{bindir}/smbscript"); - push (@provision_options, "$self->{setupdir}/provision"); + push (@provision_options, "$self->{setupdir}/provision.js"); } else { push (@provision_options, "$self->{bindir}/smbpython"); - push (@provision_options, "$self->{setupdir}/provision.py"); + push (@provision_options, "$self->{setupdir}/provision"); } push (@provision_options, split(' ', $configuration)); push (@provision_options, "--host-name=$netbiosname"); @@ -729,9 +729,10 @@ nogroup:x:65534:nobody if ($self->{ldap} eq "openldap") { ($ret->{SLAPD_CONF}, $ret->{OPENLDAP_PIDFILE}) = $self->mk_openldap($ldapdir, $configuration) or die("Unable to create openldap directories"); + push (@provision_options, "--ldap-backend-type=openldap"); } elsif ($self->{ldap} eq "fedora-ds") { ($ret->{FEDORA_DS_DIR}, $ret->{FEDORA_DS_PIDFILE}) = $self->mk_fedora_ds($ldapdir, $configuration) or die("Unable to create fedora ds directories"); - push (@provision_options, "--ldap-module=nsuniqueid"); + push (@provision_options, "--ldap-backend-type=fedora-ds"); push (@provision_options, "'--aci=aci:: KHRhcmdldGF0dHIgPSAiKiIpICh2ZXJzaW9uIDMuMDthY2wgImZ1bGwgYWNjZXNzIHRvIGFsbCBieSBhbGwiO2FsbG93IChhbGwpKHVzZXJkbiA9ICJsZGFwOi8vL2FueW9uZSIpOykK'"); } |