Skip to content

Commit 417bfd0

Browse files
committed
KVM: selftests: Convert the x86 userspace I/O test to printf guest assert
Convert x86's userspace I/O test to use printf-based guest asserts. Link: https://lore.kernel.org/r/20230729003643.1053367-30-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 847ae07 commit 417bfd0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tools/testing/selftests/kvm/x86_64/userspace_io_test.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0
2+
#define USE_GUEST_ASSERT_PRINTF 1
3+
24
#include <fcntl.h>
35
#include <stdio.h>
46
#include <stdlib.h>
@@ -20,8 +22,8 @@ static void guest_ins_port80(uint8_t *buffer, unsigned int count)
2022
end = (unsigned long)buffer + 8192;
2123

2224
asm volatile("cld; rep; insb" : "+D"(buffer), "+c"(count) : "d"(0x80) : "memory");
23-
GUEST_ASSERT_1(count == 0, count);
24-
GUEST_ASSERT_2((unsigned long)buffer == end, buffer, end);
25+
GUEST_ASSERT_EQ(count, 0);
26+
GUEST_ASSERT_EQ((unsigned long)buffer, end);
2527
}
2628

2729
static void guest_code(void)
@@ -43,7 +45,9 @@ static void guest_code(void)
4345
memset(buffer, 0, sizeof(buffer));
4446
guest_ins_port80(buffer, 8192);
4547
for (i = 0; i < 8192; i++)
46-
GUEST_ASSERT_2(buffer[i] == 0xaa, i, buffer[i]);
48+
__GUEST_ASSERT(buffer[i] == 0xaa,
49+
"Expected '0xaa', got '0x%x' at buffer[%u]",
50+
buffer[i], i);
4751

4852
GUEST_DONE();
4953
}
@@ -91,7 +95,7 @@ int main(int argc, char *argv[])
9195
case UCALL_DONE:
9296
break;
9397
case UCALL_ABORT:
94-
REPORT_GUEST_ASSERT_2(uc, "argN+1 = 0x%lx, argN+2 = 0x%lx");
98+
REPORT_GUEST_ASSERT(uc);
9599
default:
96100
TEST_FAIL("Unknown ucall %lu", uc.cmd);
97101
}

0 commit comments

Comments
 (0)