mirror of
https://github.com/torvalds/linux.git
synced 2026-10-14 11:54:03 +02:00
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.com Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
5f82bbab84
commit
9291c9cef5
|
|
@ -1,4 +1,6 @@
|
|||
// 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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user