From 897f59fab1a1eb504be1fda9d6d43b7ea05fe024 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Thu, 10 Jul 2025 20:48:11 +0300 Subject: [PATCH] test/fuzz: add ignored fuzz test for min()/max() - ignored because of bugs --- tests/integration/fuzz/mod.rs | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/integration/fuzz/mod.rs b/tests/integration/fuzz/mod.rs index ecb478fcc..e8b06d953 100644 --- a/tests/integration/fuzz/mod.rs +++ b/tests/integration/fuzz/mod.rs @@ -1373,6 +1373,66 @@ mod tests { } } + #[test] + #[ignore] + /// Ignored because of https://github.com/tursodatabase/turso/issues/2040, https://github.com/tursodatabase/turso/issues/2041 + /// TODO: add fuzzing for other aggregate functions + pub fn min_max_agg_fuzz() { + let _ = env_logger::try_init(); + + let datatypes = ["INTEGER", "TEXT", "REAL", "BLOB"]; + let (mut rng, seed) = rng_from_time(); + log::info!("seed: {}", seed); + + for _ in 0..1000 { + // Create table with random datatype + let datatype = datatypes[rng.random_range(0..datatypes.len())]; + let create_table = format!("CREATE TABLE t(x {})", datatype); + + let db = TempDatabase::new_empty(false); + let limbo_conn = db.connect_limbo(); + let sqlite_conn = rusqlite::Connection::open_in_memory().unwrap(); + + limbo_exec_rows(&db, &limbo_conn, &create_table); + sqlite_exec_rows(&sqlite_conn, &create_table); + + // Insert 5 random values of random types + let mut values = Vec::new(); + for _ in 0..5 { + let value = match rng.random_range(0..4) { + 0 => rng.random_range(-1000..1000).to_string(), // Integer + 1 => format!( + "'{}'", + (0..10) + .map(|_| rng.random_range(b'a'..=b'z') as char) + .collect::() + ), // Text + 2 => format!("{:.2}", rng.random_range(-100..100) as f64 / 10.0), // Real + 3 => "NULL".to_string(), // NULL + _ => unreachable!(), + }; + values.push(format!("({})", value)); + } + + let insert = format!("INSERT INTO t VALUES {}", values.join(",")); + limbo_exec_rows(&db, &limbo_conn, &insert); + sqlite_exec_rows(&sqlite_conn, &insert); + + // Test min and max + for agg in ["min(x)", "max(x)"] { + let query = format!("SELECT {} FROM t", agg); + let limbo = limbo_exec_rows(&db, &limbo_conn, &query); + let sqlite = sqlite_exec_rows(&sqlite_conn, &query); + + assert_eq!( + limbo, sqlite, + "query: {}, limbo: {:?}, sqlite: {:?}, seed: {}, values: {:?}, schema: {}", + query, limbo, sqlite, seed, values, create_table + ); + } + } + } + #[test] pub fn table_logical_expression_fuzz_run() { let _ = env_logger::try_init();