Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Make modules case insenstive on windows #3527

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/agent/coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

use anyhow::Result;
use regex::{Regex, RegexSet};
use regex::{Regex, RegexBuilder, RegexSet};
use std::path::Path;

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -144,7 +144,13 @@ fn glob_to_regex(expr: &str) -> Result<Regex> {
// Anchor to line start and end.
let expr = format!("^{expr}$");

Ok(Regex::new(&expr)?)
let mut rb = RegexBuilder::new(&expr);

if cfg!(windows) {
rb.case_insensitive(true);
tevoinea marked this conversation as resolved.
Show resolved Hide resolved
}

Ok(rb.build()?)
}

#[cfg(test)]
Expand Down
10 changes: 9 additions & 1 deletion src/agent/coverage/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ fn windows_snapshot_tests() {
};

// filter to just the input test file:
let source_allowlist = AllowList::parse(&input_path.to_string_lossy()).unwrap();
let source_allowlist =
AllowList::parse(&input_path.to_string_lossy().to_ascii_lowercase()).unwrap();

let exe_cmd = std::process::Command::new(&exe_name);
let recorded = coverage::CoverageRecorder::new(exe_cmd)
Expand All @@ -52,6 +53,13 @@ fn windows_snapshot_tests() {
.record()
.unwrap();

// Windows modules should be case insensitive
tevoinea marked this conversation as resolved.
Show resolved Hide resolved
recorded
.coverage
.modules
.keys()
.for_each(|k| assert_eq!(k.to_string().to_ascii_lowercase(), k.to_string()));

// generate source-line coverage info
let source =
coverage::source::binary_to_source_coverage(&recorded.coverage, &source_allowlist)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
source: coverage/tests/snapshot.rs
expression: result
input_file: coverage/tests/windows/inlinee.cpp
input_file: coverage/tests/windows/Inlinee.cpp
---
[ ] #include <iostream>
[ ]
Expand Down
2 changes: 2 additions & 0 deletions src/agent/debugger/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ impl Module {
"???".into()
});

let path = PathBuf::from(path.as_os_str().to_ascii_lowercase());
tevoinea marked this conversation as resolved.
Show resolved Hide resolved

let image_details = get_image_details(&path)?;

Ok(Module {
Expand Down
9 changes: 6 additions & 3 deletions src/agent/onefuzz/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ impl<'a> Expand<'a> {

fn input_file_sha256(&self) -> Result<ExpandedValue<'a>> {
let Some(val) = self.values.get(PlaceHolder::Input.get_string()) else {
bail!("no value found for {}, unable to evaluate {}",
bail!(
"no value found for {}, unable to evaluate {}",
PlaceHolder::Input.get_string(),
PlaceHolder::InputFileSha256.get_string(),
)
Expand All @@ -149,7 +150,8 @@ impl<'a> Expand<'a> {

fn extract_file_name_no_ext(&self) -> Result<ExpandedValue<'a>> {
let Some(val) = self.values.get(PlaceHolder::Input.get_string()) else {
bail!("no value found for {}, unable to evaluate {}",
bail!(
"no value found for {}, unable to evaluate {}",
PlaceHolder::Input.get_string(),
PlaceHolder::InputFileNameNoExt.get_string(),
)
Expand All @@ -173,7 +175,8 @@ impl<'a> Expand<'a> {

fn extract_file_name(&self) -> Result<ExpandedValue<'a>> {
let Some(val) = self.values.get(PlaceHolder::Input.get_string()) else {
bail!("no value found for {}, unable to evaluate {}",
bail!(
"no value found for {}, unable to evaluate {}",
PlaceHolder::Input.get_string(),
PlaceHolder::InputFileName.get_string(),
)
Expand Down
Loading