mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-07-15 02:10:44 +00:00
fix(xcat-test): run testcase commands under bash, not /bin/sh
xcattest's runcmd ran each RUN: command via Perl backticks, i.e. /bin/sh. On Ubuntu /bin/sh is dash, so testcases using bashisms ([ x == y ], [[ ... ]]) error with "unexpected operator": the [ exits non-zero, the enclosing if is taken as false, and the case's distro-specific branch is silently skipped while the case still reports Passed -- a false pass. Run the command through bash via list-form open() so no intervening /bin/sh re-parses or re-expands the command's embedded quotes and backticks. EL is unaffected (its /bin/sh is already bash). Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
+7
-1
@@ -1683,7 +1683,13 @@ sub runcmd
|
||||
my $rc = 0;
|
||||
$::RUNCMD_RC = 0;
|
||||
my $outref = [];
|
||||
@$outref = `$cmd 2>&1`;
|
||||
# xCAT-test cases use bashisms ([ x == y ], [[ ]]); on Ubuntu /bin/sh is dash, so run
|
||||
# the command under bash. open('-|', LIST) execs bash directly -- no intervening
|
||||
# /bin/sh, so the cases' embedded quotes/backticks are not re-parsed or re-expanded.
|
||||
if (open(my $cfh, '-|', '/bin/bash', '-c', "$cmd 2>&1")) {
|
||||
@$outref = <$cfh>;
|
||||
close($cfh); # sets $? just like the backtick did
|
||||
}
|
||||
if ($?)
|
||||
{
|
||||
$rc = $?;
|
||||
|
||||
Reference in New Issue
Block a user