MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / test_setlint

Function test_setlint

vmm/src/cpu.rs:3292–3317  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3290
3291 #[test]
3292 fn test_setlint() {
3293 let hv = hypervisor::new().unwrap();
3294 let vm = hv
3295 .create_vm(HypervisorVmConfig::default())
3296 .expect("new VM fd creation failed");
3297 hv.check_required_extensions().unwrap();
3298 // Calling get_lapic will fail if there is no irqchip before hand.
3299 vm.create_irq_chip().unwrap();
3300 let vcpu = vm.create_vcpu(0, None).unwrap();
3301 let klapic_before: LapicState = vcpu.get_lapic().unwrap();
3302
3303 // Compute the value that is expected to represent LVT0 and LVT1.
3304 let lint0 = klapic_before.get_klapic_reg(APIC_LVT0);
3305 let lint1 = klapic_before.get_klapic_reg(APIC_LVT1);
3306 let lint0_mode_expected = set_apic_delivery_mode(lint0, APIC_MODE_EXTINT);
3307 let lint1_mode_expected = set_apic_delivery_mode(lint1, APIC_MODE_NMI);
3308
3309 set_lint(vcpu.as_ref()).unwrap();
3310
3311 // Compute the value that represents LVT0 and LVT1 after set_lint.
3312 let klapic_actual: LapicState = vcpu.get_lapic().unwrap();
3313 let lint0_mode_actual = klapic_actual.get_klapic_reg(APIC_LVT0);
3314 let lint1_mode_actual = klapic_actual.get_klapic_reg(APIC_LVT1);
3315 assert_eq!(lint0_mode_expected, lint0_mode_actual);
3316 assert_eq!(lint1_mode_expected, lint1_mode_actual);
3317 }
3318
3319 #[test]
3320 fn test_setup_fpu() {

Callers

nothing calls this directly

Calls 9

newFunction · 0.85
set_apic_delivery_modeFunction · 0.85
set_lintFunction · 0.85
get_klapic_regMethod · 0.80
create_vmMethod · 0.45
create_irq_chipMethod · 0.45
create_vcpuMethod · 0.45
get_lapicMethod · 0.45

Tested by

no test coverage detected