Add comprehensive fuzz testing infrastructure with 6 new targets

- Fix numpy.c: tautology bug (|| → &&), infinite loop, and missing
  sqlite3_vec_numpy_init call
- Replace tests/fuzz/Makefile: auto-detect clang, add UBSAN, macOS
  ld_classic workaround, generic build rules for all 10 targets
- Add 6 new fuzz targets: shadow-corrupt (corrupted shadow tables),
  vec0-operations (INSERT/DELETE/query sequences), scalar-functions
  (all 18 SQL scalar functions), vec0-create-full (CREATE + lifecycle),
  metadata-columns (metadata/auxiliary columns), vec-each (vec_each TVF)
- Add seed corpora for shadow-corrupt, vec0-operations, exec, and json
- Add fuzz-build/fuzz-quick/fuzz-long targets to root Makefile

All 10 targets verified building and running on macOS ARM (Apple Silicon).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Garcia 2026-03-02 20:33:05 -08:00
parent 9a6bf96b92
commit a61d45183b
24 changed files with 600 additions and 47 deletions

View file

@ -192,6 +192,39 @@ test-loadable-watch:
test-unit:
$(CC) -DSQLITE_CORE -DSQLITE_VEC_TEST tests/test-unit.c sqlite-vec.c vendor/sqlite3.c -I./ -Ivendor -o $(prefix)/test-unit && $(prefix)/test-unit
fuzz-build:
$(MAKE) -C tests/fuzz all
fuzz-quick: fuzz-build
@echo "Running all fuzz targets for 30 seconds each..."
@for target in tests/fuzz/targets/*; do \
[ -f "$$target" ] && [ -x "$$target" ] || continue; \
name=$$(basename $$target); \
echo "=== Fuzzing $$name ==="; \
corpus="tests/fuzz/corpus/$$name"; \
mkdir -p "$$corpus"; \
dict="tests/fuzz/$${name//_/-}.dict"; \
dict_flag=""; \
[ -f "$$dict" ] && dict_flag="-dict=$$dict"; \
"$$target" $$dict_flag \
-max_total_time=30 "$$corpus" 2>&1 || true; \
done
fuzz-long: fuzz-build
@echo "Running all fuzz targets for 5 minutes each..."
@for target in tests/fuzz/targets/*; do \
[ -f "$$target" ] && [ -x "$$target" ] || continue; \
name=$$(basename $$target); \
echo "=== Fuzzing $$name ==="; \
corpus="tests/fuzz/corpus/$$name"; \
mkdir -p "$$corpus"; \
dict="tests/fuzz/$${name//_/-}.dict"; \
dict_flag=""; \
[ -f "$$dict" ] && dict_flag="-dict=$$dict"; \
"$$target" $$dict_flag \
-max_total_time=300 "$$corpus" 2>&1 || true; \
done
site-dev:
npm --prefix site run dev