1
0
mirror of https://github.com/cloud-hypervisor/cloud-hypervisor.git synced 2025-03-20 07:58:55 +00:00

ci: Pass target triple to the test scripts

We pass it to the integration and unit tests script through --libc.
Cargo tests are left unmodified.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2020-04-21 08:02:58 +02:00 committed by Rob Bradford
parent 33b0e15804
commit ce794f7858
3 changed files with 28 additions and 16 deletions

View File

@ -3,6 +3,8 @@ set -x
source $HOME/.cargo/env source $HOME/.cargo/env
export BUILD_TARGET=${BUILD_TARGET-x86_64-unknown-linux-gnu}
WORKLOADS_DIR="$HOME/workloads" WORKLOADS_DIR="$HOME/workloads"
mkdir -p "$WORKLOADS_DIR" mkdir -p "$WORKLOADS_DIR"
@ -208,13 +210,13 @@ sudo ip tuntap add name vunet-tap0 mode tap
# Create tap interface with multipe queues support for vhost_user_net test. # Create tap interface with multipe queues support for vhost_user_net test.
sudo ip tuntap add name vunet-tap1 mode tap multi_queue sudo ip tuntap add name vunet-tap1 mode tap multi_queue
cargo build --release cargo build --release --target $BUILD_TARGET
sudo setcap cap_net_admin+ep target/release/cloud-hypervisor sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/cloud-hypervisor
sudo setcap cap_net_admin+ep target/release/vhost_user_net sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/vhost_user_net
# We always copy a fresh version of our binary for our L2 guest. # We always copy a fresh version of our binary for our L2 guest.
cp target/release/cloud-hypervisor $VFIO_DIR cp target/$BUILD_TARGET/release/cloud-hypervisor $VFIO_DIR
cp target/release/ch-remote $VFIO_DIR cp target/$BUILD_TARGET/release/ch-remote $VFIO_DIR
# Enable KSM with some reasonable parameters so that it won't take too long # Enable KSM with some reasonable parameters so that it won't take too long
# for the memory to be merged between two processes. # for the memory to be merged between two processes.
@ -239,8 +241,8 @@ RES=$?
if [ $RES -eq 0 ]; then if [ $RES -eq 0 ]; then
# virtio-mmio based testing # virtio-mmio based testing
cargo build --release --no-default-features --features "mmio" cargo build --release --target $BUILD_TARGET --no-default-features --features "mmio"
sudo setcap cap_net_admin+ep target/release/cloud-hypervisor sudo setcap cap_net_admin+ep target/$BUILD_TARGET/release/cloud-hypervisor
# Ensure test binary has the same caps as the cloud-hypervisor one # Ensure test binary has the same caps as the cloud-hypervisor one
time cargo test --no-run --features "integration_tests,mmio" -- --nocapture || exit 1 time cargo test --no-run --features "integration_tests,mmio" -- --nocapture || exit 1

View File

@ -2,13 +2,15 @@
source $HOME/.cargo/env source $HOME/.cargo/env
cargo test --workspace --no-run BUILD_TARGET=${BUILD_TARGET-x86_64-unknown-linux-gnu}
pushd target/debug
cargo test --target $BUILD_TARGET --workspace --no-run
pushd target/$BUILD_TARGET/debug
ls | grep net_util | grep -v "\.d" | xargs -n 1 sudo setcap cap_net_admin,cap_net_raw+ep ls | grep net_util | grep -v "\.d" | xargs -n 1 sudo setcap cap_net_admin,cap_net_raw+ep
popd popd
sudo adduser $USER kvm sudo adduser $USER kvm
newgrp kvm << EOF || exit 1 newgrp kvm << EOF || exit 1
export RUST_BACKTRACE=1 export RUST_BACKTRACE=1
cargo test --workspace "$@" || exit 1; cargo test --target $BUILD_TARGET --workspace "$@" || exit 1;
EOF EOF

View File

@ -18,6 +18,7 @@ extern crate lazy_static;
mod tests { mod tests {
#![allow(dead_code)] #![allow(dead_code)]
use ssh2::Session; use ssh2::Session;
use std::env;
use std::ffi::OsStr; use std::ffi::OsStr;
use std::fs; use std::fs;
use std::io; use std::io;
@ -130,6 +131,13 @@ mod tests {
Err(io::Error::last_os_error()) Err(io::Error::last_os_error())
} }
fn clh_command(cmd: &str) -> String {
env::var("BUILD_TARGET").map_or(
format!("target/x86_64-unknown-linux-gnu/release/{}", cmd),
|target| format!("target/{}/release/{}", target, cmd),
)
}
impl DiskConfig for ClearDiskConfig { impl DiskConfig for ClearDiskConfig {
fn prepare_cloudinit(&self, tmp_dir: &TempDir, network: &GuestNetworkConfig) -> String { fn prepare_cloudinit(&self, tmp_dir: &TempDir, network: &GuestNetworkConfig) -> String {
let cloudinit_file_path = let cloudinit_file_path =
@ -358,7 +366,7 @@ mod tests {
String::from(tmp_dir.path().join("virtiofs.sock").to_str().unwrap()); String::from(tmp_dir.path().join("virtiofs.sock").to_str().unwrap());
// Start the daemon // Start the daemon
let child = Command::new("target/release/vhost_user_fs") let child = Command::new(clh_command("vhost_user_fs"))
.args(&["--shared-dir", shared_dir]) .args(&["--shared-dir", shared_dir])
.args(&["--sock", virtiofsd_socket_path.as_str()]) .args(&["--sock", virtiofsd_socket_path.as_str()])
.spawn() .spawn()
@ -386,7 +394,7 @@ mod tests {
let vubd_socket_path = String::from(tmp_dir.path().join("vub.sock").to_str().unwrap()); let vubd_socket_path = String::from(tmp_dir.path().join("vub.sock").to_str().unwrap());
// Start the daemon // Start the daemon
let child = Command::new("target/release/cloud-hypervisor") let child = Command::new(clh_command("cloud-hypervisor"))
.args(&[ .args(&[
"--block-backend", "--block-backend",
format!( format!(
@ -445,7 +453,7 @@ mod tests {
) )
}; };
let child = Command::new("target/release/cloud-hypervisor") let child = Command::new(clh_command("cloud-hypervisor"))
.args(&["--net-backend", net_params.as_str()]) .args(&["--net-backend", net_params.as_str()])
.spawn() .spawn()
.unwrap(); .unwrap();
@ -477,7 +485,7 @@ mod tests {
} }
fn remote_command(api_socket: &str, command: &str, arg: Option<&str>) -> bool { fn remote_command(api_socket: &str, command: &str, arg: Option<&str>) -> bool {
let mut cmd = Command::new("target/release/ch-remote"); let mut cmd = Command::new(clh_command("ch-remote"));
cmd.args(&[&format!("--api-socket={}", api_socket), command]); cmd.args(&[&format!("--api-socket={}", api_socket), command]);
if let Some(arg) = arg { if let Some(arg) = arg {
@ -492,7 +500,7 @@ mod tests {
desired_vcpus: Option<u8>, desired_vcpus: Option<u8>,
desired_ram: Option<usize>, desired_ram: Option<usize>,
) -> bool { ) -> bool {
let mut cmd = Command::new("target/release/ch-remote"); let mut cmd = Command::new(clh_command("ch-remote"));
cmd.args(&[&format!("--api-socket={}", api_socket), "resize"]); cmd.args(&[&format!("--api-socket={}", api_socket), "resize"]);
if let Some(desired_vcpus) = desired_vcpus { if let Some(desired_vcpus) = desired_vcpus {
@ -813,7 +821,7 @@ mod tests {
impl<'a> GuestCommand<'a> { impl<'a> GuestCommand<'a> {
fn new(guest: &'a Guest) -> Self { fn new(guest: &'a Guest) -> Self {
Self { Self {
command: Command::new("target/release/cloud-hypervisor"), command: Command::new(clh_command("cloud-hypervisor")),
guest, guest,
capture_output: false, capture_output: false,
} }