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:
Zhongtao Hu 2023-07-13 09:39:23 +08:00 committed by GitHub
commit b69cdb5c21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 42 additions and 13 deletions

View File

@ -26,7 +26,7 @@ export VERSION_COMMIT := $(if $(COMMIT),$(VERSION)-$(COMMIT),$(VERSION))
EXTRA_RUSTFEATURES :=
##VAR SECCOMP=yes|no define if agent enables seccomp feature
SECCOMP := yes
SECCOMP ?= yes
# Enable seccomp feature of rust build
ifeq ($(SECCOMP),yes)

View File

@ -1118,6 +1118,7 @@ mod tests {
use std::fs::create_dir;
use std::fs::create_dir_all;
use std::fs::remove_dir_all;
use std::fs::remove_file;
use std::io;
use std::os::unix::fs;
use std::os::unix::io::AsRawFd;
@ -1333,14 +1334,9 @@ mod tests {
fn test_mknod_dev() {
skip_if_not_root!();
let tempdir = tempdir().unwrap();
let olddir = unistd::getcwd().unwrap();
defer!(let _ = unistd::chdir(&olddir););
let _ = unistd::chdir(tempdir.path());
let path = "/dev/fifo-test";
let dev = oci::LinuxDevice {
path: "/fifo".to_string(),
path: path.to_string(),
r#type: "c".to_string(),
major: 0,
minor: 0,
@ -1348,13 +1344,16 @@ mod tests {
uid: Some(unistd::getuid().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);
let ret = stat::stat(path);
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]

View File

@ -33,7 +33,7 @@ pub fn create_pci_root_bus_path() -> String {
// check if there is pci bus path for acpi
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;
}

View File

@ -39,12 +39,15 @@ clean:
test:
ifdef SUPPORT_VIRTUALIZATION
cargo test --all-features --target $(TRIPLE) -- --nocapture
RUST_BACKTRACE=1 cargo test --all-features --target $(TRIPLE) -- --nocapture --test-threads=1
else
@echo "INFO: skip testing dragonball, it need virtualization support."
exit 0
endif
coverage:
RUST_BACKTRACE=1 cargo llvm-cov --all-features --target $(TRIPLE) -- --nocapture --test-threads=1
endif # ifeq ($(ARCH), s390x)
.DEFAULT_GOAL := default

View File

@ -1240,7 +1240,11 @@ mod tests {
Some(vm.vm_config().clone()),
vm.shared_info().clone(),
);
#[cfg(target_arch = "x86_64")]
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 mmap_region = MmapRegion::build(

View File

@ -873,6 +873,8 @@ impl Vm {
#[cfg(test)]
pub mod tests {
#[cfg(target_arch = "aarch64")]
use dbs_boot::layout::GUEST_MEM_START;
#[cfg(target_arch = "x86_64")]
use kvm_ioctls::VcpuExit;
use linux_loader::cmdline::Cmdline;
@ -936,7 +938,13 @@ pub mod tests {
let vm_memory = vm.address_space.vm_memory().unwrap();
assert_eq!(vm_memory.num_regions(), 1);
#[cfg(target_arch = "x86_64")]
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.
let vm_config = VmConfigInfo {
@ -959,9 +967,18 @@ pub mod tests {
assert!(vm.init_guest_memory().is_ok());
let vm_memory = vm.address_space.vm_memory().unwrap();
assert_eq!(vm_memory.num_regions(), 1);
#[cfg(target_arch = "x86_64")]
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);
#[cfg(target_arch = "aarch64")]
let obj_addr = GuestAddress(GUEST_MEM_START + 0xf0);
vm_memory.write_obj(67u8, obj_addr).unwrap();
let read_val: u8 = vm_memory.read_obj(obj_addr).unwrap();
assert_eq!(read_val, 67u8);
@ -1001,7 +1018,13 @@ pub mod tests {
let vm_memory = vm.address_space.vm_memory().unwrap();
assert_eq!(vm_memory.num_regions(), 1);
#[cfg(target_arch = "x86_64")]
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 cmd_line = Cmdline::new(64);

View File

@ -130,7 +130,7 @@ endef
##VAR BUILD_TYPE=release|debug type of rust build
BUILD_TYPE = release
BUILD_TYPE ?= release
##VAR ARCH=arch target to build (format: uname -m)
HOST_ARCH = $(shell uname -m)