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

Commit

Permalink
Tests and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
tevoinea committed Sep 25, 2023
1 parent 4955ac4 commit cc551a6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 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, RegexBuilder};
use regex::{Regex, RegexBuilder, RegexSet};
use std::path::Path;

#[derive(Clone, Debug)]
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
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
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

0 comments on commit cc551a6

Please sign in to comment.