Skip to content

Commit

Permalink
config: Skip validation of keylime_dir during tests
Browse files Browse the repository at this point in the history
When running tests on machines where /var/lib/keylime does not exist
(e.g. build machines where keylime is not installed), the tests would
fail on the check if keylime_dir exists.

Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
  • Loading branch information
ansasaki committed Feb 24, 2023
1 parent cf6c4f0 commit be096f2
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions keylime-agent/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,23 +608,26 @@ fn config_translate_keywords(
Some(ref dir) => {
if dir.is_empty() {
match &config.agent.keylime_dir {
s => s.clone(),
_ => DEFAULT_KEYLIME_DIR.to_string(),
s => Path::new(s),
_ => Path::new(DEFAULT_KEYLIME_DIR),
}
} else {
dir.to_string()
Path::new(dir)
}
}
None => match &config.agent.keylime_dir {
s => s.clone(),
_ => DEFAULT_KEYLIME_DIR.to_string(),
s => Path::new(s),
_ => Path::new(DEFAULT_KEYLIME_DIR),
},
};

// Validate that keylime_dir exists
let keylime_dir = Path::new(&keylime_dir).canonicalize().map_err(|e| {
#[cfg(not(test))]
let keylime_dir = keylime_dir.canonicalize().map_err(|e| {
Error::Configuration(format!(
"Path {keylime_dir} set in keylime_dir configuration option not found: {e}"
"Path {} set in keylime_dir configuration option not found: {}",
keylime_dir.display(),
e
))
})?;

Expand Down

0 comments on commit be096f2

Please sign in to comment.