Skip to content

Commit 8436ff1

Browse files
author
BillXiang
committed
riscv64: Add unit test for SbiExt0_1ConsoleGetchar/Putchar
running 1 test test ioctls::vcpu::tests::test_run_code ... ok Signed-off-by: BillXiang <[email protected]>
1 parent 5cd1cbd commit 8436ff1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

kvm-ioctls/src/ioctls/vcpu.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,6 +2654,25 @@ mod tests {
26542654
0x03, 0xa5, 0x0c, 0x00, // lw a0, 0(s9); test MMIO read
26552655
0x93, 0x05, 0x70, 0x60, // li a1, 0x0607;
26562656
0x23, 0xa0, 0xbc, 0x00, // sw a1, 0(s9); test MMIO write
2657+
//sbi_console_getchar
2658+
0x01, 0x45, // li a0, 0
2659+
0x81, 0x45, // li a1, 0
2660+
0x01, 0x46, // li a2, 0
2661+
0x81, 0x46, // li a3, 0
2662+
0x01, 0x47, // li a4, 0
2663+
0x81, 0x47, // li a5, 0
2664+
0x01, 0x48, // li a6, 0
2665+
0x89, 0x48, // li a7, 2
2666+
0x73, 0x00, 0x00, 0x00, //ecall
2667+
//sbi_console_putchar
2668+
0x81, 0x45, // li a1, 0
2669+
0x01, 0x46, // li a2, 0
2670+
0x81, 0x46, // li a3, 0
2671+
0x01, 0x47, // li a4, 0
2672+
0x81, 0x47, // li a5, 0
2673+
0x01, 0x48, // li a6, 0
2674+
0x85, 0x48, // li a7, 1
2675+
0x73, 0x00, 0x00, 0x00, //ecall
26572676
0x6f, 0x00, 0x00, 0x00, // j .; shouldn't get here, but if so loop forever
26582677
];
26592678

@@ -2725,6 +2744,12 @@ mod tests {
27252744
.map(|page| page.count_ones())
27262745
.sum();
27272746
assert_eq!(dirty_pages, 1);
2747+
}
2748+
VcpuExit::SbiExt0_1ConsoleGetchar(data) => {
2749+
data[0] = 0x2a;
2750+
}
2751+
VcpuExit::SbiExt0_1ConsolePutchar(data) => {
2752+
assert_eq!(data, 0x2a);
27282753
break;
27292754
}
27302755
r => panic!("unexpected exit reason: {:?}", r),

0 commit comments

Comments
 (0)