mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-28 12:31:04 +00:00
Merge pull request #7286 from xuejun-xj/xuejun/up-fix
dragonball/agent: Add some optimization for Makefile and bugfixes of unit tests on aarch64
This commit is contained in:
commit
b69cdb5c21
@ -26,7 +26,7 @@ export VERSION_COMMIT := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION))
|
|||||||
EXTRA_RUSTFEATURES :=
|
EXTRA_RUSTFEATURES :=
|
||||||
|
|
||||||
##VAR SECCOMP=yes|no define if agent enables seccomp feature
|
##VAR SECCOMP=yes|no define if agent enables seccomp feature
|
||||||
SECCOMP := yes
|
SECCOMP ?= yes
|
||||||
|
|
||||||
# Enable seccomp feature of rust build
|
# Enable seccomp feature of rust build
|
||||||
ifeq ($(SECCOMP),yes)
|
ifeq ($(SECCOMP),yes)
|
||||||
|
@ -1118,6 +1118,7 @@ mod tests {
|
|||||||
use std::fs::create_dir;
|
use std::fs::create_dir;
|
||||||
use std::fs::create_dir_all;
|
use std::fs::create_dir_all;
|
||||||
use std::fs::remove_dir_all;
|
use std::fs::remove_dir_all;
|
||||||
|
use std::fs::remove_file;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::os::unix::fs;
|
use std::os::unix::fs;
|
||||||
use std::os::unix::io::AsRawFd;
|
use std::os::unix::io::AsRawFd;
|
||||||
@ -1333,14 +1334,9 @@ mod tests {
|
|||||||
fn test_mknod_dev() {
|
fn test_mknod_dev() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
let tempdir = tempdir().unwrap();
|
let path = "/dev/fifo-test";
|
||||||
|
|
||||||
let olddir = unistd::getcwd().unwrap();
|
|
||||||
defer!(let _ = unistd::chdir(&olddir););
|
|
||||||
let _ = unistd::chdir(tempdir.path());
|
|
||||||
|
|
||||||
let dev = oci::LinuxDevice {
|
let dev = oci::LinuxDevice {
|
||||||
path: "/fifo".to_string(),
|
path: path.to_string(),
|
||||||
r#type: "c".to_string(),
|
r#type: "c".to_string(),
|
||||||
major: 0,
|
major: 0,
|
||||||
minor: 0,
|
minor: 0,
|
||||||
@ -1348,13 +1344,16 @@ mod tests {
|
|||||||
uid: Some(unistd::getuid().as_raw()),
|
uid: Some(unistd::getuid().as_raw()),
|
||||||
gid: Some(unistd::getgid().as_raw()),
|
gid: Some(unistd::getgid().as_raw()),
|
||||||
};
|
};
|
||||||
let path = Path::new("fifo");
|
|
||||||
|
|
||||||
let ret = mknod_dev(&dev, path);
|
let ret = mknod_dev(&dev, Path::new(path));
|
||||||
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
||||||
|
|
||||||
let ret = stat::stat(path);
|
let ret = stat::stat(path);
|
||||||
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
||||||
|
|
||||||
|
// clear test device node
|
||||||
|
let ret = remove_file(path);
|
||||||
|
assert!(ret.is_ok(), "Should pass, Got: {:?}", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -33,7 +33,7 @@ pub fn create_pci_root_bus_path() -> String {
|
|||||||
|
|
||||||
// check if there is pci bus path for acpi
|
// check if there is pci bus path for acpi
|
||||||
acpi_sysfs_dir.push_str(&acpi_root_bus_path);
|
acpi_sysfs_dir.push_str(&acpi_root_bus_path);
|
||||||
if let Ok(_) = fs::metadata(&acpi_sysfs_dir) {
|
if fs::metadata(&acpi_sysfs_dir).is_ok() {
|
||||||
return acpi_root_bus_path;
|
return acpi_root_bus_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,12 +39,15 @@ clean:
|
|||||||
|
|
||||||
test:
|
test:
|
||||||
ifdef SUPPORT_VIRTUALIZATION
|
ifdef SUPPORT_VIRTUALIZATION
|
||||||
cargo test --all-features --target $(TRIPLE) -- --nocapture
|
RUST_BACKTRACE=1 cargo test --all-features --target $(TRIPLE) -- --nocapture --test-threads=1
|
||||||
else
|
else
|
||||||
@echo "INFO: skip testing dragonball, it need virtualization support."
|
@echo "INFO: skip testing dragonball, it need virtualization support."
|
||||||
exit 0
|
exit 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
RUST_BACKTRACE=1 cargo llvm-cov --all-features --target $(TRIPLE) -- --nocapture --test-threads=1
|
||||||
|
|
||||||
endif # ifeq ($(ARCH), s390x)
|
endif # ifeq ($(ARCH), s390x)
|
||||||
|
|
||||||
.DEFAULT_GOAL := default
|
.DEFAULT_GOAL := default
|
||||||
|
@ -1240,7 +1240,11 @@ mod tests {
|
|||||||
Some(vm.vm_config().clone()),
|
Some(vm.vm_config().clone()),
|
||||||
vm.shared_info().clone(),
|
vm.shared_info().clone(),
|
||||||
);
|
);
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
let guest_addr = GuestAddress(0x200000000000);
|
let guest_addr = GuestAddress(0x200000000000);
|
||||||
|
// TODO: #7290 - https://github.com/kata-containers/kata-containers/issues/7290
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
let guest_addr = GuestAddress(0xF800000000);
|
||||||
|
|
||||||
let cache_len = 1024 * 1024 * 1024;
|
let cache_len = 1024 * 1024 * 1024;
|
||||||
let mmap_region = MmapRegion::build(
|
let mmap_region = MmapRegion::build(
|
||||||
|
@ -873,6 +873,8 @@ impl Vm {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod tests {
|
pub mod tests {
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
use dbs_boot::layout::GUEST_MEM_START;
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
use kvm_ioctls::VcpuExit;
|
use kvm_ioctls::VcpuExit;
|
||||||
use linux_loader::cmdline::Cmdline;
|
use linux_loader::cmdline::Cmdline;
|
||||||
@ -936,7 +938,13 @@ pub mod tests {
|
|||||||
let vm_memory = vm.address_space.vm_memory().unwrap();
|
let vm_memory = vm.address_space.vm_memory().unwrap();
|
||||||
|
|
||||||
assert_eq!(vm_memory.num_regions(), 1);
|
assert_eq!(vm_memory.num_regions(), 1);
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
assert_eq!(vm_memory.last_addr(), GuestAddress(0xffffff));
|
assert_eq!(vm_memory.last_addr(), GuestAddress(0xffffff));
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
assert_eq!(
|
||||||
|
vm_memory.last_addr(),
|
||||||
|
GuestAddress(GUEST_MEM_START + 0xffffff)
|
||||||
|
);
|
||||||
|
|
||||||
// Reconfigure an already configured vm will be ignored and just return OK.
|
// Reconfigure an already configured vm will be ignored and just return OK.
|
||||||
let vm_config = VmConfigInfo {
|
let vm_config = VmConfigInfo {
|
||||||
@ -959,9 +967,18 @@ pub mod tests {
|
|||||||
assert!(vm.init_guest_memory().is_ok());
|
assert!(vm.init_guest_memory().is_ok());
|
||||||
let vm_memory = vm.address_space.vm_memory().unwrap();
|
let vm_memory = vm.address_space.vm_memory().unwrap();
|
||||||
assert_eq!(vm_memory.num_regions(), 1);
|
assert_eq!(vm_memory.num_regions(), 1);
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
assert_eq!(vm_memory.last_addr(), GuestAddress(0xffffff));
|
assert_eq!(vm_memory.last_addr(), GuestAddress(0xffffff));
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
assert_eq!(
|
||||||
|
vm_memory.last_addr(),
|
||||||
|
GuestAddress(GUEST_MEM_START + 0xffffff)
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
let obj_addr = GuestAddress(0xf0);
|
let obj_addr = GuestAddress(0xf0);
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
let obj_addr = GuestAddress(GUEST_MEM_START + 0xf0);
|
||||||
vm_memory.write_obj(67u8, obj_addr).unwrap();
|
vm_memory.write_obj(67u8, obj_addr).unwrap();
|
||||||
let read_val: u8 = vm_memory.read_obj(obj_addr).unwrap();
|
let read_val: u8 = vm_memory.read_obj(obj_addr).unwrap();
|
||||||
assert_eq!(read_val, 67u8);
|
assert_eq!(read_val, 67u8);
|
||||||
@ -1001,7 +1018,13 @@ pub mod tests {
|
|||||||
|
|
||||||
let vm_memory = vm.address_space.vm_memory().unwrap();
|
let vm_memory = vm.address_space.vm_memory().unwrap();
|
||||||
assert_eq!(vm_memory.num_regions(), 1);
|
assert_eq!(vm_memory.num_regions(), 1);
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
assert_eq!(vm_memory.last_addr(), GuestAddress(0xffffff));
|
assert_eq!(vm_memory.last_addr(), GuestAddress(0xffffff));
|
||||||
|
#[cfg(target_arch = "aarch64")]
|
||||||
|
assert_eq!(
|
||||||
|
vm_memory.last_addr(),
|
||||||
|
GuestAddress(GUEST_MEM_START + 0xffffff)
|
||||||
|
);
|
||||||
|
|
||||||
let kernel_file = TempFile::new().unwrap();
|
let kernel_file = TempFile::new().unwrap();
|
||||||
let cmd_line = Cmdline::new(64);
|
let cmd_line = Cmdline::new(64);
|
||||||
|
2
utils.mk
2
utils.mk
@ -130,7 +130,7 @@ endef
|
|||||||
|
|
||||||
|
|
||||||
##VAR BUILD_TYPE=release|debug type of rust build
|
##VAR BUILD_TYPE=release|debug type of rust build
|
||||||
BUILD_TYPE = release
|
BUILD_TYPE ?= release
|
||||||
|
|
||||||
##VAR ARCH=arch target to build (format: uname -m)
|
##VAR ARCH=arch target to build (format: uname -m)
|
||||||
HOST_ARCH = $(shell uname -m)
|
HOST_ARCH = $(shell uname -m)
|
||||||
|
Loading…
Reference in New Issue
Block a user