mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 10:32:10 +00:00
BUG=b/210015827 TEST=./tools/run_tests --target vm:aarch64 --arch armhf Change-Id: I4b1968d85969e6094ed393bb4f83c67328591cce Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340226 Reviewed-by: Anton Romanov <romanton@google.com> Auto-Submit: Anton Romanov <romanton@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dennis Kempin <denniskempin@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
38 lines
1 KiB
Rust
38 lines
1 KiB
Rust
// 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.
|
|
|
|
#![cfg(not(target_arch = "arm"))]
|
|
|
|
use libc::{c_char, ioctl, open, 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);
|
|
}
|