Skip to content

Commit e4af810

Browse files
Adapt the suite and rusqlite pin to SQLite3MC 2.6.1
1 parent c464cf4 commit e4af810

2 files changed

Lines changed: 14 additions & 19 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ jobs:
195195
runs-on: ubuntu-latest
196196
env:
197197
# Head of LucaCappelletti94/rusqlite feat/sqlite3mc-src, moved by hand when rusqlite-pin.yml goes red.
198-
RUSQLITE_REV: 15c7356af30f42c5938b48217a240e61203eac50
198+
RUSQLITE_REV: a2b5c62dc8df82b49a68ff1c2fa022d9c15b4149
199199
steps:
200200
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
201201
with:

‎suite/run.sh‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ memsubsys2-4.1 SQLite3MC's cipher tables stay allocated between sqlite
1919
memsubsys2-4.3 SQLite3MC's cipher tables stay allocated between sqlite3_initialize and sqlite3_shutdown
2020
memsubsys2-4.4 SQLite3MC's cipher tables stay allocated between sqlite3_initialize and sqlite3_shutdown
2121
memsubsys2-4.11 SQLite3MC's cipher tables stay allocated between sqlite3_initialize and sqlite3_shutdown
22-
backup2-10 mcIoRead drops read errors of the real file, fixed by SQLite3MC pull request 272 after 2.5.1
2322
EOF
2423
)
2524
# SQLite test files that crash through a named SQLite3MC defect, each with its reason.
2625
EXPECTED_CRASHES=$(cat <<'EOF'
27-
init sqlite3mcRegisterCipher writes through an unchecked sqlite3_malloc when an allocation fails
28-
quota sqlite3mcCloneCodecParameterTable writes through an unchecked sqlite3_malloc when an allocation fails
29-
multiplex sqlite3mcCloneCodecParameterTable writes through an unchecked sqlite3_malloc when an allocation fails
26+
shared9 2.6.0's temp-file encryption stores the opening connection in the shared pager, which outlives that connection
3027
EOF
3128
)
3229
# SQLite test files not run, each with its reason.
@@ -45,6 +42,9 @@ if [ -n "${SANITIZE:-}" ]; then
4542
crash8 its simulated crashes end child processes holding memory, which LeakSanitizer reports on SQLite alone too
4643
EOF
4744
)
45+
# Plain builds read shared9's freed connection handle there without faulting.
46+
EXPECTED_CRASHES=$(printf '%s\n%s' "$EXPECTED_CRASHES" \
47+
"vtab_shared reads shared9's freed connection handle, which only the sanitizer catches")
4848
fi
4949

5050
# A clean sanitizer run only counts if the binary is really instrumented.
@@ -76,9 +76,11 @@ git -C "$WORK/mc" fetch --quiet --depth 1 https://github.com/utelle/SQLite3Multi
7676
git -C "$WORK/mc" archive "$commit" test | tar x -C "$WORK/mc"
7777
failed=""
7878
# Upstream never checks the output, so its results, without the echoed script lines, are compared here.
79+
# Their mc_* information pragmas name the host CPU's features, so their lines are dropped from each script.
7980
while read -r name db script; do
8081
echo "== $name"
81-
(cd "$WORK/mc" && "$WORK/sqlite3mc" "$db" ".read test/$script" 2>&1 | grep -vxF -f "test/$script") || true
82+
grep -viE '^pragma mc_(aes_info|chacha20_hwaccel|cpu_info)\b' "$WORK/mc/test/$script" > "$WORK/mc/test/host-free.sql"
83+
(cd "$WORK/mc" && "$WORK/sqlite3mc" "$db" ".read test/host-free.sql" 2>&1 | grep -vxF -f test/host-free.sql) || true
8284
done > "$WORK/sqlite3mc.out" <<'EOF'
8385
test1 test1.db3 test1.sql
8486
test2 test2.db3 test2.sql
@@ -151,27 +153,20 @@ awk '$1 == "F" { print $3 " *" $2; print "file " $2 }' manifest | sort | cmp -s
151153
# TCL_LIB names the tclConfig.sh directory when configure cannot find it.
152154
CC="$CC" ./configure ${TCL_LIB:+--with-tcl="$TCL_LIB"} > configure.log
153155
make sqlite3.c > make.log
154-
# testfixture reaches SQLite internals through -DSQLITE_PRIVATE="", which the shipped amalgamation rejects by
155-
# defining sqlite3mcCodecAttach static against its SQLITE_PRIVATE declaration. The copy drops that one static,
156-
# as SQLite3MC pull request 276 proposes, and the run stops once a release no longer carries it.
157-
line=$(grep -n -x 'sqlite3mcCodecAttach(sqlite3\* db, int nDb, const char\* zPath, const void\* zKey, int nKey)' "$SHIPPED" | cut -d: -f1)
158-
if [ -z "$line" ] || [ "$(sed -n "$((line - 1))p" "$SHIPPED")" != "static int" ]; then
159-
echo "sqlite3mcCodecAttach is no longer defined static, so drop its edit from suite/run.sh" >&2
160-
exit 1
161-
fi
162-
sed "$((line - 1))s/^static int$/SQLITE_PRIVATE int/" "$SHIPPED" > sqlite3.c
163-
[ "$(diff "$SHIPPED" sqlite3.c | grep -c '^[<>]')" -eq 2 ] || { echo "the testfixture copy differs by more than one line" >&2; exit 1; }
164-
make testfixture CC="$CC" CFLAGS="$OPT" LDFLAGS="${SANITIZE:+$OPT}" > testfixture.log 2>&1
156+
cp "$SHIPPED" sqlite3.c
157+
# The test sources fit their temp-store expectations to the compile-time SQLITE_TEMP_STORE, so they see the amalgamation's.
158+
temp_store=$(awk '/^#ifndef SQLITE_TEMP_STORE$/{getline; print $3; exit}' "$SHIPPED")
159+
make testfixture CC="$CC" CFLAGS="$OPT ${temp_store:+-DSQLITE_TEMP_STORE=$temp_store}" LDFLAGS="${SANITIZE:+$OPT}" > testfixture.log 2>&1
165160
instrumented testfixture
166161
printf 'sqlite3 db :memory:\nputs [db one {SELECT sqlite3mc_version()}]\n' > probe.tcl
167162
# A testfixture that cannot open a database runs no test, so its own report ends the run.
168163
tested=$(./testfixture probe.tcl) || { echo "Failed:$failed testfixture" >&2; exit 1; }
169164
echo "Testing $tested with SQLite's veryquick suite"
170165

171166
skips=$(echo "$SKIP_FILES" | awk 'NF { printf " ~%s.test", $1 }')
167+
# The testrunner exits nonzero when any file does, and the cipher tables make every file exit nonzero, so verdict.awk judges.
172168
# shellcheck disable=SC2086
173-
./testfixture test/testrunner.tcl veryquick --jobs "$(nproc)" $skips > testrunner.out 2>&1 ||
174-
{ tail -n 40 testrunner.out; echo "Failed:$failed testrunner" >&2; exit 1; }
169+
./testfixture test/testrunner.tcl veryquick --jobs "$(nproc)" $skips > testrunner.out 2>&1 || true
175170
for name in $(echo "$SKIP_FILES" | awk '{ print $1 }'); do echo "skip $name"; done
176171
awk -v failures="$(echo "$EXPECTED_FAILURES" | awk '{ print $1 }')" \
177172
-v crashes="$(echo "$EXPECTED_CRASHES" | awk '{ print $1 }')" \

0 commit comments

Comments
 (0)