s4-selftest: when a command fails show both normal and expanded command
authorAndrew Tridgell <tridge@samba.org>
Sun, 10 Jan 2010 22:36:48 +0000 (09:36 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sun, 10 Jan 2010 22:55:28 +0000 (09:55 +1100)
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

index e7191efbf2cc7fbe4aac1ada9995483d66ccea61..883d2a0d463816452f592324df49b6d4eef13687 100755 (executable)
@@ -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;