Skip to content

Commit

Permalink
Making sure that the test feature is exercised correctly in the rust …
Browse files Browse the repository at this point in the history
…agent build

Signed-off-by: George Almasi <[email protected]>
  • Loading branch information
George Almasi committed Jan 17, 2024
1 parent ea1fd45 commit 048f6c0
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions keylime-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,21 @@ async fn main() -> Result<()> {
let mut config = config::KeylimeConfig::new()?;

// load path for IMA logfile
// To fix later: GA 10/1/23: IMA and MBA log path override mechanisms are different
let mut ima_ml_path;
cfg_if::cfg_if! {
if #[cfg(test)] {
#[cfg(test)]
fn ima_ml_path_get(_: &String) -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))

Check warning on line 138 in keylime-agent/src/main.rs

View check run for this annotation

Codecov / codecov/patch

keylime-agent/src/main.rs#L137-L138

Added lines #L137 - L138 were not covered by tests
.join("test-data")
.join("ima")
.join("ascii_runtime_measurements")
}

let p = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("test-data")
.join("ima")
.join("ascii_runtime_measurements");
ima_ml_path = p.as_path();
} else {
ima_ml_path = Path::new(&config.agent.ima_ml_path);
}
#[cfg(not(test))]
fn ima_ml_path_get(s: &String) -> PathBuf {
Path::new(&s).to_path_buf()
}

let ima_ml_path = ima_ml_path_get(&config.agent.ima_ml_path);

// check whether anyone has overridden the default
if ima_ml_path.as_os_str() != config::DEFAULT_IMA_ML_PATH {
warn!(
Expand All @@ -158,7 +158,7 @@ async fn main() -> Result<()> {

// check IMA logfile exists & accessible
let ima_ml_file = if ima_ml_path.exists() {
match fs::File::open(ima_ml_path) {
match fs::File::open(&ima_ml_path) {
Ok(file) => Some(Mutex::new(file)),
Err(e) => {
warn!(
Expand Down

0 comments on commit 048f6c0

Please sign in to comment.