|
|
my $tmp_script = "$cfg::tmpdir/buftest.$host.$PROCESS_ID.sh"; | my $tmp_script = "$cfg::tmpdir/buftest.$host.$PROCESS_ID.sh"; |
my $retval = 0; | my $retval = 0; |
my $pipecmd; | my $pipecmd; |
|
my $explicit_success; |
| |
$buffer_cmd =~ s:^\s*\|\s*::; | $buffer_cmd =~ s:^\s*\|\s*::; |
$buffer_cmd =~ s:\s*\|\s*$::; | $buffer_cmd =~ s:\s*\|\s*$::; |
|
|
print SCR "res=\$?\n"; | print SCR "res=\$?\n"; |
print SCR "out=\`cat \$tmp_err\`\n"; | print SCR "out=\`cat \$tmp_err\`\n"; |
print SCR "if [ \$res -eq 0 ]; then\n"; | print SCR "if [ \$res -eq 0 ]; then\n"; |
print SCR " echo successful\n"; |
print SCR " echo \"successful\"\n"; |
print SCR "else\n"; | print SCR "else\n"; |
print SCR " echo \"unsuccessful: exit code \$res: \$out\" \n"; | print SCR " echo \"unsuccessful: exit code \$res: \$out\" \n"; |
print SCR "fi\n"; | print SCR "fi\n"; |
|
|
$pipecmd = "sh $tmp_script "; | $pipecmd = "sh $tmp_script "; |
} else { | } else { |
print $::msg "| Checking '$cfg::buffer' on host $host... "; | print $::msg "| Checking '$cfg::buffer' on host $host... "; |
$pipecmd = "cat $tmp_script | ($::remoteshell $host 'cat > $tmp_script; sh $tmp_script; rm -f $tmp_script')"; |
$pipecmd = "$::remoteshell $host '$::path{mkdir} -p $cfg::tmpdir'; cat $tmp_script | ($::remoteshell $host 'cat > $tmp_script; sh $tmp_script; rm -rf $cfg::tmpdir')"; |
} | } |
| |
if (!defined($::debug)) { | if (!defined($::debug)) { |
| |
open(PIPE,"$pipecmd |") || die; | open(PIPE,"$pipecmd |") || die; |
|
|
|
$explicit_success = 0; |
while (<PIPE>) { | while (<PIPE>) { |
|
if (/^successful$/) { |
|
$explicit_success = 1; |
|
last; |
|
} |
if (/^unsuccessful: exit code (\d+): (.*)/) { | if (/^unsuccessful: exit code (\d+): (.*)/) { |
$retval = $1; | $retval = $1; |
my $out = $2; | my $out = $2; |
|
|
print $::msg "\n(debug) $pipecmd\n"; | print $::msg "\n(debug) $pipecmd\n"; |
} | } |
| |
if ($retval == 0) { |
if ($explicit_success) { |
print $::msg "Ok\n"; | print $::msg "Ok\n"; |
} else { | } else { |
|
if ($retval == 0) { |
|
push(@::errors, "Unanticipated problems encountered testing '$cfg::buffer' on host '$host'."); |
|
} else { |
print $::msg "Failed!\n"; | print $::msg "Failed!\n"; |
} | } |
|
} |
unlink("$tmp_script"); | unlink("$tmp_script"); |
| |
return($retval); | return($retval); |