Skip to content

Commit b21c469

Browse files
authored
Merge pull request bootc-dev#663 from cgwalters/lint-kargs
lint: Verify we can parse the kargs.d files
2 parents dad29ac + f9b3e3f commit b21c469

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lib/src/lints.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! This module implements `bootc container lint`.
44
5+
use std::env::consts::ARCH;
6+
57
use anyhow::Result;
68
use cap_std::fs::Dir;
79
use cap_std_ext::cap_std;
@@ -13,7 +15,7 @@ use fn_error_context::context;
1315
/// if it does not exist error.
1416
#[context("Linting")]
1517
pub(crate) fn lint(root: &Dir) -> Result<()> {
16-
let lints = [check_var_run, check_kernel];
18+
let lints = [check_var_run, check_kernel, check_parse_kargs];
1719
for lint in lints {
1820
lint(&root)?;
1921
}
@@ -30,6 +32,12 @@ fn check_var_run(root: &Dir) -> Result<()> {
3032
Ok(())
3133
}
3234

35+
/// Validate that we can parse the /usr/lib/bootc/kargs.d files.
36+
fn check_parse_kargs(root: &Dir) -> Result<()> {
37+
let _args = crate::kargs::get_kargs_in_root(root, ARCH)?;
38+
Ok(())
39+
}
40+
3341
fn check_kernel(root: &Dir) -> Result<()> {
3442
let result = ostree_ext::bootabletree::find_kernel_dir_fs(&root)?;
3543
tracing::debug!("Found kernel: {:?}", result);
@@ -70,3 +78,13 @@ fn test_kernel_lint() -> Result<()> {
7078
check_kernel(root).unwrap();
7179
Ok(())
7280
}
81+
82+
#[test]
83+
fn test_kargs() -> Result<()> {
84+
let root = &fixture()?;
85+
check_parse_kargs(root).unwrap();
86+
root.create_dir_all("usr/lib/bootc")?;
87+
root.write("usr/lib/bootc/kargs.d", "not a directory")?;
88+
assert!(check_parse_kargs(root).is_err());
89+
Ok(())
90+
}

0 commit comments

Comments
 (0)