2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-21 16:39:30 +00:00
Files
xcat-core/xCAT-test/bats
Daniel Hilst b4735e10e2 test(xcat-core): the machine-type test accepts a cleanup that removes nothing
diskless_flat_vmothersetting_machine.bats checked the restore with a substring
match and checked the cleanup only for the absence of "unary operator
expected". A cleanup that writes the machine type back, or leaves it in place,
passed both.

The test now reads the value chdef receives. The restore must write exactly
machine:<type>, and must keep a setting the node already carries. The cleanup
must write an empty value when the machine type is all there is, and must leave
the other setting behind when there is one. The chdef stub brackets its
arguments so an empty value is not the same as no call.

ppc64le is red on the cleanup: the restore ladder writes
machine:pseries-rhel7.6.0 and the cleanup ladder removes machine:pseries-7.6.0,
so the node keeps the machine type. x86_64 and riscv64 pass.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-09-17 07:35:51 -03:00
..

xCAT-test/bats

Shell-script unit tests live here and run with:

bats -r xCAT-test/bats

The GitHub Actions xcat_test workflow runs this command after the Perl .t unit tests. Use BATS for shell behavior that can be exercised from the source tree without an installed xCAT, a live management node, or real services.

Prefer sourcing an existing shell library or sourceable script and calling the function under test. Keep reusable install-template helpers in xCAT-server/share/xcat/install/scripts/scriptlib, and reusable postscript helpers in xCAT/postscripts/xcatlib.sh. Use scratch directories and shadowed commands so tests cannot write to the host.

Extraction helpers in helpers/shell_source.bash are only for legacy code that cannot safely be sourced yet. Do not add Perl .t tests that grep shell source when the behavior can be tested with BATS.