| 1135 | ri(RealInstruction::Csrrs(Csrrs::new(10, 0xC02, 0))), |
| 1136 | ri(RealInstruction::Addi(Addi::new(17, 0, 93))), // a7 = 93 |
| 1137 | ri(RealInstruction::Ecall(Ecall::new())), |
| 1138 | ]); |
| 1139 | // instret should be >= 3 (the 3 nops have retired; csrrs reads the count before incrementing) |
| 1140 | assert!( |
| 1141 | matches!(outcome, RunOutcome::Halted(n) if n >= 3), |
| 1142 | "expected instret >= 3, got {outcome:?}" |
| 1143 | ); |
| 1144 | } |
| 1145 | |
| 1146 | // --- End-to-end qemu program tests (full HLL pipeline through VM) --- |
| 1147 | |
| 1148 | #[test] |
| 1149 | fn qemu_01_arithmetic_and_types() { |
| 1150 | let (_, outcome, _) = run_hll_file("programs/test/qemu/01_arithmetic_and_types.hll"); |
| 1151 | assert!( |
| 1152 | matches!(outcome, RunOutcome::Halted(42)), |
| 1153 | "expected Halted(42), got {outcome:?}" |
| 1154 | ); |
| 1155 | } |
| 1156 | |
| 1157 | #[test] |
| 1158 | fn qemu_02_control_flow() { |
| 1159 | let (_, outcome, _) = run_hll_file("programs/test/qemu/02_control_flow.hll"); |