mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-21 16:39:30 +00:00
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>
This commit is contained in:
@@ -45,13 +45,20 @@ run_case_command()
|
||||
cmd="${cmd//\$\$CN/cn1}"
|
||||
|
||||
OUT="$(bash -c "lsdef() { echo ' vmothersetting=$lsdef_value'; }
|
||||
chdef() { echo \"CHDEF:\$*\"; }
|
||||
chdef() { echo \"CHDEF:[\$*]\"; }
|
||||
$cmd" 2>&1)" || true
|
||||
WRITTEN="$(sed -n 's/^CHDEF:cn1 vmothersetting=//p' <<<"$OUT")"
|
||||
# The brackets keep an empty value apart from no call at all: the cleanup is meant to write
|
||||
# an empty vmothersetting, and a command that never reaches chdef must not read as that.
|
||||
CHDEF_CALLS="$(grep -c '^CHDEF:' <<<"$OUT" || true)"
|
||||
WRITTEN="$(sed -n 's/^CHDEF:\[cn1 vmothersetting=\(.*\)\]$/\1/p' <<<"$OUT")"
|
||||
}
|
||||
|
||||
# The machine type each architecture must end up with. riscv64 guests run the qemu "virt"
|
||||
# machine; kvm.pm sets it in guest_arch_profile.
|
||||
#
|
||||
# The restore writes the machine type; the cleanup after it takes the same machine type away
|
||||
# again and leaves every other setting. Both read the same ladder, so both are checked against
|
||||
# the same value.
|
||||
assert_arch()
|
||||
{
|
||||
local arch="$1" machine="$2" restore remove
|
||||
@@ -59,27 +66,37 @@ assert_arch()
|
||||
restore="$(restore_command)"
|
||||
remove="$(remove_command)"
|
||||
|
||||
# The node carries the corrupt value only.
|
||||
run_case_command "$restore" "$arch" 'machine:invalid'
|
||||
[ -n "$WRITTEN" ]
|
||||
[[ "$WRITTEN" == *machine:* ]]
|
||||
[[ "$WRITTEN" == *"$machine"* ]]
|
||||
[ "$CHDEF_CALLS" -eq 1 ]
|
||||
[ "$WRITTEN" = "machine:$machine" ]
|
||||
|
||||
# The check the case runs straight after the restore.
|
||||
[[ "$WRITTEN" == *machine* ]]
|
||||
# The node carries a setting of its own beside the corrupt value.
|
||||
run_case_command "$restore" "$arch" 'cpumode:host-passthrough;machine:invalid'
|
||||
[ "$CHDEF_CALLS" -eq 1 ]
|
||||
[ "$WRITTEN" = "cpumode:host-passthrough;machine:$machine" ]
|
||||
|
||||
# The remove path reads the same ladder; it must not die on an empty str3.
|
||||
# The cleanup, with nothing but the machine type to remove.
|
||||
run_case_command "$remove" "$arch" "machine:$machine"
|
||||
[ "$(grep -c 'unary operator expected' <<<"$OUT")" -eq 0 ]
|
||||
[ "$CHDEF_CALLS" -eq 1 ]
|
||||
[ "$WRITTEN" = "" ]
|
||||
|
||||
# The cleanup, with a setting of its own that must survive it.
|
||||
run_case_command "$remove" "$arch" "cpumode:host-passthrough;machine:$machine"
|
||||
[ "$(grep -c 'unary operator expected' <<<"$OUT")" -eq 0 ]
|
||||
[ "$CHDEF_CALLS" -eq 1 ]
|
||||
[ "$WRITTEN" = "cpumode:host-passthrough" ]
|
||||
}
|
||||
|
||||
@test "ppc64le: the restore writes the machine type, and the remove path compares two strings" {
|
||||
assert_arch ppc64le pseries
|
||||
@test "ppc64le: the restore writes the machine type and the cleanup takes it away" {
|
||||
assert_arch ppc64le pseries-rhel7.6.0
|
||||
}
|
||||
|
||||
@test "x86_64: the restore writes the machine type, and the remove path compares two strings" {
|
||||
@test "x86_64: the restore writes the machine type and the cleanup takes it away" {
|
||||
assert_arch x86_64 pc
|
||||
}
|
||||
|
||||
@test "riscv64: the restore writes the machine type, and the remove path compares two strings" {
|
||||
@test "riscv64: the restore writes the machine type and the cleanup takes it away" {
|
||||
assert_arch riscv64 virt
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user