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>
When a test case file is missing the end marker and the last line is a
cmd: directive, $newcmdstart stays set. The parser then appends lines
from the next file into the current command. If that next file is a
shell script (like simulatorctl.sh in the testcase tree), thousands of
lines of Perl/bash get concatenated and executed.
Reset $newcmdstart after closing each file to prevent state leaking
between files.
Fixes#5255
xcattest will replace vars in testcases.
But vars with same prefix will lead to a replacement failure.
Issue:
XCATTEST_PORT=500 XCATTEST_CN=xcat-com001 XCATTEST_PDU=xmount XCATTEST_PDUIP=192.168.200.100 xcattest -t mkdef_pdu_object
cmd:mkdef $$PDU groups=pdu ip=$$PDUIP mgt=pdu nodetype=pdu
will be:
RUN:mkdef xmount groups=pdu ip=xmountIP mgt=pdu nodetype=pdu
$$PDUIP had no chance to be substituted.
Reported-by: Yang Jian <fun_yang@foxmail.com>
Signed-off-by: Chen Hanxiao <chen_han_xiao@126.com>
- to support customize the testcase dir with environment variable XCATTEST_CASEDIR
- to allow to print more debug info with environment variable XCATTEST_DEBUG
- to add a new func to get general object attribute (__GETOBJECTATTR(...)__)
2, allow xcattest get 'var' type config from environment variable when no config file specified.
For example, when given 'XCATTEST_CN=fake1', xcattest will set $$CN=fake1