Skip to content

Commit ad6fd91

Browse files
committed
WIP: add userauth deprecated tests
1 parent 36571ef commit ad6fd91

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed

.github/workflows/go.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
- name: 'Tags: libsqlite3'
4747
run: go test -race -v -tags "libsqlite3"
4848

49+
- name: 'Tags: userauth deprecated'
50+
run: make --jobs=$(nproc) test_userauth_fails test_userauth_fails_libsqlite3
51+
4952
- name: 'Tags: full'
5053
run: go test -race -v -tags "sqlite_allow_uri_authority sqlite_app_armor sqlite_column_metadata sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_math_functions sqlite_os_trace sqlite_preupdate_hook sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_unlock_notify sqlite_vacuum_incr sqlite_vtable"
5154

Makefile

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Benchmark options
2+
NO_TESTS = ^$
3+
# BENCHMARKS = ^BenchmarkIndex('\$'|Hard|Torture|Periodic(Unicode)?)
4+
BENCH_SUITE = BenchmarkSuite
5+
BENCH_QUERY = BenchmarkSuite/.*BenchmarkQuery$
6+
BENCH_EXEC_STEP = BenchmarkSuite/.*BenchmarkExecStep$
7+
8+
# TODO: join these into a single list
9+
ALL_TEST_TAGS := sqlite_allow_uri_authority
10+
ALL_TEST_TAGS += sqlite_app_armor
11+
ALL_TEST_TAGS += sqlite_column_metadata
12+
ALL_TEST_TAGS += sqlite_foreign_keys
13+
ALL_TEST_TAGS += sqlite_fts5
14+
ALL_TEST_TAGS += sqlite_icu
15+
ALL_TEST_TAGS += sqlite_introspect
16+
ALL_TEST_TAGS += sqlite_json
17+
ALL_TEST_TAGS += sqlite_math_functions
18+
ALL_TEST_TAGS += sqlite_preupdate_hook
19+
ALL_TEST_TAGS += sqlite_secure_delete
20+
ALL_TEST_TAGS += sqlite_see
21+
ALL_TEST_TAGS += sqlite_stat4
22+
ALL_TEST_TAGS += sqlite_trace
23+
ALL_TEST_TAGS += sqlite_unlock_notify
24+
ALL_TEST_TAGS += sqlite_vacuum_incr
25+
ALL_TEST_TAGS += sqlite_vtable
26+
27+
space := $(subst ,, )
28+
comma := ,
29+
30+
ALL_TEST_TAGS_JOINED = $(subst $(space),$(comma),$(ALL_TEST_TAGS))
31+
32+
# GO_VERSION = $(shell go version | grep -oE 'go[1-9]\.[0-9]+(\.[0-9]+)?')
33+
# ifeq (,$(shell echo $(GO_VERSION_NUMBER) | grep -E 'go1\.2[2-9]'))
34+
# export GOEXPERIMENT=cgocheck2
35+
# endif
36+
37+
.PHONY: all
38+
all: build
39+
40+
.PHONY: build
41+
build:
42+
@go build -tags "libsqlite3"
43+
44+
.PHONY: test
45+
test:
46+
@GOEXPERIMENT=cgocheck2 go test -tags "libsqlite3" -v
47+
48+
.PHONY: test_all
49+
test_all:
50+
@GOEXPERIMENT=cgocheck2 go test -tags "$(ALL_TEST_TAGS_JOINED)" -v
51+
52+
# TODO: merge with the above target
53+
.PHONY: test_all_libsqlite3
54+
test_all_libsqlite3:
55+
GOEXPERIMENT=cgocheck2 go test -tags "$(ALL_TEST_TAGS_JOINED),libsqlite3" -v
56+
57+
.PHONY: qtest
58+
qtest:
59+
@GOEXPERIMENT=cgocheck2 go test -tags "libsqlite3"
60+
61+
.PHONY: short
62+
short:
63+
@go test -tags "libsqlite3" -short
64+
65+
.PHONY: testrace
66+
testrace:
67+
@GOEXPERIMENT=cgocheck2 go test -tags "libsqlite3" -race
68+
69+
.PHONY: test_userauth_fails
70+
test_userauth_fails:
71+
@./scripts/test-userauth-fails.bash
72+
73+
.PHONY: test_userauth_fails_libsqlite3
74+
test_userauth_fails_libsqlite3:
75+
@./scripts/test-userauth-fails.bash -libsqlite3
76+
77+
.PHONY: testfull
78+
testfull:
79+
@./scripts/test-full.bash -v
80+
81+
.PHONY: testfull_race
82+
testfull_race:
83+
@./scripts/test-full.bash -v -race
84+
85+
.PHONY: bench
86+
bench:
87+
@go test -tags "libsqlite3 darwin" -run $(NO_TESTS) -bench $(BENCH_SUITE) -benchmem
88+
89+
.PHONY: bench_stmt_rows
90+
bench_stmt_rows:
91+
@go test -tags "libsqlite3 darwin" -run $(NO_TESTS) -bench $(BENCH_QUERY) -benchmem
92+
93+
.PHONY: bench_exec_step
94+
bench_exec_step:
95+
@go test -tags "libsqlite3 darwin" -run $(NO_TESTS) -bench $(BENCH_EXEC_STEP) -benchmem
96+
97+
.PHONY: bench_mem
98+
bench_mem:
99+
@go test -tags "libsqlite3 darwin" -run $(NO_TESTS) \
100+
-bench $(BENCH_SUITE) \
101+
-benchmem -memprofilerate 1 -memprofile mem.out -benchtime 5s
102+
103+
.PHONY: bench_cpu
104+
bench_cpu:
105+
@go test -tags "libsqlite3 darwin" -run $(NO_TESTS) \
106+
-bench $(BENCH_SUITE) \
107+
-cpuprofile cpu.out -benchtime 5s
108+
109+
.PHONY: tags
110+
tags:
111+
@\grep -ohP '(?<=//go:build )\w+(\s+\w+)?' *.go | sort -u

scripts/test-userauth-fails.bash

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
3+
# Test that the userauth tests fail, but don't panic.
4+
# Pass "-libsqlite3" as an argument to the script to
5+
# run the tests with the "libsqlite3" build tag.
6+
7+
set -euo pipefail
8+
9+
OUT="$(mktemp -t 'go-sqlite3.XXXXXX')"
10+
trap 'rm "${OUT}"' EXIT
11+
12+
function test_sqlite_userauth() {
13+
local tags='sqlite_userauth'
14+
if (( $# > 0 )); then
15+
tags+="$(printf ',%s' "$@")"
16+
fi
17+
18+
if go test -tags "${tags}" &> "${OUT}"; then
19+
cat "${OUT}"
20+
echo >&2 ""
21+
echo >&2 "FAIL: tests passed: expected them to fail"
22+
return 2
23+
fi
24+
25+
if \grep -qF 'panic:' "${OUT}"; then
26+
cat "${OUT}"
27+
echo >&2 ""
28+
echo >&2 "FAIL: test panicked"
29+
return 2
30+
fi
31+
32+
echo "PASS"
33+
}
34+
35+
function main() {
36+
local tags=''
37+
if [[ ${1:-} == '-libsqlite3' ]]; then
38+
tags='libsqlite3'
39+
fi
40+
test_sqlite_userauth "${tags}"
41+
}
42+
43+
main "$@"

0 commit comments

Comments
 (0)