From 952e263e499689bef5436379d6420966969016b7 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 5 Nov 2024 18:11:53 +0100 Subject: [PATCH] Fix testing for s390x --- .github/workflows/checks.yaml | 3 ++- tests/quick.rs | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index c5bc50dbb..5f4a09bde 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -107,6 +107,7 @@ jobs: features: "" target: "s390x-unknown-linux-gnu" gcc: "s390x-linux-gnu-gcc" + runner: "qemu-s390x -L /usr/s390x-linux-gnu" - rust: stable os: ubuntu-latest features: "" @@ -140,7 +141,7 @@ jobs: - name: cargo build run: cargo build --target ${{matrix.target}} ${{ matrix.features }} - name: cargo nextest # reports segfaults in a helpful way - run: cargo nextest run --target ${{matrix.target}} ${{ matrix.features }} + run: RUNNER="${{ matrix.target }}" cargo nextest run --target ${{matrix.target}} ${{ matrix.features }} env: RUST_BACKTRACE: 1 CC: ${{matrix.gcc}} diff --git a/tests/quick.rs b/tests/quick.rs index 2f1528670..2c34bd4a5 100644 --- a/tests/quick.rs +++ b/tests/quick.rs @@ -1,11 +1,27 @@ +use std::env; +use std::process::{Command, Stdio}; + fn run_test(compressed: &str, expected: &[u8]) { - let output = std::process::Command::new(env!("CARGO_BIN_EXE_bzip2")) + let mut cmd; + match env::var("RUNNER") { + Ok(runner) if !runner.is_empty() => { + let mut runner_args = runner.split(' '); + cmd = Command::new(runner_args.next().unwrap()); + cmd.args(runner_args); + cmd.arg(env!("CARGO_BIN_EXE_bzip2")); + } + _ => cmd = Command::new(env!("CARGO_BIN_EXE_bzip2")), + } + let output = match cmd .arg("-d") .arg(compressed) .arg("-c") - .stdout(std::process::Stdio::piped()) + .stdout(Stdio::piped()) .output() - .unwrap(); + { + Ok(output) => output, + Err(err) => panic!("Running {cmd:?} failed with {err:?}"), + }; assert!( output.status.success(), "status: {:?} stderr: {:?}",