use qemu when running tests for arm32

This commit is contained in:
Mohamed Daahir 2025-02-16 16:28:28 +00:00
parent 5c6c65ccaa
commit e9717139a0
2 changed files with 27 additions and 34 deletions

View File

@ -64,20 +64,14 @@ jobs:
sudo apt-get -y install libc6:armhf libstdc++6:armhf qemu-user
echo CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc >> $GITHUB_ENV
echo CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm >> $GITHUB_ENV
fi
sudo apt-get -y install ${{ matrix.job.compiler-tools }}
- run: cargo test --target=arm-unknown-linux-gnueabihf --no-run
- run: qemu-arm -strace -L /lib/arm-linux-gnueabihf ./target/arm-unknown-linux-gnueabihf/debug/deps/xh-* --nocapture --test-threads=1 --test can_parse_old_httpie_session
env:
RUST_BACKTRACE: 1
# - uses: ClementTsang/cargo-action@v0.0.6
# with:
# command: test
# args: --target ${{ matrix.job.target }} ${{ matrix.job.flags }} can_parse_old_httpie_session -- --nocapture
# env:
# RUST_BACKTRACE: 1
- uses: ClementTsang/cargo-action@v0.0.6
with:
command: test
args: --target ${{ matrix.job.target }} ${{ matrix.job.flags }}
fmt-and-clippy:
name: Rustfmt and clippy

View File

@ -61,33 +61,32 @@ fn random_string() -> String {
.collect()
}
// Cargo-cross for ARM runs tests using qemu.
//
// It sets an environment variable like this:
// CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm
// fn find_runner() -> Option<String> {
// for (key, value) in std::env::vars() {
// if key.starts_with("CARGO_TARGET_") && key.ends_with("_RUNNER") && !value.is_empty() {
// return Some(value);
// }
// }
// None
// }
/// Cargo-cross for ARM runs tests using qemu.
///
/// It sets an environment variable like this:
/// CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm
fn find_runner() -> Option<String> {
for (key, value) in std::env::vars() {
if key.starts_with("CARGO_TARGET_") && key.ends_with("_RUNNER") && !value.is_empty() {
return Some(value);
}
}
None
}
fn get_base_command() -> Command {
let mut cmd;
let path = assert_cmd::cargo::cargo_bin("xh");
// if let Some(runner) = find_runner() {
// let mut runner = runner.split_whitespace();
// cmd = Command::new(runner.next().unwrap());
// for arg in runner {
// cmd.arg(arg);
// }
// cmd.arg(path);
// } else {
// cmd = Command::new(path);
// }
cmd = Command::new(path);
if let Some(runner) = find_runner() {
let mut runner = runner.split_whitespace();
cmd = Command::new(runner.next().unwrap());
for arg in runner {
cmd.arg(arg);
}
cmd.arg(path);
} else {
cmd = Command::new(path);
}
cmd.env("HOME", "");
cmd.env("NETRC", "");
cmd.env("XH_CONFIG_DIR", "");