Skip to content

Commit

Permalink
wip-stuck in limbo
Browse files Browse the repository at this point in the history
  • Loading branch information
prestist committed Mar 28, 2024
1 parent b97d8bd commit cbe1fcb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//!
//! Command line tool to manage bootable ostree-based containers.
use anyhow::Ok;
use anyhow::{Context, Result};
use camino::Utf8PathBuf;
use cap_std_ext::cap_std;
Expand Down Expand Up @@ -151,6 +150,10 @@ pub(crate) enum TestingOpts {
image: String,
blockdev: Utf8PathBuf,
},
// Test set of lints on ostree container
TestBuildLint {
image: String,
},
}

/// Deploy and transactionally in-place with bootable container images.
Expand Down Expand Up @@ -588,3 +591,21 @@ fn test_parse_install_args() {
assert!(o.target_opts.target_no_signature_verification);
assert_eq!(o.filesystem_opts.root_path.as_str(), "/target");
}

#[test]
fn test_linting() {
// linting should only occur in side of a container.
match ostree_ext::container_utils::is_ostree_container() {
Ok(result) => {
if !result {
let expected_error_message = "Not in a ostree container, this command only verifies ostree containers.";

let result = lint();
assert_eq!(result.err().unwrap().to_string(), expected_error_message, "Error message mismatch");
}

},
Err(_) =>{
}
}
}
16 changes: 16 additions & 0 deletions lib/src/privtests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ fn test_install_filesystem(image: &str, blockdev: &Utf8Path) -> Result<()> {
Ok(())
}

#[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()?;

Ok(())

}

pub(crate) async fn run(opts: TestingOpts) -> Result<()> {
match opts {
TestingOpts::RunPrivilegedIntegration {} => {
Expand All @@ -179,5 +191,9 @@ pub(crate) async fn run(opts: TestingOpts) -> Result<()> {
crate::cli::ensure_self_unshared_mount_namespace().await?;
tokio::task::spawn_blocking(move || test_install_filesystem(&image, &blockdev)).await?
}
TestingOpts::TestBuildLint { image } => {
tokio::task::spawn_blocking(move || test_build_lint(&image)).await?
}

}
}

0 comments on commit cbe1fcb

Please sign in to comment.