Skip to content

eBPF-based security platform

testing: run the backend's SQL tests as a tier of make tests

John Fastabend14d4ac430d2d
diff --git a/.agents/skills/pre-submit/SKILL.md b/.agents/skills/pre-submit/SKILL.md
index b702025e..542b0a9b 100644
--- a/.agents/skills/pre-submit/SKILL.md
+++ b/.agents/skills/pre-submit/SKILL.md
@@ -61,15 +61,19 @@ make -B && make -B shirudo-build && make -B quote-check &&
make -B CC=clang && make -B CC=clang shirudo-build &&
make -B CC=clang quote-check &&
make -B -f Makefile.shirudo CC=clang test-helpers
-make tests VM=0 SANITIZE=address,undefined # CC=gcc and CC=clang,
+make tests VM=0 BACKEND=0 SANITIZE=address,undefined # CC=gcc and CC=clang,
# one worktree each
-make tests VM=0 SANITIZE=thread CC=clang # and TSan in a third
+make tests VM=0 BACKEND=0 SANITIZE=thread CC=clang # and TSan in a third
sh .github/scripts/msan-deps.sh && # MSan, a worktree of
sh .github/scripts/msan-tests.sh 60 # its own
make -C testing fuzz FUZZ_SECONDS=60
make proofs-cbmc CHANGED=$range # the proofs that read
make proofs-lean4 # what the series changed
make -C testing functional/<family> # each family it touches
+make -C testing backend # after a change to
+ # tools/backend
+make -C tools/xtop tests # after one to tools/xtop;
+ # not in make tests
```
A warning fails every build. Fix it rather than silence it; `WERROR=0`
diff --git a/.agents/skills/testing/SKILL.md b/.agents/skills/testing/SKILL.md
index 06d02de2..d1de605a 100644
--- a/.agents/skills/testing/SKILL.md
+++ b/.agents/skills/testing/SKILL.md
@@ -15,18 +15,21 @@ covers and changes with every test added or removed.
```sh
make tests # every test, as CI runs them
-make -C testing unit|ci-checks|functional|end2end
+make -C testing unit|ci-checks|functional|end2end|backend
make -C testing unit/<suite> # one unit suite
make -C testing functional/<family> # one family, its VM tests too
make tests VM=0 # without the target tests
-make tests VM=0 SANITIZE=address,undefined # CI: once with gcc, once with clang
-make tests VM=0 SANITIZE=thread CC=clang # CI: TSan, for threads and handlers
+make tests BACKEND=0 # without the backend's SQL tests
+make tests VM=0 BACKEND=0 SANITIZE=address,undefined # CI: once with gcc, once with clang
+make tests VM=0 BACKEND=0 SANITIZE=thread CC=clang # CI: TSan, for threads and handlers
sh .github/scripts/msan-deps.sh # MSan: instrumented libraries once,
sh .github/scripts/msan-tests.sh [60] # then unit and fuzz from a clean tree
make -C testing fuzz [FUZZ_SECONDS=60] [FUZZERS=<target>...]
.github/scripts/afl-deps.sh # AFL++ for clang 23, into build/afl
PATH=$PWD/build/afl/bin:$PATH make -C testing afl [AFL_SECONDS=600]
make -C testing help
+tools/backend/test/run.sh <name>... # only the SQL tests named
+make -C tools/xtop tests # xtop: tsc and bun test, needs bun
```
The end2end tier runs t9107, and t9109 to t9112 on the host, against
diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml
index c1e4b119..100ab437 100644
--- a/.github/workflows/sanitizers.yml
+++ b/.github/workflows/sanitizers.yml
@@ -87,7 +87,7 @@ jobs:
make -j4 SANITIZE=${{ matrix.sanitize }}
make SANITIZE=${{ matrix.sanitize }} shirudo-build
make -C testing SANITIZE=${{ matrix.sanitize }} test-helpers
- make tests VM=0 SANITIZE=${{ matrix.sanitize }}
+ make tests VM=0 BACKEND=0 SANITIZE=${{ matrix.sanitize }}
- name: Save the sanitizer OpenSSL build
if: always() && steps.sanitizer-openssl.outputs.cache-hit != 'true' && hashFiles('build/sanitizer-openssl/lib/libcrypto.so') != ''
diff --git a/AGENTS.md b/AGENTS.md
index 0a33fce6..21b4ae70 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -346,7 +346,10 @@ one usually still compiles and passes tests.
by `testing/unit/<m>.c`, a parser of input from outside the host has a
fuzz target, and a shell test `t<F><K><NN>` lives in its family's
directory (`Documentation/contribute/testing/testing.rst`). The
- `testing` and `fuzz-target` skills say how to run and add them.
+ `testing` and `fuzz-target` skills say how to run and add them. Its
+ last tier is the SQL tests of `tools/backend`, which need docker or
+ podman (`BACKEND=0` leaves them out). The tests of xtop are not part
+ of it: `make -C tools/xtop tests`, which needs bun, runs them.
- `make proofs` runs the CBMC proofs of `testing/proofs/cbmc/`, which
check parsers and emitters for every input within a bound, and the Lean
4 proofs of `testing/proofs/lean4/`, which prove models of algorithms
diff --git a/Documentation/contribute/testing/testing.rst b/Documentation/contribute/testing/testing.rst
index 75893350..830a76bc 100644
--- a/Documentation/contribute/testing/testing.rst
+++ b/Documentation/contribute/testing/testing.rst
@@ -107,11 +107,13 @@ Test tiers
* - Backend
- :src:`tools/backend/test/`
- On the build host, against a ClickHouse container
- - ``make -C tools/backend tests``
+ - ``make -C testing backend``
``make tests`` in the checkout root, or ``make -C testing``, runs the
-unit, CI check, functional and end-to-end tiers in that order. The fuzz
-targets, the proofs and the backend tests run on their own. CI runs the
+unit, CI check, functional, end-to-end and backend tiers in that order.
+``BACKEND=0`` leaves out the backend tier, which needs docker or podman
+and reads no C: the sanitizer runs pass it. The fuzz targets and the
+proofs run on their own. CI runs the
proofs only after a push to main, in the ``Proofs`` workflow, never on a
pull request: :doc:`proofs` says which to run for a change.
diff --git a/testing/Makefile b/testing/Makefile
index 32130ef5..75f08301 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -27,7 +27,7 @@ test-vm-arch = $(shell TEST_VM_ARCH='$(TEST_VM_ARCH)'; \
. $(ROOT)/testing/vm/arch.sh && printf '%s' "$$$(1)")
.DEFAULT_GOAL := all
-.PHONY: all help clean unit ci-checks functional end2end build-operator build-unit kernel-btf \
+.PHONY: all help clean unit ci-checks functional end2end backend build-operator build-unit kernel-btf \
test-helpers \
fuzz afl bundle test-vm-bundle require-vm-kernel vm vm-console vm-ssh vm-enroll vm-sbom vm-stop vm-clean \
vm-operator-end2end
@@ -260,8 +260,10 @@ endef
# a target number (t?1??) runs in a VM its family boots from the bundle, so
# no test finds what another family left behind; tpm boots a second VM
# before init, without the initrd, for the TPM register tests. VM=0 leaves
-# out every test that boots a VM.
+# out every test that boots a VM. BACKEND=0 leaves out the SQL tests of
+# tools/backend, which need docker or podman and read no C.
VM ?= 1
+BACKEND ?= 1
UNIT_SUITES := $(sort $(basename $(notdir $(filter-out %/unit.c, \
$(wildcard $(ROOT)/testing/unit/*.c)))))
family-list = $(shell cd $(ROOT)/testing/functional && \
@@ -281,10 +283,14 @@ all:
+$(Q)$(MAKE) ci-checks
+$(Q)$(MAKE) functional
+$(Q)$(MAKE) end2end
+ +$(Q)$(MAKE) backend
unit: build-unit
$(Q)$(ROOT)/testing/run-tests.sh unit
+backend:
+ +$(Q)$(if $(filter 0,$(BACKEND)),:,$(MAKE) -C $(ROOT)/tools/backend tests)
+
$(addprefix unit/,$(UNIT_SUITES)): unit/%: build-unit
$(Q)$(ROOT)/testing/run-tests.sh unit/$*
@@ -422,9 +428,11 @@ help:
' make -C testing ci-checks the scripts CI runs' \
' make -C testing functional[/<family>] families: $(FAMILIES)' \
' make -C testing end2end' \
+ ' make -C testing backend the SQL tests of tools/backend' \
' TEST_FILTER=<regex> selects test filenames (empty runs everything).' \
' VM=0 leaves out the tests that boot a VM, which need root;' \
' make -j boots several at once.' \
+ ' BACKEND=0 leaves out the backend tests, which need docker or podman.' \
' make -C testing fuzz [FUZZ_SECONDS=60] [FUZZ_CORPUS=<dir>] [FUZZERS=<target>...]' \
' make -C testing afl [AFL_SECONDS=600] [FUZZ_CORPUS=<dir>] [FUZZERS=<target>...]' \
' make -C testing vm, vm-console, vm-ssh, vm-enroll, vm-sbom, vm-stop, or vm-clean' \