From 28071acca17ae97a96c70e00bb4a35b8f1e6e27e Mon Sep 17 00:00:00 2001 From: Steven Presti Date: Thu, 25 Apr 2024 14:47:42 -0400 Subject: [PATCH] wip: tweaking tests, and getting understanding of cmd --- lib/src/privtests.rs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/src/privtests.rs b/lib/src/privtests.rs index c1f264794..eeea46602 100644 --- a/lib/src/privtests.rs +++ b/lib/src/privtests.rs @@ -164,12 +164,30 @@ 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()?; + cmd!(sh, "podman rm -f test").run()?; + 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()?; + let _copy_kernel = "&& cp -r /usr/lib/modules/${kernel} /usr/lib/modules/${kernel}-to-delete"; + // create container named test + cmd!(sh, "podman run -dt --name test --privileged --pid=host --env=RUST_LOG -v /usr/bin/bootc:/usr/bin/bootc {image} bash").run()?; + // run command against container to copy kernel + let kernel_name = cmd!(sh, "podman exec test bash -c 'ls /usr/lib/modules | tail -n -1'" ).read()?; + println!("{:?}",kernel_name); + //podman exec test bash -c 'sudo cp -r /usr/lib/modules/6.8.0-0.rc4.20240216git4f5e5092fdbf.39.eln136.x86_64 /usr/lib/modules/delete-me' + cmd!(sh, "podman exec test bash -c 'sudo cp -r /usr/lib/modules/6.8.0-0.rc4.20240216git4f5e5092fdbf.39.eln136.x86_64 /usr/lib/modules/delete-me'" ).run()?; + // run our code. + let cmd_output = cmd!(sh, "podman exec test bash -c 'bootc build-lint'").read_stderr(); + let cmd_output2 = cmd!(sh, "podman exec test bash -c 'bootc build-lint'").ignore_status().read(); + + + // println!("{}", std::any::type_name::(cmd_output)); + println!("{:?}",cmd_output); + println!("{:?}", cmd_output2); + // assert_eq!(cmd_output, 1); + cmd!(sh, "podman rm -f test").run()?; Ok(()) }