From d0123e0a9a4a9dc2e28d6f66afce73b9ab0b0936 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Jan 2010 09:36:48 +1100 Subject: s4-selftest: when a command fails show both normal and expanded command It is sometimes hard to tell which varient of something like $SMB_CONF_PATH or $USERNAME is being used in a test. By giving both the expanded command ($command with environment variables expanded) and non-expanded command it is easier to reproduce bugs outside the test environment. --- selftest/selftest.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'selftest/selftest.pl') diff --git a/selftest/selftest.pl b/selftest/selftest.pl index e7191efbf2..883d2a0d46 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -212,6 +212,17 @@ sub cleanup_pcap($$) unlink($pcap_file); } +# expand strings from %ENV +sub expand_environment_strings($) +{ + my $s = shift; + # we use a reverse sort so we do the longer ones first + foreach my $k (sort { $b cmp $a } keys %ENV) { + $s =~ s/\$$k/$ENV{$k}/g; + } + return $s; +} + sub run_testsuite($$$$$) { my ($envname, $name, $cmd, $i, $totalsuites) = @_; @@ -255,6 +266,7 @@ sub run_testsuite($$$$$) } print "command: $cmd\n"; + printf "expanded command: %s\n", expand_environment_strings($cmd); my $exitcode = $ret >> 8; -- cgit