Commit 9291c9ce authored by Sean Christopherson's avatar Sean Christopherson

KVM: selftests: Convert set_memory_region_test to printf-based GUEST_ASSERT

Convert set_memory_region_test to print-based GUEST_ASSERT, using a combo
of newfangled macros to report (hopefully) useful information.

Link: https://lore.kernel.org/r/20230729003643.1053367-19-seanjc@google.comSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
parent 5f82bbab
// SPDX-License-Identifier: GPL-2.0
#define USE_GUEST_ASSERT_PRINTF 1
#define _GNU_SOURCE /* for program_invocation_short_name */
#include <fcntl.h>
#include <pthread.h>
......@@ -88,7 +90,7 @@ static void *vcpu_worker(void *data)
}
if (run->exit_reason == KVM_EXIT_IO && cmd == UCALL_ABORT)
REPORT_GUEST_ASSERT_1(uc, "val = %lu");
REPORT_GUEST_ASSERT(uc);
return NULL;
}
......@@ -156,19 +158,22 @@ static void guest_code_move_memory_region(void)
* window where the memslot is invalid is usually quite small.
*/
val = guest_spin_on_val(0);
GUEST_ASSERT_1(val == 1 || val == MMIO_VAL, val);
__GUEST_ASSERT(val == 1 || val == MMIO_VAL,
"Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val);
/* Spin until the misaligning memory region move completes. */
val = guest_spin_on_val(MMIO_VAL);
GUEST_ASSERT_1(val == 1 || val == 0, val);
__GUEST_ASSERT(val == 1 || val == 0,
"Expected '0' or '1' (no MMIO), got '%llx'", val);
/* Spin until the memory region starts to get re-aligned. */
val = guest_spin_on_val(0);
GUEST_ASSERT_1(val == 1 || val == MMIO_VAL, val);
__GUEST_ASSERT(val == 1 || val == MMIO_VAL,
"Expected '1' or MMIO ('%llx'), got '%llx'", MMIO_VAL, val);
/* Spin until the re-aligning memory region move completes. */
val = guest_spin_on_val(MMIO_VAL);
GUEST_ASSERT_1(val == 1, val);
GUEST_ASSERT_EQ(val, 1);
GUEST_DONE();
}
......@@ -224,15 +229,15 @@ static void guest_code_delete_memory_region(void)
/* Spin until the memory region is deleted. */
val = guest_spin_on_val(0);
GUEST_ASSERT_1(val == MMIO_VAL, val);
GUEST_ASSERT_EQ(val, MMIO_VAL);
/* Spin until the memory region is recreated. */
val = guest_spin_on_val(MMIO_VAL);
GUEST_ASSERT_1(val == 0, val);
GUEST_ASSERT_EQ(val, 0);
/* Spin until the memory region is deleted. */
val = guest_spin_on_val(0);
GUEST_ASSERT_1(val == MMIO_VAL, val);
GUEST_ASSERT_EQ(val, MMIO_VAL);
asm("1:\n\t"
".pushsection .rodata\n\t"
......@@ -249,7 +254,7 @@ static void guest_code_delete_memory_region(void)
"final_rip_end: .quad 1b\n\t"
".popsection");
GUEST_ASSERT_1(0, 0);
GUEST_ASSERT(0);
}
static void test_delete_memory_region(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment