kata-ctl: Limit running tests to x86 and use native-tls on s390x

For s390x, use native-tls for reqwest because the rustls-tls/ring
dependency is not available for s390x.

Also exclude s390x, powerpc64le, and aarch64 from running the cpu
check due to the lack of the arch-specific implementation. In this
case, rust complains about unused functions in src/check.rs (both
normal and test context).

Fixes: #5438

Co-authored-by: James O. D. Hunt <james.o.hunt@intel.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.ibm.com>
This commit is contained in:
Hendrik Brueckner 2022-10-18 11:10:56 +00:00
parent 9f2c7e47c9
commit 871d2cf2c0
2 changed files with 17 additions and 3 deletions

View File

@ -3,6 +3,9 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
[workspace]
resolver = "2"
[package] [package]
name = "kata-ctl" name = "kata-ctl"
version = "0.0.1" version = "0.0.1"
@ -12,9 +15,14 @@ edition = "2018"
[dependencies] [dependencies]
anyhow = "1.0.31" anyhow = "1.0.31"
clap = { version = "3.2.20", features = ["derive", "cargo"] } clap = { version = "3.2.20", features = ["derive", "cargo"] }
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }
serde_json = "1.0.85" serde_json = "1.0.85"
thiserror = "1.0.35" thiserror = "1.0.35"
[target.'cfg(target_arch = "s390x")'.dependencies]
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "native-tls"] }
[target.'cfg(not(target_arch = "s390x"))'.dependencies]
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }
[dev-dependencies] [dev-dependencies]
semver = "1.0.12" semver = "1.0.12"

View File

@ -9,18 +9,19 @@ use anyhow::{anyhow, Result};
use reqwest::header::{CONTENT_TYPE, USER_AGENT}; use reqwest::header::{CONTENT_TYPE, USER_AGENT};
use serde_json::Value; use serde_json::Value;
use std::collections::HashMap; use std::collections::HashMap;
use std::fs;
const KATA_GITHUB_URL: &str = const KATA_GITHUB_URL: &str =
"https://api.github.com/repos/kata-containers/kata-containers/releases/latest"; "https://api.github.com/repos/kata-containers/kata-containers/releases/latest";
#[cfg(any(target_arch = "x86_64"))]
fn get_cpu_info(cpu_info_file: &str) -> Result<String> { fn get_cpu_info(cpu_info_file: &str) -> Result<String> {
let contents = fs::read_to_string(cpu_info_file)?; let contents = std::fs::read_to_string(cpu_info_file)?;
Ok(contents) Ok(contents)
} }
// get_single_cpu_info returns the contents of the first cpu from // get_single_cpu_info returns the contents of the first cpu from
// the specified cpuinfo file by parsing based on a specified delimiter // the specified cpuinfo file by parsing based on a specified delimiter
#[cfg(any(target_arch = "x86_64"))]
pub fn get_single_cpu_info(cpu_info_file: &str, substring: &str) -> Result<String> { pub fn get_single_cpu_info(cpu_info_file: &str, substring: &str) -> Result<String> {
let contents = get_cpu_info(cpu_info_file)?; let contents = get_cpu_info(cpu_info_file)?;
@ -40,6 +41,7 @@ pub fn get_single_cpu_info(cpu_info_file: &str, substring: &str) -> Result<Strin
// get_cpu_flags returns a string of cpu flags from cpuinfo, passed in // get_cpu_flags returns a string of cpu flags from cpuinfo, passed in
// as a string // as a string
#[cfg(any(target_arch = "x86_64"))]
pub fn get_cpu_flags(cpu_info: &str, cpu_flags_tag: &str) -> Result<String> { pub fn get_cpu_flags(cpu_info: &str, cpu_flags_tag: &str) -> Result<String> {
if cpu_info.is_empty() { if cpu_info.is_empty() {
return Err(anyhow!("cpu_info string is empty"))?; return Err(anyhow!("cpu_info string is empty"))?;
@ -63,6 +65,7 @@ pub fn get_cpu_flags(cpu_info: &str, cpu_flags_tag: &str) -> Result<String> {
// get_missing_strings searches for required (strings) in data and returns // get_missing_strings searches for required (strings) in data and returns
// a vector containing the missing strings // a vector containing the missing strings
#[cfg(any(target_arch = "x86_64"))]
fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result<Vec<String>> { fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result<Vec<String>> {
let mut missing: Vec<String> = Vec::new(); let mut missing: Vec<String> = Vec::new();
@ -75,6 +78,7 @@ fn get_missing_strings(data: &str, required: &'static [&'static str]) -> Result<
Ok(missing) Ok(missing)
} }
#[cfg(any(target_arch = "x86_64"))]
pub fn check_cpu_flags( pub fn check_cpu_flags(
retrieved_flags: &str, retrieved_flags: &str,
required_flags: &'static [&'static str], required_flags: &'static [&'static str],
@ -84,6 +88,7 @@ pub fn check_cpu_flags(
Ok(missing_flags) Ok(missing_flags)
} }
#[cfg(any(target_arch = "x86_64"))]
pub fn check_cpu_attribs( pub fn check_cpu_attribs(
cpu_info: &str, cpu_info: &str,
required_attribs: &'static [&'static str], required_attribs: &'static [&'static str],
@ -139,6 +144,7 @@ pub fn check_version() -> Result<()> {
Ok(()) Ok(())
} }
#[cfg(any(target_arch = "x86_64"))]
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;