From 4eea4a71d721e338e088d6e588a3c3aed7ea79ee Mon Sep 17 00:00:00 2001 From: "Levy A." Date: Fri, 27 Jun 2025 22:04:36 -0300 Subject: [PATCH] fix: add fuzz to CI checks --- .github/workflows/rust.yml | 2 ++ fuzz/Cargo.lock | 54 ++++----------------------------- fuzz/fuzz_targets/cast_real.rs | 4 +-- fuzz/fuzz_targets/expression.rs | 8 ++--- fuzz/fuzz_targets/schema.rs | 7 ++--- 5 files changed, 16 insertions(+), 59 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fa7cd6b0d..b1aeae085 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,6 +17,8 @@ jobs: - uses: dtolnay/rust-toolchain@stable - name: Check formatting run: cargo fmt --check + - name: Check formatting (fuzz) + run: cd fuzz && cargo fmt --check build-native: strategy: diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index c9ea0ca83..4730408e4 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -564,26 +564,6 @@ dependencies = [ "turso_core", ] -[[package]] -name = "limbo_series" -version = "0.1.0-pre.2" -dependencies = [ - "mimalloc", - "turso_ext", -] - -[[package]] -name = "limbo_time" -version = "0.1.0-pre.2" -dependencies = [ - "chrono", - "mimalloc", - "strum", - "strum_macros", - "thiserror 2.0.12", - "turso_ext", -] - [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -1018,16 +998,7 @@ version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ - "thiserror-impl 1.0.69", -] - -[[package]] -name = "thiserror" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" -dependencies = [ - "thiserror-impl 2.0.12", + "thiserror-impl", ] [[package]] @@ -1041,17 +1012,6 @@ dependencies = [ "syn", ] -[[package]] -name = "thiserror-impl" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "tinystr" version = "0.7.6" @@ -1095,7 +1055,7 @@ dependencies = [ [[package]] name = "turso_core" -version = "0.1.0-pre.2" +version = "0.1.1" dependencies = [ "bitflags", "built", @@ -1108,8 +1068,6 @@ dependencies = [ "julian_day_converter", "libloading", "libm", - "limbo_series", - "limbo_time", "miette", "mimalloc", "parking_lot", @@ -1122,7 +1080,7 @@ dependencies = [ "ryu", "strum", "strum_macros", - "thiserror 1.0.69", + "thiserror", "tracing", "turso_ext", "turso_macros", @@ -1133,7 +1091,7 @@ dependencies = [ [[package]] name = "turso_ext" -version = "0.1.0-pre.2" +version = "0.1.1" dependencies = [ "chrono", "getrandom 0.3.1", @@ -1142,7 +1100,7 @@ dependencies = [ [[package]] name = "turso_macros" -version = "0.1.0-pre.2" +version = "0.1.1" dependencies = [ "proc-macro2", "quote", @@ -1151,7 +1109,7 @@ dependencies = [ [[package]] name = "turso_sqlite3_parser" -version = "0.1.0-pre.2" +version = "0.1.1" dependencies = [ "bitflags", "cc", diff --git a/fuzz/fuzz_targets/cast_real.rs b/fuzz/fuzz_targets/cast_real.rs index 41fa0cbd2..adcb5d53e 100644 --- a/fuzz/fuzz_targets/cast_real.rs +++ b/fuzz/fuzz_targets/cast_real.rs @@ -1,7 +1,7 @@ #![no_main] use libfuzzer_sys::{fuzz_target, Corpus}; -use turso_core::numeric::StrToF64; use std::error::Error; +use turso_core::numeric::StrToF64; fn do_fuzz(text: String) -> Result> { let expected = { @@ -13,7 +13,7 @@ fn do_fuzz(text: String) -> Result> { let actual = turso_core::numeric::str_to_f64(&text) .map(|v| { - let (StrToF64::Fractional(non_nan) | StrToF64::Decimal(non_nan)) = v; + let (StrToF64::Fractional(non_nan) | StrToF64::Decimal(non_nan)) = v; f64::from(non_nan) }) .unwrap_or(0.0); diff --git a/fuzz/fuzz_targets/expression.rs b/fuzz/fuzz_targets/expression.rs index d7fd62d92..005d2b42b 100644 --- a/fuzz/fuzz_targets/expression.rs +++ b/fuzz/fuzz_targets/expression.rs @@ -4,7 +4,7 @@ use std::{error::Error, num::NonZero, sync::Arc}; use arbitrary::Arbitrary; use libfuzzer_sys::{fuzz_target, Corpus}; -use turso_core::{Value, IO as _}; +use turso_core::IO as _; macro_rules! str_enum { ($vis:vis enum $name:ident { $($variant:ident => $value:literal),*, }) => { @@ -63,7 +63,7 @@ str_enum! { } } -#[derive(Arbitrary, Debug, Clone)] +#[derive(Arbitrary, Debug, Clone, PartialEq)] enum Value { Null, Integer(i64), @@ -184,7 +184,7 @@ fn do_fuzz(expr: Expr) -> Result> { let found = 'value: { let io = Arc::new(turso_core::MemoryIO::new()); - let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?; + let db = turso_core::Database::open_file(io.clone(), ":memory:", false, true)?; let conn = db.connect()?; let mut stmt = conn.prepare(sql)?; @@ -206,7 +206,7 @@ fn do_fuzz(expr: Expr) -> Result> { }; assert_eq!( - Value::from(expected.clone()), + turso_core::Value::from(Value::from(expected.clone())), found.clone(), "with expression {:?}", expr, diff --git a/fuzz/fuzz_targets/schema.rs b/fuzz/fuzz_targets/schema.rs index 8edf7553b..53f3f1c73 100644 --- a/fuzz/fuzz_targets/schema.rs +++ b/fuzz/fuzz_targets/schema.rs @@ -66,10 +66,7 @@ struct ColumnDef { impl fmt::Display for ColumnDef { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let ColumnDef { - name, - r#type, - } = self; + let ColumnDef { name, r#type } = self; write!(f, "{name} {type}",)?; Ok(()) @@ -338,7 +335,7 @@ fn do_fuzz(Ops(ops): Ops) -> Result> { let rusqlite_conn = rusqlite::Connection::open_in_memory()?; let io = Arc::new(turso_core::MemoryIO::new()); - let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?; + let db = turso_core::Database::open_file(io.clone(), ":memory:", false, true)?; let limbo_conn = db.connect()?; for op in ops {