Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit 7274d86

Browse files
RuoqingHerbradford
authored andcommitted
x86: Repurpose test_set_gsi_routing
Compilation would fail with previous code on other architectures don't have `create_irq_chip` available. Repurpose this unit test to work on all architectures. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
1 parent 4e1c6c4 commit 7274d86

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/ioctls/vm.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,16 +2678,19 @@ mod tests {
26782678
fn test_set_gsi_routing() {
26792679
let kvm = Kvm::new().unwrap();
26802680
let vm = kvm.create_vm().unwrap();
2681-
if cfg!(target_arch = "x86") || cfg!(target_arch = "x86_64") {
2682-
let irq_routing = kvm_irq_routing::default();
2683-
// Expect failure for x86 since the irqchip is not created yet.
2684-
vm.set_gsi_routing(&irq_routing).unwrap_err();
2685-
vm.create_irq_chip().unwrap();
2686-
}
2687-
// RISC-V 64-bit expect an AIA device to be created in advance of committing irq_routing table.
2681+
let irq_routing = kvm_irq_routing::default();
2682+
2683+
// Expect failure for x86 since the irqchip is not created yet.
2684+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2685+
vm.set_gsi_routing(&irq_routing).unwrap_err();
2686+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2687+
vm.create_irq_chip().unwrap();
2688+
2689+
// RISC-V 64-bit expect an AIA device to be created in advance of
2690+
// committing irq_routing table.
26882691
#[cfg(target_arch = "riscv64")]
26892692
create_aia_device(&vm, 0);
2690-
let irq_routing = kvm_irq_routing::default();
2693+
26912694
vm.set_gsi_routing(&irq_routing).unwrap();
26922695
}
26932696

0 commit comments

Comments
 (0)