Skip to content

Commit

Permalink
Merge pull request #663 from cgwalters/lint-kargs
Browse files Browse the repository at this point in the history
lint: Verify we can parse the kargs.d files
  • Loading branch information
cgwalters committed Jul 2, 2024
2 parents dad29ac + f9b3e3f commit b21c469
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/src/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! This module implements `bootc container lint`.

use std::env::consts::ARCH;

use anyhow::Result;
use cap_std::fs::Dir;
use cap_std_ext::cap_std;
Expand All @@ -13,7 +15,7 @@ use fn_error_context::context;
/// if it does not exist error.
#[context("Linting")]
pub(crate) fn lint(root: &Dir) -> Result<()> {
let lints = [check_var_run, check_kernel];
let lints = [check_var_run, check_kernel, check_parse_kargs];
for lint in lints {
lint(&root)?;
}
Expand All @@ -30,6 +32,12 @@ fn check_var_run(root: &Dir) -> Result<()> {
Ok(())
}

/// Validate that we can parse the /usr/lib/bootc/kargs.d files.
fn check_parse_kargs(root: &Dir) -> Result<()> {
let _args = crate::kargs::get_kargs_in_root(root, ARCH)?;
Ok(())
}

fn check_kernel(root: &Dir) -> Result<()> {
let result = ostree_ext::bootabletree::find_kernel_dir_fs(&root)?;
tracing::debug!("Found kernel: {:?}", result);
Expand Down Expand Up @@ -70,3 +78,13 @@ fn test_kernel_lint() -> Result<()> {
check_kernel(root).unwrap();
Ok(())
}

#[test]
fn test_kargs() -> Result<()> {
let root = &fixture()?;
check_parse_kargs(root).unwrap();
root.create_dir_all("usr/lib/bootc")?;
root.write("usr/lib/bootc/kargs.d", "not a directory")?;
assert!(check_parse_kargs(root).is_err());
Ok(())
}

0 comments on commit b21c469

Please sign in to comment.