rust-vmm / kvm

281 stars 107 forks source link

Add negative tests for vcpu ioctls on aarch64 #116

Open andreeaflorescu opened 4 years ago

andreeaflorescu commented 4 years ago

There are already negative tests for x86_64: https://github.com/rust-vmm/kvm-ioctls/blob/a6380052496c2db83fbbc0936ea66afc87b742a8/src/ioctls/vcpu.rs#L1813

We should make sure that we do not duplicate test code. We can do that by having a platform independent negative test with ioctls that are valid on all supported platforms, and 2 platform dependent tests (one for x86_64, and one for aarch64).

anth1y commented 3 years ago

does this issue still need to be worked on? @andreeaflorescu

andreeaflorescu commented 3 years ago

@anth1y yes, this is still relevant. We need to also provide negative tests (similar to those of x86) on aarch64.

anth1y commented 3 years ago

@andreeaflorescu thank you for getting back to me I'll take a look at this tonight. pardon my ignorance but what exactly is meant by "negative tests"?

andreeaflorescu commented 3 years ago

Here we were referring to having similar negative tests as the existing one on x86_64. The test is called test_faulty_vcpu_fd and it is linked in the issue description.

That test is a "negative test" because it is using invalid FDs to check the return value of various ioctls.

        let faulty_vcpu_fd = VcpuFd {
            vcpu: unsafe { File::from_raw_fd(-1) },
            kvm_run_ptr: KvmRunWrapper {
                kvm_run_ptr: mmap_anonymous(10),
                mmap_size: 10,
            },
        };

        assert_eq!(faulty_vcpu_fd.get_regs().unwrap_err().errno(), badf_errno);

So we should create faulty vCPU, KVM, Device, and VM file descriptors (as you can see in the previous example), and run the appropriate ioctls on both x86_64 and aarch64. Does that make sense?

anth1y commented 3 years ago

https://www.youtube.com/watch?v=vhu3NTOHz-M I gotcha thank you sooo much