From 0a88cccd5188074de96f54a4b6b44a63971ac157 Mon Sep 17 00:00:00 2001 From: Sungjoon Moon Date: Thu, 18 Dec 2025 00:38:12 +0800 Subject: [PATCH] Fix compression tests in QEMU cross-compilation environments (#3248) * tests: fix cmd_exists for QEMU environments QEMU user-mode has a bug where posix_spawn returns success even when the command doesn't exist. The child exits with 127, but the parent thinks it succeeded. Change cmd_exists to check if the command actually ran successfully (exit code 0), not just if spawn returned Ok. This fixes compression tests on riscv64 and other QEMU-emulated architectures. Ref https://github.com/rust-lang/rust/issues/90825 * tests: remove riscv64 skip for compression tests Remove the cfg guards that disabled lz4, brotli, and zstd tests on riscv64. These now work with the QEMU fix. --- tests/misc.rs | 6 ------ tests/util.rs | 5 ++++- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/misc.rs b/tests/misc.rs index df79e95..aae84da 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -922,8 +922,6 @@ be, to a very large extent, the result of luck. Sherlock Holmes eqnice!(expected, cmd.stdout()); }); -// lz4 decompression tool doesn't work under RISC-V QEMU emulation in CI -#[cfg(not(target_arch = "riscv64"))] rgtest!(compressed_lz4, |dir: Dir, mut cmd: TestCommand| { if !cmd_exists("lz4") { return; @@ -954,8 +952,6 @@ be, to a very large extent, the result of luck. Sherlock Holmes eqnice!(expected, cmd.stdout()); }); -// brotli decompression tool doesn't work under RISC-V QEMU emulation in CI -#[cfg(not(target_arch = "riscv64"))] rgtest!(compressed_brotli, |dir: Dir, mut cmd: TestCommand| { if !cmd_exists("brotli") { return; @@ -971,8 +967,6 @@ be, to a very large extent, the result of luck. Sherlock Holmes eqnice!(expected, cmd.stdout()); }); -// zstd decompression tool doesn't work under RISC-V QEMU emulation in CI -#[cfg(not(target_arch = "riscv64"))] rgtest!(compressed_zstd, |dir: Dir, mut cmd: TestCommand| { if !cmd_exists("zstd") { return; diff --git a/tests/util.rs b/tests/util.rs index e5fb8a6..44d0a51 100644 --- a/tests/util.rs +++ b/tests/util.rs @@ -45,7 +45,10 @@ pub fn sort_lines(lines: &str) -> String { /// Returns true if and only if the given program can be successfully executed /// with a `--help` flag. pub fn cmd_exists(program: &str) -> bool { - Command::new(program).arg("--help").output().is_ok() + match Command::new(program).arg("--help").output() { + Ok(output) => output.status.success(), + Err(_) => false, + } } /// Dir represents a directory in which tests should be run.