diff options
author | Dylan Reid <dgreid@chromium.org> | 2017-05-01 18:22:11 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-05-02 05:20:27 -0700 |
commit | 303f86fa21dd2ac21076da29dbc8957516724781 (patch) | |
tree | 289c7d76d6be19369cbe2b922d6ea9397b5f7611 /kvm_sys/tests | |
parent | bf86e0fc86d7bf8b11804a2e89c174798259beee (diff) | |
download | crosvm-303f86fa21dd2ac21076da29dbc8957516724781.tar crosvm-303f86fa21dd2ac21076da29dbc8957516724781.tar.gz crosvm-303f86fa21dd2ac21076da29dbc8957516724781.tar.bz2 crosvm-303f86fa21dd2ac21076da29dbc8957516724781.tar.lz crosvm-303f86fa21dd2ac21076da29dbc8957516724781.tar.xz crosvm-303f86fa21dd2ac21076da29dbc8957516724781.tar.zst crosvm-303f86fa21dd2ac21076da29dbc8957516724781.zip |
kvm-sys: rename to kvm_sys
underscores are better Change-Id: Ida36de419f6ecf704f40d868cf7296d4d4fc41e6 Reviewed-on: https://chromium-review.googlesource.com/492666 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'kvm_sys/tests')
-rw-r--r-- | kvm_sys/tests/sanity.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/kvm_sys/tests/sanity.rs b/kvm_sys/tests/sanity.rs new file mode 100644 index 0000000..f9d0144 --- /dev/null +++ b/kvm_sys/tests/sanity.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +extern crate kvm_sys; +extern crate libc; + +use libc::{ioctl, open, c_char, O_RDWR}; + +use kvm_sys::*; + +const KVM_PATH: &'static str = "/dev/kvm\0"; + +#[test] +fn get_version() { + let sys_fd = unsafe { open(KVM_PATH.as_ptr() as *const c_char, O_RDWR) }; + assert!(sys_fd >= 0); + + let ret = unsafe { ioctl(sys_fd, KVM_GET_API_VERSION(), 0) }; + assert_eq!(ret as u32, KVM_API_VERSION); +} + +#[test] +fn create_vm_fd() { + let sys_fd = unsafe { open(KVM_PATH.as_ptr() as *const c_char, O_RDWR) }; + assert!(sys_fd >= 0); + + let vm_fd = unsafe { ioctl(sys_fd, KVM_CREATE_VM(), 0) }; + assert!(vm_fd >= 0); +} + +#[test] +fn check_vm_extension() { + let sys_fd = unsafe { open(KVM_PATH.as_ptr() as *const c_char, O_RDWR) }; + assert!(sys_fd >= 0); + + let has_user_memory = unsafe { ioctl(sys_fd, KVM_CHECK_EXTENSION(), KVM_CAP_USER_MEMORY) }; + assert_eq!(has_user_memory, 1); +} |