mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-01 15:57:20 +00:00
Merge pull request #8485 from BbolroC/add-unit-test-s390x
GHA: Enable static check for s390x, aarch64 and ppc64le
This commit is contained in:
commit
b7d6b18768
14
.github/workflows/static-checks.yaml
vendored
14
.github/workflows/static-checks.yaml
vendored
@ -35,7 +35,6 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
build-checks:
|
build-checks:
|
||||||
runs-on: ubuntu-20.04
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@ -78,7 +77,20 @@ jobs:
|
|||||||
install-libseccomp: yes
|
install-libseccomp: yes
|
||||||
- component: genpolicy
|
- component: genpolicy
|
||||||
component-path: src/tools/genpolicy
|
component-path: src/tools/genpolicy
|
||||||
|
instance:
|
||||||
|
- "ubuntu-20.04"
|
||||||
|
- "arm-no-k8s"
|
||||||
|
- "s390x"
|
||||||
|
- "ppc64le"
|
||||||
|
runs-on: ${{ matrix.instance }}
|
||||||
steps:
|
steps:
|
||||||
|
- name: Adjust a permission for repo
|
||||||
|
run: |
|
||||||
|
sudo chown -R $USER:$USER $GITHUB_WORKSPACE $HOME
|
||||||
|
sudo rm -rf $GITHUB_WORKSPACE/*
|
||||||
|
sudo rm -f /tmp/kata_hybrid* # Sometime we got leftover from test_setup_hvsock_failed()
|
||||||
|
if: ${{ matrix.instance != 'ubuntu-20.04' }}
|
||||||
|
|
||||||
- name: Checkout the code
|
- name: Checkout the code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
@ -17,6 +17,7 @@ die() {
|
|||||||
function install_yq() {
|
function install_yq() {
|
||||||
local yq_pkg="github.com/mikefarah/yq"
|
local yq_pkg="github.com/mikefarah/yq"
|
||||||
local yq_version=3.4.1
|
local yq_version=3.4.1
|
||||||
|
local precmd=""
|
||||||
INSTALL_IN_GOPATH=${INSTALL_IN_GOPATH:-true}
|
INSTALL_IN_GOPATH=${INSTALL_IN_GOPATH:-true}
|
||||||
|
|
||||||
if [ "${INSTALL_IN_GOPATH}" == "true" ];then
|
if [ "${INSTALL_IN_GOPATH}" == "true" ];then
|
||||||
@ -25,6 +26,15 @@ function install_yq() {
|
|||||||
local yq_path="${GOPATH}/bin/yq"
|
local yq_path="${GOPATH}/bin/yq"
|
||||||
else
|
else
|
||||||
yq_path="/usr/local/bin/yq"
|
yq_path="/usr/local/bin/yq"
|
||||||
|
# Check if we need sudo to install yq
|
||||||
|
if [ ! -w "/usr/local/bin" ]; then
|
||||||
|
# Check if we have sudo privileges
|
||||||
|
if ! sudo -n true 2>/dev/null; then
|
||||||
|
die "Please provide sudo privileges to install yq"
|
||||||
|
else
|
||||||
|
precmd="sudo"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
[ -x "${yq_path}" ] && [ "`${yq_path} --version`"X == "yq version ${yq_version}"X ] && return
|
[ -x "${yq_path}" ] && [ "`${yq_path} --version`"X == "yq version ${yq_version}"X ] && return
|
||||||
|
|
||||||
@ -75,9 +85,9 @@ function install_yq() {
|
|||||||
|
|
||||||
## NOTE: ${var,,} => gives lowercase value of var
|
## NOTE: ${var,,} => gives lowercase value of var
|
||||||
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos}_${goarch}"
|
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos}_${goarch}"
|
||||||
curl -o "${yq_path}" -LSsf "${yq_url}"
|
${precmd} curl -o "${yq_path}" -LSsf "${yq_url}"
|
||||||
[ $? -ne 0 ] && die "Download ${yq_url} failed"
|
[ $? -ne 0 ] && die "Download ${yq_url} failed"
|
||||||
chmod +x "${yq_path}"
|
${precmd} chmod +x "${yq_path}"
|
||||||
|
|
||||||
if ! command -v "${yq_path}" >/dev/null; then
|
if ! command -v "${yq_path}" >/dev/null; then
|
||||||
die "Cannot not get ${yq_path} executable"
|
die "Cannot not get ${yq_path} executable"
|
||||||
|
@ -1400,6 +1400,20 @@ mod tests {
|
|||||||
fn test_new_fs_manager() {
|
fn test_new_fs_manager() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
|
let output = Command::new("stat")
|
||||||
|
.arg("-f")
|
||||||
|
.arg("-c")
|
||||||
|
.arg("%T")
|
||||||
|
.arg("/sys/fs/cgroup/")
|
||||||
|
.output()
|
||||||
|
.unwrap();
|
||||||
|
let output_str = String::from_utf8(output.stdout).unwrap();
|
||||||
|
let cgroup_version = output_str.strip_suffix("\n").unwrap();
|
||||||
|
if cgroup_version.eq("cgroup2fs") {
|
||||||
|
println!("INFO: Skipping the test as cgroups v2 is used by default");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct TestCase {
|
struct TestCase {
|
||||||
cpath: Vec<String>,
|
cpath: Vec<String>,
|
||||||
devices: Vec<Vec<LinuxDeviceCgroup>>,
|
devices: Vec<Vec<LinuxDeviceCgroup>>,
|
||||||
|
@ -1563,7 +1563,7 @@ mod tests {
|
|||||||
|
|
||||||
// Valid path
|
// Valid path
|
||||||
let device = ccw::Device::from_str(relpath).unwrap();
|
let device = ccw::Device::from_str(relpath).unwrap();
|
||||||
let matcher = VirtioBlkCCWMatcher::new(&root_bus, &device);
|
let matcher = VirtioBlkCCWMatcher::new(root_bus, &device);
|
||||||
assert!(matcher.is_match(&uev));
|
assert!(matcher.is_match(&uev));
|
||||||
|
|
||||||
// Invalid paths
|
// Invalid paths
|
||||||
@ -1794,12 +1794,7 @@ mod tests {
|
|||||||
assert!(!matcher.is_match(&uev_remove));
|
assert!(!matcher.is_match(&uev_remove));
|
||||||
|
|
||||||
let mut uev_other_device = uev.clone();
|
let mut uev_other_device = uev.clone();
|
||||||
uev_other_device.devpath = format!(
|
uev_other_device.devpath = format!("{}/card{}/{}.0002", AP_ROOT_BUS_PATH, card, card);
|
||||||
"{}/card{}/{}",
|
|
||||||
AP_ROOT_BUS_PATH,
|
|
||||||
card,
|
|
||||||
format!("{}.0002", card)
|
|
||||||
);
|
|
||||||
assert!(!matcher.is_match(&uev_other_device));
|
assert!(!matcher.is_match(&uev_other_device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,9 @@ impl Handle {
|
|||||||
route.device = self.find_link(LinkFilter::Index(index)).await?.name();
|
route.device = self.find_link(LinkFilter::Index(index)).await?.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
result.push(route);
|
if !route.dest.is_empty() {
|
||||||
|
result.push(route);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
@ -12,7 +12,13 @@ use std::os::unix::io::{AsRawFd, FromRawFd};
|
|||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
|
||||||
pub const RNGDEV: &str = "/dev/random";
|
pub const RNGDEV: &str = "/dev/random";
|
||||||
|
#[cfg(target_arch = "powerpc64")]
|
||||||
|
pub const RNDADDTOENTCNT: libc::c_uint = 0x80045201;
|
||||||
|
#[cfg(target_arch = "powerpc64")]
|
||||||
|
pub const RNDRESEEDCRNG: libc::c_int = 0x20005207;
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
pub const RNDADDTOENTCNT: libc::c_int = 0x40045201;
|
pub const RNDADDTOENTCNT: libc::c_int = 0x40045201;
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
pub const RNDRESEEDCRNG: libc::c_int = 0x5207;
|
pub const RNDRESEEDCRNG: libc::c_int = 0x5207;
|
||||||
|
|
||||||
// Handle the differing ioctl(2) request types for different targets
|
// Handle the differing ioctl(2) request types for different targets
|
||||||
|
@ -1963,6 +1963,7 @@ fn load_kernel_module(module: &protocols::agent::KernelModule) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(dead_code)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
@ -2154,6 +2155,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn test_do_write_stream() {
|
async fn test_do_write_stream() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
@ -2694,8 +2696,16 @@ OtherField:other
|
|||||||
fs::write(mount_dir.path().join("file.dat"), "foobar").unwrap();
|
fs::write(mount_dir.path().join("file.dat"), "foobar").unwrap();
|
||||||
stats = get_volume_capacity_stats(mount_dir.path().to_str().unwrap()).unwrap();
|
stats = get_volume_capacity_stats(mount_dir.path().to_str().unwrap()).unwrap();
|
||||||
|
|
||||||
assert_eq!(stats.used, 4 * 1024);
|
let size = get_block_size(mount_dir.path().to_str().unwrap()).unwrap();
|
||||||
assert_eq!(stats.available, available - 4 * 1024);
|
|
||||||
|
assert_eq!(stats.used, size);
|
||||||
|
assert_eq!(stats.available, available - size);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_block_size(path: &str) -> Result<u64, Errno> {
|
||||||
|
let stat = statfs::statfs(path)?;
|
||||||
|
let block_size = stat.block_size() as u64;
|
||||||
|
Ok(block_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
@ -655,6 +655,8 @@ fn onlined_cpus() -> Result<i32> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[allow(unused_imports)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::mount::baremount;
|
use crate::mount::baremount;
|
||||||
@ -924,6 +926,7 @@ mod tests {
|
|||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[serial]
|
#[serial]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn add_and_get_container() {
|
async fn add_and_get_container() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
@ -989,6 +992,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn test_find_container_process() {
|
async fn test_find_container_process() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
@ -1036,6 +1040,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
#[cfg(not(target_arch = "powerpc64"))]
|
||||||
async fn test_find_process() {
|
async fn test_find_process() {
|
||||||
skip_if_not_root!();
|
skip_if_not_root!();
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ include ../../utils.mk
|
|||||||
|
|
||||||
PROJECT_DIRS := $(shell find . -name Cargo.toml -printf '%h\n' | sort -u)
|
PROJECT_DIRS := $(shell find . -name Cargo.toml -printf '%h\n' | sort -u)
|
||||||
|
|
||||||
ifeq ($(ARCH), s390x)
|
ifeq ($(ARCH), $(filter $(ARCH), s390x ppc64le))
|
||||||
default build check test clippy:
|
default build check test clippy vendor:
|
||||||
@echo "s390x not support currently"
|
@echo "$(ARCH) is not support currently"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
else
|
||||||
|
|
||||||
|
@ -25,6 +25,9 @@ use crate::{Error as VirtioError, Result as VirtioResult};
|
|||||||
|
|
||||||
enum EndpointProtocolFlags {
|
enum EndpointProtocolFlags {
|
||||||
ProtocolMq = 1,
|
ProtocolMq = 1,
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[cfg(feature = "vhost-user-blk")]
|
||||||
|
ProtocolBackend = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct Listener {
|
pub(super) struct Listener {
|
||||||
|
@ -1038,9 +1038,7 @@ impl DeviceManager {
|
|||||||
pub fn get_pci_bus_resources(&self) -> Option<PciBusResources> {
|
pub fn get_pci_bus_resources(&self) -> Option<PciBusResources> {
|
||||||
let mut vfio_dev_mgr = self.vfio_manager.lock().unwrap();
|
let mut vfio_dev_mgr = self.vfio_manager.lock().unwrap();
|
||||||
let vfio_pci_mgr = vfio_dev_mgr.get_pci_manager();
|
let vfio_pci_mgr = vfio_dev_mgr.get_pci_manager();
|
||||||
if vfio_pci_mgr.is_none() {
|
vfio_pci_mgr.as_ref()?;
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let pci_manager = vfio_pci_mgr.unwrap();
|
let pci_manager = vfio_pci_mgr.unwrap();
|
||||||
let ecam_space = pci_manager.get_ecam_space();
|
let ecam_space = pci_manager.get_ecam_space();
|
||||||
let bar_space = pci_manager.get_bar_space();
|
let bar_space = pci_manager.get_bar_space();
|
||||||
|
@ -467,8 +467,14 @@ clean-generated-files:
|
|||||||
vendor:
|
vendor:
|
||||||
@cargo vendor
|
@cargo vendor
|
||||||
|
|
||||||
|
ifeq ($(ARCH),x86_64)
|
||||||
##TARGET check: run test
|
##TARGET check: run test
|
||||||
check: $(GENERATED_FILES) standard_rust_check
|
check: $(GENERATED_FILES) standard_rust_check
|
||||||
|
else
|
||||||
|
check:
|
||||||
|
@echo "$(ARCH) is not currently supported"
|
||||||
|
exit 0
|
||||||
|
endif
|
||||||
|
|
||||||
##TARGET run: build and run agent
|
##TARGET run: build and run agent
|
||||||
run:
|
run:
|
||||||
|
@ -918,6 +918,7 @@ mod tests {
|
|||||||
|
|
||||||
use kata_types::config::hypervisor::{Hypervisor as HypervisorConfig, SecurityInfo};
|
use kata_types::config::hypervisor::{Hypervisor as HypervisorConfig, SecurityInfo};
|
||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
|
#[cfg(target_arch = "x86_64")]
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use test_utils::{assert_result, skip_if_not_root};
|
use test_utils::{assert_result, skip_if_not_root};
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import "testing"
|
|||||||
|
|
||||||
func getExpectedHostDetails(tmpdir string) (HostInfo, error) {
|
func getExpectedHostDetails(tmpdir string) (HostInfo, error) {
|
||||||
expectedVendor := ""
|
expectedVendor := ""
|
||||||
expectedModel := "POWER8"
|
expectedModel := "POWER9"
|
||||||
expectedVMContainerCapable := true
|
expectedVMContainerCapable := true
|
||||||
return genericGetExpectedHostDetails(tmpdir, expectedVendor, expectedModel, expectedVMContainerCapable)
|
return genericGetExpectedHostDetails(tmpdir, expectedVendor, expectedModel, expectedVMContainerCapable)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ include ../../../utils.mk
|
|||||||
|
|
||||||
ifeq ($(ARCH), ppc64le)
|
ifeq ($(ARCH), ppc64le)
|
||||||
override ARCH = powerpc64le
|
override ARCH = powerpc64le
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.DEFAULT_GOAL := default
|
.DEFAULT_GOAL := default
|
||||||
default: build
|
default: build
|
||||||
|
@ -32,6 +32,12 @@ GENERATED_FILES := $(GENERATED_CODE)
|
|||||||
|
|
||||||
.DEFAULT_GOAL := default
|
.DEFAULT_GOAL := default
|
||||||
|
|
||||||
|
ifeq ($(ARCH), ppc64le)
|
||||||
|
default build check test vendor:
|
||||||
|
@echo "Building kata-ctl on $(ARCH) is currently being skipped"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
|
||||||
default: $(TARGET) build
|
default: $(TARGET) build
|
||||||
|
|
||||||
$(TARGET): $(GENERATED_CODE)
|
$(TARGET): $(GENERATED_CODE)
|
||||||
@ -60,6 +66,8 @@ install:
|
|||||||
|
|
||||||
check: $(GENERATED_CODE) standard_rust_check
|
check: $(GENERATED_CODE) standard_rust_check
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
.PHONY: \
|
.PHONY: \
|
||||||
build \
|
build \
|
||||||
check \
|
check \
|
||||||
|
@ -104,11 +104,11 @@ mod arch_specific {
|
|||||||
|
|
||||||
let check_fn = if search_values.is_empty() {
|
let check_fn = if search_values.is_empty() {
|
||||||
|param: &str, search_param: &str, _search_values: &[&str]| {
|
|param: &str, search_param: &str, _search_values: &[&str]| {
|
||||||
return param.eq_ignore_ascii_case(search_param);
|
param.eq_ignore_ascii_case(search_param)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|param: &str, search_param: &str, search_values: &[&str]| {
|
|param: &str, search_param: &str, search_values: &[&str]| {
|
||||||
let split: Vec<&str> = param.splitn(2, "=").collect();
|
let split: Vec<&str> = param.splitn(2, '=').collect();
|
||||||
if split.len() < 2 || split[0] != search_param {
|
if split.len() < 2 || split[0] != search_param {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ include ../../../utils.mk
|
|||||||
|
|
||||||
ifeq ($(ARCH), ppc64le)
|
ifeq ($(ARCH), ppc64le)
|
||||||
override ARCH = powerpc64le
|
override ARCH = powerpc64le
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TARGET = runk
|
TARGET = runk
|
||||||
TARGET_PATH = target/$(TRIPLE)/$(BUILD_TYPE)/$(TARGET)
|
TARGET_PATH = target/$(TRIPLE)/$(BUILD_TYPE)/$(TARGET)
|
||||||
|
@ -95,6 +95,7 @@ mod tests {
|
|||||||
use std::fs::{create_dir, File};
|
use std::fs::{create_dir, File};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
use test_utils::skip_if_not_root;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_init_container_validate() {
|
fn test_init_container_validate() {
|
||||||
@ -113,6 +114,8 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_init_container_create_launcher() {
|
fn test_init_container_create_launcher() {
|
||||||
|
#[cfg(target_arch = "powerpc64")]
|
||||||
|
skip_if_not_root!();
|
||||||
let logger = slog::Logger::root(slog::Discard, o!());
|
let logger = slog::Logger::root(slog::Discard, o!());
|
||||||
let root_dir = tempdir().unwrap();
|
let root_dir = tempdir().unwrap();
|
||||||
let bundle_dir = tempdir().unwrap();
|
let bundle_dir = tempdir().unwrap();
|
||||||
|
@ -7,7 +7,7 @@ include ../../../utils.mk
|
|||||||
|
|
||||||
ifeq ($(ARCH), ppc64le)
|
ifeq ($(ARCH), ppc64le)
|
||||||
override ARCH = powerpc64le
|
override ARCH = powerpc64le
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.DEFAULT_GOAL := default
|
.DEFAULT_GOAL := default
|
||||||
default: build
|
default: build
|
||||||
|
Loading…
Reference in New Issue
Block a user