selftest: create pcap files for invidual env services
authorStefan Metzmacher <metze@samba.org>
Wed, 30 Oct 2019 20:53:39 +0000 (21:53 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 6 Feb 2020 14:57:42 +0000 (14:57 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
selftest/target/Samba.pm
selftest/target/Samba3.pm
selftest/target/Samba4.pm

index de35eda5ce7a4f9e132928666bd92c82d1d3668c..70e61080f812c8417bfc81585fe34aac79ec3fb1 100644 (file)
@@ -18,11 +18,11 @@ sub new($$$$$) {
            $opt_socket_wrapper_pcap, $opt_socket_wrapper_keep_pcap) = @_;
 
        my $self = {
-           samba3 => new Samba3($bindir, $srcdir, $server_maxtime),
-           samba4 => new Samba4($bindir, $srcdir, $server_maxtime),
            opt_socket_wrapper_pcap => $opt_socket_wrapper_pcap,
            opt_socket_wrapper_keep_pcap => $opt_socket_wrapper_keep_pcap,
        };
+       $self->{samba3} = new Samba3($self, $bindir, $srcdir, $server_maxtime);
+       $self->{samba4} = new Samba4($self, $bindir, $srcdir, $server_maxtime);
        bless $self;
        return $self;
 }
@@ -670,6 +670,8 @@ sub get_env_for_process
 sub fork_and_exec
 {
        my ($self, $env_vars, $daemon_ctx, $STDIN_READER) = @_;
+       my $SambaCtx = $self;
+       $SambaCtx = $self->{SambaCtx} if defined($self->{SambaCtx});
 
        unlink($daemon_ctx->{LOG_FILE});
        print "STARTING $daemon_ctx->{NAME} for $ENV{ENVNAME}...";
@@ -694,7 +696,7 @@ sub fork_and_exec
 
                SocketWrapper::set_default_iface($env_vars->{SOCKET_WRAPPER_DEFAULT_IFACE});
                if (defined($daemon_ctx->{PCAP_FILE})) {
-                       SocketWrapper::setup_pcap($daemon_ctx->{PCAP_FILE});
+                       $SambaCtx->setup_pcap("$daemon_ctx->{PCAP_FILE}");
                }
 
                # setup ENV variables in the child process
index a3e2129b185404be19d77c61216da66c29e421f0..0c9adcc76fd7b202eda9141bf7abd5b0b9d6937d 100755 (executable)
@@ -54,8 +54,9 @@ sub get_fs_specific_conf($$)
 }
 
 sub new($$) {
-       my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
+       my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_;
        my $self = { vars => {},
+                    SambaCtx => $SambaCtx,
                     bindir => $bindir,
                     srcdir => $srcdir,
                     server_maxtime => $server_maxtime
@@ -1346,6 +1347,7 @@ sub check_or_start($$$$$) {
                BINARY_PATH => $binary,
                FULL_CMD => [ @full_cmd ],
                LOG_FILE => $env_vars->{NMBD_TEST_LOG},
+               PCAP_FILE => "env-$ENV{ENVNAME}-nmbd",
                ENV_VARS => $nmbd_envs,
        };
        if ($nmbd ne "yes") {
@@ -1370,6 +1372,7 @@ sub check_or_start($$$$$) {
                BINARY_PATH => $binary,
                FULL_CMD => [ @full_cmd ],
                LOG_FILE => $env_vars->{WINBINDD_TEST_LOG},
+               PCAP_FILE => "env-$ENV{ENVNAME}-winbindd",
        };
        if ($winbindd ne "yes") {
                $daemon_ctx->{SKIP_DAEMON} = 1;
@@ -1390,6 +1393,7 @@ sub check_or_start($$$$$) {
                BINARY_PATH => $binary,
                FULL_CMD => [ @full_cmd ],
                LOG_FILE => $env_vars->{SMBD_TEST_LOG},
+               PCAP_FILE => "env-$ENV{ENVNAME}-smbd",
        };
        if ($smbd ne "yes") {
                $daemon_ctx->{SKIP_DAEMON} = 1;
index e181289b66b28ed8f20bb273c725a4152d621c3a..3f25317ea8ccca25e27e317e9468e224b493b62b 100755 (executable)
@@ -20,14 +20,15 @@ use Archive::Tar;
 use File::Path 'make_path';
 
 sub new($$$$$) {
-       my ($classname, $bindir, $srcdir, $server_maxtime) = @_;
+       my ($classname, $SambaCtx, $bindir, $srcdir, $server_maxtime) = @_;
 
        my $self = {
                vars => {},
+               SambaCtx => $SambaCtx,
                bindir => $bindir,
                srcdir => $srcdir,
                server_maxtime => $server_maxtime,
-               target3 => new Samba3($bindir, $srcdir, $server_maxtime)
+               target3 => new Samba3($SambaCtx, $bindir, $srcdir, $server_maxtime)
        };
        bless $self;
        return $self;
@@ -89,6 +90,7 @@ sub check_or_start($$$)
                FULL_CMD => [ @full_cmd ],
                LOG_FILE => $env_vars->{SAMBA_TEST_LOG},
                TEE_STDOUT => 1,
+               PCAP_FILE => "env-$ENV{ENVNAME}-samba",
                ENV_VARS => $samba_envs,
        };
        my $pid = Samba::fork_and_exec($self, $env_vars, $daemon_ctx, $STDIN_READER);
@@ -323,14 +325,10 @@ sub setup_dns_hub_internal($$$)
                FULL_CMD => [ @full_cmd ],
                LOG_FILE => $env->{DNS_HUB_LOG},
                TEE_STDOUT => 1,
+               PCAP_FILE => "env-$ENV{ENVNAME}-dns_hub",
                ENV_VARS => {},
        };
 
-       my $pcap_dir = $ENV{SOCKET_WRAPPER_PCAP_DIR};
-       if (defined $pcap_dir) {
-               $daemon_ctx->{PCAP_FILE} = "$pcap_dir/env-$hostname$.pcap",
-       }
-
        # use a pipe for stdin in the child processes. This allows
        # those processes to monitor the pipe for EOF to ensure they
        # exit when the test script exits