test: regression test case for cliprdr_format target (#405)

This commit is contained in:
Benoît Cortier 2024-03-09 00:44:12 +09:00 committed by GitHub
parent 220df049b6
commit e92d8c3e17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 31 additions and 14 deletions

View file

@ -199,9 +199,9 @@ impl BitmapInfoHeader {
let size = src.read_u32();
let width = src.read_i32();
// NOTE: .abs() could panic on i32::MIN, therefore we have a check for it first.
let width = src.read_i32();
check_invariant(width != i32::MIN && width.abs() <= 10_000)
.ok_or_else(|| invalid_message_err!("biWidth", "width is too big"))?;

View file

@ -0,0 +1,28 @@
macro_rules! check {
($oracle:ident) => {{
use ironrdp_fuzzing::oracles;
const REGRESSION_DATA_FOLDER: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
concat!("/test_data/fuzz_regression/", stringify!($oracle))
);
println!("Read directory {REGRESSION_DATA_FOLDER}");
for entry in std::fs::read_dir(REGRESSION_DATA_FOLDER).unwrap() {
let entry = entry.unwrap();
println!("Check {}", entry.path().display());
let test_case = std::fs::read(entry.path()).unwrap();
oracles::$oracle(&test_case);
}
}};
}
#[test]
pub fn check_pdu_decode() {
check!(pdu_decode);
}
#[test]
pub fn check_cliprdr_format() {
check!(cliprdr_format);
}

View file

@ -11,6 +11,7 @@
mod clipboard;
mod displaycontrol;
mod fuzz_regression;
mod graphics;
mod input;
mod pcb;

View file

@ -4,6 +4,5 @@ mod input;
mod mcs;
mod pointer;
mod rdp;
mod regression;
mod rfx;
mod x224;

View file

@ -1,11 +0,0 @@
const REGRESSION_DATA_FOLDER: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/test_data/pdu/regression/");
#[test]
pub fn check() {
for entry in std::fs::read_dir(REGRESSION_DATA_FOLDER).unwrap() {
let entry = entry.unwrap();
println!("Check {}", entry.path().display());
let test_case = std::fs::read(entry.path()).unwrap();
ironrdp_fuzzing::oracles::pdu_decode(&test_case);
}
}