mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-17 20:38:06 +00:00
address latest clippy warnings (#679)
This commit is contained in:
@ -260,7 +260,7 @@ mod tests {
|
|||||||
let runtime_dir = tempfile::tempdir().unwrap();
|
let runtime_dir = tempfile::tempdir().unwrap();
|
||||||
|
|
||||||
let supervisor_exe = if let Ok(x) = env::var("ONEFUZZ_TEST_AFL_LINUX_FUZZER") {
|
let supervisor_exe = if let Ok(x) = env::var("ONEFUZZ_TEST_AFL_LINUX_FUZZER") {
|
||||||
x.into()
|
x
|
||||||
} else {
|
} else {
|
||||||
warn!("Unable to test AFL integration");
|
warn!("Unable to test AFL integration");
|
||||||
return;
|
return;
|
||||||
|
@ -100,9 +100,7 @@ fn url_input_name(url: &Url) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fixture() -> InputPoller<Msg> {
|
fn fixture() -> InputPoller<Msg> {
|
||||||
let task = InputPoller::new();
|
InputPoller::new()
|
||||||
|
|
||||||
task
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn url_fixture(msg: Msg) -> Url {
|
fn url_fixture(msg: Msg) -> Url {
|
||||||
|
@ -44,32 +44,33 @@ impl std::io::Write for TailBuffer {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use anyhow::Result;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tail_buffer() {
|
fn test_tail_buffer() -> Result<()> {
|
||||||
let mut buf = TailBuffer::new(5);
|
let mut buf = TailBuffer::new(5);
|
||||||
|
|
||||||
assert!(buf.data().is_empty());
|
assert!(buf.data().is_empty());
|
||||||
|
|
||||||
buf.write(&[1, 2, 3]).unwrap();
|
assert_eq!(buf.write(&[1, 2, 3])?, 3);
|
||||||
assert_eq!(buf.data(), &[1, 2, 3]);
|
assert_eq!(buf.data(), &[1, 2, 3]);
|
||||||
|
|
||||||
buf.write(&[]).unwrap();
|
assert_eq!(buf.write(&[])?, 0);
|
||||||
assert_eq!(buf.data(), &[1, 2, 3]);
|
assert_eq!(buf.data(), &[1, 2, 3]);
|
||||||
|
|
||||||
buf.write(&[4, 5]).unwrap();
|
assert_eq!(buf.write(&[4, 5])?, 2);
|
||||||
assert_eq!(buf.data(), &[1, 2, 3, 4, 5]);
|
assert_eq!(buf.data(), &[1, 2, 3, 4, 5]);
|
||||||
|
|
||||||
buf.write(&[6, 7, 8]).unwrap();
|
assert_eq!(buf.write(&[6, 7, 8])?, 3);
|
||||||
assert_eq!(buf.data(), &[4, 5, 6, 7, 8]);
|
assert_eq!(buf.data(), &[4, 5, 6, 7, 8]);
|
||||||
|
|
||||||
buf.write(&[9, 10, 11, 12, 13]).unwrap();
|
assert_eq!(buf.write(&[9, 10, 11, 12, 13])?, 5);
|
||||||
assert_eq!(buf.data(), &[9, 10, 11, 12, 13]);
|
assert_eq!(buf.data(), &[9, 10, 11, 12, 13]);
|
||||||
|
|
||||||
buf.write(&[14, 15, 16, 17, 18, 19, 20, 21, 22]).unwrap();
|
assert_eq!(buf.write(&[14, 15, 16, 17, 18, 19, 20, 21, 22])?, 9);
|
||||||
assert_eq!(buf.data(), &[18, 19, 20, 21, 22]);
|
assert_eq!(buf.data(), &[18, 19, 20, 21, 22]);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,6 +284,10 @@ mod tests {
|
|||||||
.expect("no captures");
|
.expect("no captures");
|
||||||
|
|
||||||
assert_eq!(parsed.iters(), 2097152);
|
assert_eq!(parsed.iters(), 2097152);
|
||||||
assert_eq!(parsed.execs_sec(), 699050.0_f64);
|
|
||||||
|
let expected: f64 = 699050.0;
|
||||||
|
let execs_sec = parsed.execs_sec();
|
||||||
|
assert!(execs_sec.is_finite());
|
||||||
|
assert!((execs_sec - expected).abs() < f64::EPSILON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user