Skip to content

Commit

Permalink
wip: tweaking tests, and getting understanding of cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
prestist committed Apr 25, 2024
1 parent cbe1fcb commit 28071ac
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/src/privtests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<T>(cmd_output));
println!("{:?}",cmd_output);
println!("{:?}", cmd_output2);
// assert_eq!(cmd_output, 1);
cmd!(sh, "podman rm -f test").run()?;
Ok(())

}
Expand Down

0 comments on commit 28071ac

Please sign in to comment.