diff --git a/lib/src/privtests.rs b/lib/src/privtests.rs index c1f264794..92e938598 100644 --- a/lib/src/privtests.rs +++ b/lib/src/privtests.rs @@ -5,7 +5,6 @@ use camino::Utf8Path; use fn_error_context::context; use rustix::fd::AsFd; use xshell::{cmd, Shell}; - use crate::blockdev::LoopbackDevice; use crate::install::config::InstallConfiguration; @@ -164,14 +163,33 @@ fn test_install_filesystem(image: &str, blockdev: &Utf8Path) -> Result<()> { #[context("Container tests")] fn test_build_lint(image: &str) -> Result<()> { - let sh = Shell::new()?; - cmd!(sh, "podman run --rm --privileged --pid=host --env=RUST_LOG -v /usr/bin/bootc:/usr/bin/bootc {image} bootc build-lint").run()?; - let copy_kernel = "bootc build-lint"; - cmd!(sh, "podman run --rm --privileged --pid=host --env=RUST_LOG -v /usr/bin/bootc:/usr/bin/bootc {image} {copy_kernel}").run()?; + let sh = Shell::new()?; + // Smoke test of build_lint + let _test_1_result = cmd!(sh, "podman run --rm --privileged --pid=host --env=RUST_LOG -v /usr/bin/bootc:/usr/bin/bootc {image} bootc build-lint").run(); + + // Setup for multiple kernels lint test + cmd!(sh, "podman run -dt --name test --privileged --pid=host --env=RUST_LOG -v /usr/bin/bootc:/usr/bin/bootc {image} bash").run()?; + let kernel_name = cmd!(sh, "podman exec test bash -c 'ls /usr/lib/modules | tail -n -1'" ).read()?; + Command::new("podman") + .arg("exec") + .arg("test") + .arg("bash") + .arg("-c") + .arg(format!("sudo cp -r /usr/lib/modules/{} /usr/lib/modules/delete-me", kernel_name)) + .output()?; + let more_then_one_kernel_result = cmd!(sh, "podman exec test bash -c 'bootc build-lint'").read_stderr(); + // Container Cleanup + cmd!(sh, "podman rm -f test").run()?; + + _test_1_result?; + if let Err(e) = more_then_one_kernel_result { + assert!(e.to_string().contains("bootc build-lint")); + } else { + assert!(false, "Expected error, got none"); + } Ok(()) - } pub(crate) async fn run(opts: TestingOpts) -> Result<()> {