#![cfg(feature = "testing")]
use sqlite_diff_rs::testing::{
FuzzSchemas, TypedSimpleTable, run_crash_dir_regression, test_apply_roundtrip,
test_differential, test_reverse_idempotent, test_roundtrip, test_sql_roundtrip,
};
use std::time::Duration;
const PER_INPUT_TIME_LIMIT: Duration = Duration::from_secs(2);
#[test]
fn fuzz_regression_empty_patchset_changeset_equality() {
let input = [0x50, 0x01, 0x01, 0x3b, 0x01, 0x3d, 0x00];
test_roundtrip(&input);
}
#[test]
fn fuzz_regression_nan_normalized_to_null() {
let input = [
0x54, 0x04, 0x2d, 0x93, 0xf8, 0xff, 0x11, 0x00, 0x09, 0x08, 0x00, 0x02, 0x7f, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
];
test_roundtrip(&input);
}
#[test]
fn fuzz_regression_crash_3() {
let input = [
0x50, 0x01, 0x00, 0x02, 0x02, 0x2d, 0x35, 0x31, 0x38, 0x50, 0x02, 0x00, 0x09, 0x09, 0x09,
0x00, 0x12, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x03, 0x20, 0x00, 0x00,
0x00, 0x00,
];
test_roundtrip(&input);
}
#[test]
fn fuzz_regression_crash_4() {
let input = [
0x54, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00,
];
test_roundtrip(&input);
}
#[test]
fn fuzz_regression_crash_5() {
let input = [
0x50, 0x02, 0xff, 0x40, 0x00, 0x17, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x09, 0x00, 0x00, 0x00, 0x50, 0x02, 0xff, 0x40, 0x00,
];
test_roundtrip(&input);
}
#[test]
fn fuzz_regression_crash_6() {
let input = [
0x54, 0x05, 0x48, 0x00, 0x00, 0xf5, 0x00, 0x00, 0x09, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x12, 0xf8, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
0x00, 0x00,
];
test_roundtrip(&input);
}
#[test]
fn fuzz_regression_roundtrip_crash_inputs_dir() {
run_crash_dir_regression(
concat!(env!("CARGO_MANIFEST_DIR"), "/tests/crash_inputs/roundtrip"),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/fuzz/hfuzz_workspace/roundtrip"
),
PER_INPUT_TIME_LIMIT,
test_roundtrip,
);
}
#[test]
fn fuzz_regression_reverse_idempotent_crash_inputs_dir() {
run_crash_dir_regression(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/crash_inputs/reverse_idempotent"
),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/fuzz/hfuzz_workspace/reverse_idempotent"
),
PER_INPUT_TIME_LIMIT,
test_reverse_idempotent,
);
}
#[test]
fn fuzz_regression_apply_roundtrip_crash_inputs_dir() {
run_crash_dir_regression(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/crash_inputs/apply_roundtrip"
),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/fuzz/hfuzz_workspace/apply_roundtrip"
),
PER_INPUT_TIME_LIMIT,
|data| {
test_roundtrip(data);
let Ok(parsed) = sqlite_diff_rs::ParsedDiffSet::try_from(data) else {
return;
};
let schemas: Vec<TypedSimpleTable> = parsed
.table_schemas()
.into_iter()
.map(TypedSimpleTable::from_table_schema)
.collect();
let serialized: Vec<u8> = parsed.into();
test_apply_roundtrip(&schemas, &serialized);
},
);
}
#[test]
fn fuzz_regression_sql_roundtrip_crash_inputs_dir() {
run_crash_dir_regression(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/crash_inputs/sql_roundtrip"
),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/fuzz/hfuzz_workspace/sql_roundtrip"
),
PER_INPUT_TIME_LIMIT,
|data| {
let Ok((schemas, sql)) =
arbitrary::Unstructured::new(data).arbitrary::<(FuzzSchemas, String)>()
else {
return;
};
test_sql_roundtrip(&schemas, &sql);
},
);
}
#[test]
fn fuzz_regression_differential_crash_inputs_dir() {
run_crash_dir_regression(
concat!(
env!("CARGO_MANIFEST_DIR"),
"/tests/crash_inputs/differential"
),
concat!(
env!("CARGO_MANIFEST_DIR"),
"/fuzz/hfuzz_workspace/differential"
),
PER_INPUT_TIME_LIMIT,
|data| {
let Ok((schemas, sql)) =
arbitrary::Unstructured::new(data).arbitrary::<(FuzzSchemas, String)>()
else {
return;
};
test_differential(&schemas, &sql);
},
);
}