Skip to content

[Bug]: Test Infrastructure Is Broken #8

@dirtyfilthy

Description

@dirtyfilthy

Pre-submission Checklist

  • I have searched existing issues to ensure this bug hasn't been reported
  • I have read the documentation
  • I am using a supported platform (Linux x86_64)

Version

001122d from main

Platform

Ubuntu 20.04

Bug Description

1. Extension Loading Path Issue

Problem: SQLite's sqlite3_load_extension() automatically appends .so (or .dylib on macOS) to extension paths. Tests were passing paths like "../build/libgraph.so", causing SQLite to attempt loading "../build/libgraph.so.so", which failed.

Impact: All 52 test files (4 C tests, 37 TCK tests, 11 Python tests) failed to load the extension.

Affected Files: 58 files total

  • tests/generate_tck_tests.py (generator)
  • 4 C test files
  • 37 TCK test files
  • 11 Python test files
  • 3 debug files
  • 1 generator script

2. Makefile References Non-Existent Tests

Problem: tests/Makefile referenced test files that don't exist:

  • BASIC_TESTS listed: test_loading, test_insert_nodes, test_query_nodes
  • EXTENDED_TESTS listed many non-existent files

Impact: make test failed because it tried to build missing test files.

Actual Test Files: Only 4 tests exist:

  • test_match_return_simple
  • test_storage
  • test_virtual_table_crud
  • test_performance

3. Dynamic Symbol Resolution Issue

Problem: Tests statically linked SQLite but dynamically loaded the extension. The extension couldn't resolve SQLite symbols (e.g., sqlite3_free) because they weren't exported from the test binary.

Error: undefined symbol: sqlite3_free

Impact: All tests failed immediately when trying to load the extension, even with correct paths.

Steps to Reproduce

# Check Makefile LDFLAGS (should not include -Wl,--export-dynamic)
grep "LDFLAGS" tests/Makefile

# Compile test without export-dynamic flag
cd tests
gcc -I../include -I../src -I../_deps/sqlite-src -I../_deps/Unity-2.5.2/src \
    -g -O0 -std=gnu99 -fPIC -DSQLITE_ENABLE_LOAD_EXTENSION=1 \
    test_match_return_simple.c -o test_match_return_simple \
    ../build/libunity.a ../build/libsqlite3.a ../build/libgraph_static.a \
    -lm -ldl -lpthread
./test_match_return_simple

# Verify symbols are not exported
readelf -s test_match_return_simple | grep sqlite3_free

Bug #1: Extension Loading Path Issue

# Check for incorrect extension paths
grep -n "libgraph\.so" tests/test_match_return_simple.c

# Compile and run test
cd tests
gcc -I../include -I../src -I../_deps/sqlite-src -I../_deps/Unity-2.5.2/src \
    -g -O0 -std=gnu99 -fPIC -DSQLITE_ENABLE_LOAD_EXTENSION=1 \
    test_match_return_simple.c -o test_match_return_simple \
    ../build/libunity.a ../build/libsqlite3.a ../build/libgraph_static.a \
    -lm -ldl -lpthread -Wl,--export-dynamic
./test_match_return_simple

# Verify issue exists in multiple files
grep -r "libgraph\.so" --include="*.c" --include="*.py" tests/

Bug #2: Makefile References Non-Existent Tests

# Check Makefile for non-existent test references
grep "BASIC_TESTS\|EXTENDED_TESTS" tests/Makefile

# List actual test files
ls tests/test_*.c

# Attempt to build tests
cd tests && make test-basic

Bug #3: Dynamic Symbol Resolution Issue

# Check Makefile LDFLAGS (should not include -Wl,--export-dynamic)
grep "LDFLAGS" tests/Makefile

# Compile test without export-dynamic flag
cd tests
gcc -I../include -I../src -I../_deps/sqlite-src -I../_deps/Unity-2.5.2/src \
    -g -O0 -std=gnu99 -fPIC -DSQLITE_ENABLE_LOAD_EXTENSION=1 \
    test_match_return_simple.c -o test_match_return_simple \
    ../build/libunity.a ../build/libsqlite3.a ../build/libgraph_static.a \
    -lm -ldl -lpthread
./test_match_return_simple

# Verify symbols are not exported
readelf -s test_match_return_simple | grep sqlite3_free

Code Sample

Error Message / Stack Trace

Expected Behavior

tests run as expected with "make test"

Actual Behavior

~/sqlite-graph$ make test

make: *** No rule to make target 'test_loading.c', needed by 'test_loading'.  Stop.

Environment Details

SQLite version: 3.46.1 (system library)
Extension: sqlite-graph (commit 001122d on main branch)
OS: Linux (aarch64)

Additional Context

No response

Severity

  • This is a critical bug (crashes, data loss)
  • This is a major bug (significant functionality broken)
  • This is a minor bug (minor functionality affected)
  • This is a cosmetic issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions