Skip to content

Commit

Permalink
Add new test-case to reproduce gix-url failure in debug mode only (Gi…
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Oct 30, 2023
1 parent d3fb537 commit d78f445
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions gix-url/tests/fixtures/fuzzed/very-long-abort.url
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wss:// @ 󠄷 񠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 󠀷 ㏴ ㅴ ㏴ 㩴 ㅴ ㏴ ㅴ . /
17 changes: 17 additions & 0 deletions gix-url/tests/fuzzed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ use bstr::ByteSlice;
use std::path::Path;
use std::time::Duration;

#[test]
#[cfg_attr(debug_assertions, ignore = "fails due to integer overflow")]
fn abort_unfixed_in_debug_mode() {
let name = "very-long-abort";
let base = Path::new("tests").join("fixtures").join("fuzzed");
let location = base.join(Path::new(name).with_extension("url"));
let url = std::fs::read(&location).unwrap();
let start = std::time::Instant::now();
gix_url::parse(url.as_bstr()).ok();
assert!(
start.elapsed() < Duration::from_millis(100),
"URL at '{}' parsed too slowly, took {:.00}s",
location.display(),
start.elapsed().as_secs_f32()
);
}

#[test]
fn fuzzed() {
for name in [
Expand Down

0 comments on commit d78f445

Please sign in to comment.