kata-ctl: add unit test for kvm check

Check that kvm test fails when run as non-root and when device specified
is not /dev/kvm.

Fixes #5338

Signed-off-by: Chelsea Mafrica <chelsea.e.mafrica@intel.com>
This commit is contained in:
Chelsea Mafrica 2023-02-27 12:55:17 -08:00
parent a085a6d7b4
commit 5f8008b69c

View File

@ -395,6 +395,7 @@ mod tests {
use std::fs; use std::fs;
use std::io::Write; use std::io::Write;
use tempfile::tempdir; use tempfile::tempdir;
use test_utils::skip_if_root;
#[test] #[test]
fn test_get_single_cpu_info() { fn test_get_single_cpu_info() {
@ -522,6 +523,16 @@ mod tests {
} }
} }
#[test]
fn test_check_kvm_is_usable_generic() {
skip_if_root!();
#[allow(dead_code)]
let result = check_kvm_is_usable_generic();
assert!(
result.err().unwrap().to_string() == "Will not perform kvm checks as non root user"
);
}
#[test] #[test]
fn test_get_kata_all_releases_by_url() { fn test_get_kata_all_releases_by_url() {
#[derive(Debug)] #[derive(Debug)]