From: Noel Power Date: Mon, 30 Nov 2020 10:18:32 +0000 (+0000) Subject: s3/script/tests: Make smb_client 'die' behaviour configurable X-Git-Tag: samba-4.14.0rc1~520 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=363bfa4e1ca10e64057a6d04d6faff7c788db89d;p=thirdparty%2Fsamba.git s3/script/tests: Make smb_client 'die' behaviour configurable smb_client behaviour is to die if there is an error. This is a little heavy handed and make it impossible for example to use smb_client to run a command that might fail (where such a failure isn't really an error) E.G. Calling deltree and the directory doesn't exist BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison --- diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl index 4aaee3e8c9c..7b9e2f938d1 100755 --- a/source3/script/tests/test_smbclient_tarmode.pl +++ b/source3/script/tests/test_smbclient_tarmode.pl @@ -1118,7 +1118,9 @@ sub check_tar { return (@more + @less + @diff); # nb of errors } -=head3 C +=head3 C + +=head3 C Run smbclient with C<@args> passed as argument and return output. @@ -1129,11 +1131,12 @@ the command-line are already inserted. The output contains both the C and C. -Die if smbclient crashes or exits with an error code. +if C<$will_die> then Die if smbclient crashes or exits with an error code. +otherwise return output =cut -sub smb_client { - my (@args) = @_; +sub smb_client_cmd { + my ($will_die, @args) = @_; my $fullpath = "//$HOST/$SHARE"; my $cmd = sprintf("%s %s %s", @@ -1166,11 +1169,34 @@ sub smb_client { } if ($err) { - die "ERROR: $errstr"; + if ($will_die) { + die "ERROR: $errstr"; + } else { + say "ERROR: $errstr"; + } } return $out; } +=head3 C + +Run smbclient with C<@args> passed as argument and return output. + +Each element of C<@args> becomes one escaped argument of smbclient. + +Host, share, user, password and the additionnal arguments provided on +the command-line are already inserted. + +The output contains both the C and C. + +Die if smbclient crashes or exits with an error code. + +=cut +sub smb_client { + my (@args) = @_; + return smb_client_cmd(1, @args) +} + sub smb_cmd { return smb_client('-c', join(' ', @_)); }