Skip to content

Commit 7f1d731

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 983d7da commit 7f1d731

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
@@ -2650,6 +2650,25 @@ mod tests {
26502650
0x03, 0xa5, 0x0c, 0x00, // lw a0, 0(s9); test MMIO read
26512651
0x93, 0x05, 0x70, 0x60, // li a1, 0x0607;
26522652
0x23, 0xa0, 0xbc, 0x00, // sw a1, 0(s9); test MMIO write
2653+
//sbi_console_getchar
2654+
0x01, 0x45, // li a0, 0
2655+
0x81, 0x45, // li a1, 0
2656+
0x01, 0x46, // li a2, 0
2657+
0x81, 0x46, // li a3, 0
2658+
0x01, 0x47, // li a4, 0
2659+
0x81, 0x47, // li a5, 0
2660+
0x01, 0x48, // li a6, 0
2661+
0x89, 0x48, // li a7, 2
2662+
0x73, 0x00, 0x00, 0x00, //ecall
2663+
//sbi_console_putchar
2664+
0x81, 0x45, // li a1, 0
2665+
0x01, 0x46, // li a2, 0
2666+
0x81, 0x46, // li a3, 0
2667+
0x01, 0x47, // li a4, 0
2668+
0x81, 0x47, // li a5, 0
2669+
0x01, 0x48, // li a6, 0
2670+
0x85, 0x48, // li a7, 1
2671+
0x73, 0x00, 0x00, 0x00, //ecall
26532672
0x6f, 0x00, 0x00, 0x00, // j .; shouldn't get here, but if so loop forever
26542673
];
26552674

@@ -2721,6 +2740,12 @@ mod tests {
27212740
.map(|page| page.count_ones())
27222741
.sum();
27232742
assert_eq!(dirty_pages, 1);
2743+
}
2744+
VcpuExit::SbiExt0_1ConsoleGetchar(data) => {
2745+
data[0] = 0x2a;
2746+
}
2747+
VcpuExit::SbiExt0_1ConsolePutchar(data) => {
2748+
assert_eq!(data, 0x2a);
27242749
break;
27252750
}
27262751
r => panic!("unexpected exit reason: {:?}", r),

0 commit comments

Comments
 (0)