2
2
//!
3
3
//! This module implements `bootc container lint`.
4
4
5
+ use std:: env:: consts:: ARCH ;
6
+
5
7
use anyhow:: Result ;
6
8
use cap_std:: fs:: Dir ;
7
9
use cap_std_ext:: cap_std;
@@ -13,7 +15,7 @@ use fn_error_context::context;
13
15
/// if it does not exist error.
14
16
#[ context( "Linting" ) ]
15
17
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 ] ;
17
19
for lint in lints {
18
20
lint ( & root) ?;
19
21
}
@@ -30,6 +32,12 @@ fn check_var_run(root: &Dir) -> Result<()> {
30
32
Ok ( ( ) )
31
33
}
32
34
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
+
33
41
fn check_kernel ( root : & Dir ) -> Result < ( ) > {
34
42
let result = ostree_ext:: bootabletree:: find_kernel_dir_fs ( & root) ?;
35
43
tracing:: debug!( "Found kernel: {:?}" , result) ;
@@ -70,3 +78,13 @@ fn test_kernel_lint() -> Result<()> {
70
78
check_kernel ( root) . unwrap ( ) ;
71
79
Ok ( ( ) )
72
80
}
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