Skip to content

Valgrind setup fails on Ubuntu/Debian derivative distributions (e.g. Pop!_OS) #326

@s3bc40

Description

@s3bc40

Context

pub fn from_os(os: &str) -> Result<Self> {
let os_version = System::os_version().ok_or(anyhow!("Failed to get OS version"))?;
match os {
"linux" => {
let os_id = System::distribution_id();
Ok(Self::Linux(LinuxDistribution::from_id(&os_id, &os_version)))
}
"macos" => Ok(Self::Macos {
version: os_version,
}),
unsupported => bail!("Unsupported operating system: {unsupported}"),
}

Running cargo test on Ubuntu-derivative distros (e.g. Pop!_OS for me) causes 14 valgrind executor tests to fail with: Unsupported system.

test executor::tests::valgrind::test_valgrind_executor_with_env::case_2 ... FAILED
test executor::tests::valgrind::test_valgrind_executor_with_env::case_3 ... FAILED
test executor::tests::valgrind::test_valgrind_executor_with_env::case_4 ... FAILED
AGENTS.md   Cargo.toml	  CONTRIBUTING.md      LICENSE-APACHE	    schemas  target
assets	    CHANGELOG.md  crates	       LICENSE-MIT	    scripts  testdata
build.rs    CLAUDE.md	  cspell.json	       README.md	    skills   tests
Cargo.lock  cliff.toml	  dist-workspace.toml  rust-toolchain.toml  src
test executor::tests::valgrind::test_valgrind_executor_with_env::case_5 ... FAILED
test executor::shared::fifo::tests::recv_cmd_is_not_cancel_safe ... ok
test executor::tests::valgrind::test_valgrind_executor_with_env::case_6 ... FAILED
test executor::tests::valgrind::test_valgrind_executor_with_env::case_7 ... FAILED
test executor::wall_time::perf::elf_helper::tests::test_find_debug_file_by_build_id ... ok
test executor::tests::valgrind::test_valgrind_executor_with_env::case_8 ... FAILED\

Since Pop!_OS is a derivative of ubuntu|debian, I though we could adapt the process to accept other distros that are close to Ubuntu and Debian

Root cause

sysinfo::System::distribution_id() returns the distro's own ID (e.g. "pop" for Pop!_OS), not its parent. LinuxDistribution::from_id() only exact-matches "ubuntu" and "debian", so derivatives fall through to Other. Which get_codspeed_valgrind_filename() doesn't handle.

Proposal

Use System::distribution_id_like() (available since sysinfo@0.35 I think) as a fallback: if the primary ID is unrecognized, walk the parent chain (["ubuntu", "debian"]` for Pop!_OS) until a known distro is found.

https://docs.rs/sysinfo/0.38.4/sysinfo/struct.System.html#method.distribution_id_like

This requires bumping sysinfo from 0.33.1 to 0.38.4, which also involves adapting one call site where physical_core_count() became an associated function.

Affected systems

Any Linux distro where ID != ubuntu|debian but ID_LIKE contains one of them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions