Skip to content

eBPF-based security platform

testing: group kernel-obs tests

John Fastabendde09beaa85a1
diff --git a/testing/dns_obs_matrix.py b/testing/kernel-obs/dns_obs_matrix.py
similarity index 100%
rename from testing/dns_obs_matrix.py
rename to testing/kernel-obs/dns_obs_matrix.py
diff --git a/testing/kernel_obs_events.py b/testing/kernel-obs/kernel_obs_events.py
similarity index 100%
rename from testing/kernel_obs_events.py
rename to testing/kernel-obs/kernel_obs_events.py
diff --git a/testing/t0019-dns-observability-matrix.sh b/testing/kernel-obs/t0019-dns-observability-matrix.sh
similarity index 78%
rename from testing/t0019-dns-observability-matrix.sh
rename to testing/kernel-obs/t0019-dns-observability-matrix.sh
index a8ec699a..aef27577 100755
--- a/testing/t0019-dns-observability-matrix.sh
+++ b/testing/kernel-obs/t0019-dns-observability-matrix.sh
@@ -2,13 +2,13 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./test-lib.sh
command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
test_expect_success 'DNS observability packet matrix and batch ABI are valid' '
- python3 dns_obs_matrix.py --self-test
+ python3 kernel-obs/dns_obs_matrix.py --self-test
'
test_done
diff --git a/testing/t1210-kernel-obs.sh b/testing/kernel-obs/t1210-kernel-obs.sh
similarity index 96%
rename from testing/t1210-kernel-obs.sh
rename to testing/kernel-obs/t1210-kernel-obs.sh
index 9ca024a8..e724179d 100755
--- a/testing/t1210-kernel-obs.sh
+++ b/testing/kernel-obs/t1210-kernel-obs.sh
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./integration-lib.sh
target_guard
command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
@@ -190,16 +190,16 @@ test_expect_success 'kernel-obs upatch loads with seven serializers' '
'
test_expect_success 'exec, net, listen, DNS, privilege and file events produce records' '
- python3 kernel_obs_events.py all &&
- python3 kernel_obs_events.py dns-long &&
- python3 kernel_obs_events.py dns-many &&
+ python3 kernel-obs/kernel_obs_events.py all &&
+ python3 kernel-obs/kernel_obs_events.py dns-long &&
+ python3 kernel-obs/kernel_obs_events.py dns-many &&
export_maps "$WORK/events.ndjson" &&
python3 "$WORK/check.py" "$WORK/events.ndjson" &&
python3 "$WORK/check_events.py" "$WORK/events.ndjson"
'
test_expect_success 'watched destinations are recorded with the metric' '
- python3 kernel_obs_events.py watch &&
+ python3 kernel-obs/kernel_obs_events.py watch &&
export_maps "$WORK/watch.ndjson" &&
python3 "$WORK/check_watch.py" "$WORK/watch.ndjson"
'
@@ -210,7 +210,7 @@ test_expect_success 'an export drains the tables' '
'
test_expect_success 'only the touched tables carry records' '
- python3 kernel_obs_events.py exec &&
+ python3 kernel-obs/kernel_obs_events.py exec &&
export_maps "$WORK/exec-only.ndjson" &&
python3 "$WORK/check_exec_only.py" "$WORK/exec-only.ndjson"
'
diff --git a/testing/t1211-kernel-obs-dns-matrix.sh b/testing/kernel-obs/t1211-kernel-obs-dns-matrix.sh
similarity index 91%
rename from testing/t1211-kernel-obs-dns-matrix.sh
rename to testing/kernel-obs/t1211-kernel-obs-dns-matrix.sh
index a318a1a7..28db5f03 100755
--- a/testing/t1211-kernel-obs-dns-matrix.sh
+++ b/testing/kernel-obs/t1211-kernel-obs-dns-matrix.sh
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2026 Authors of shirudo
-cd "$(dirname "$0")"
+cd "$(dirname "$0")/.."
. ./integration-lib.sh
target_guard
command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
@@ -54,7 +54,7 @@ load_observability()
test_expect_success 'DNS matrix helper and generator are available' '
[ -x "$RUNNER" ] &&
- python3 dns_obs_matrix.py --self-test >"$WORK/self-test.log" 2>&1
+ python3 kernel-obs/dns_obs_matrix.py --self-test >"$WORK/self-test.log" 2>&1
'
test_expect_success 'kernel-obs DNS programs load for packet tests' '
@@ -63,7 +63,7 @@ test_expect_success 'kernel-obs DNS programs load for packet tests' '
'
test_expect_success 'DNS UDP deterministic packet matrix passes' '
- python3 dns_obs_matrix.py --deterministic --known-gaps \
+ python3 kernel-obs/dns_obs_matrix.py --deterministic --known-gaps \
--runner "$RUNNER" --shirudo "$SHIRUDO_BIN" --upatch "$NAME" \
--work "$WORK" >"$WORK/matrix.log" 2>&1 || save_failure
'
@@ -74,7 +74,7 @@ fi
if [ "${TEST_VM_DNS_FUZZ:-0}" = 1 ]; then
test_expect_success 'DNS UDP seeded mutation fuzz run passes' '
- python3 dns_obs_matrix.py --fuzz \
+ python3 kernel-obs/dns_obs_matrix.py --fuzz \
--runner "$RUNNER" --work "$WORK" \
--seed "${TEST_VM_DNS_FUZZ_SEED:-0x53484952}" \
--cases "${TEST_VM_DNS_FUZZ_CASES:-5000}" \
diff --git a/testing/run-target-obs-tests.sh b/testing/run-target-obs-tests.sh
index d499040c..8b93b95f 100755
--- a/testing/run-target-obs-tests.sh
+++ b/testing/run-target-obs-tests.sh
@@ -9,8 +9,8 @@ cd "$(dirname "$0")"
fail=0
: "${SHIRUDO_TEST_SUITE_FAILURES_FILE:=}"
for test_script in \
- t1210-kernel-obs.sh \
- t1211-kernel-obs-dns-matrix.sh
+ kernel-obs/t1210-kernel-obs.sh \
+ kernel-obs/t1211-kernel-obs-dns-matrix.sh
do
if sh "$test_script"; then
:
diff --git a/testing/run-tests.sh b/testing/run-tests.sh
index f9c180ee..3a47176e 100755
--- a/testing/run-tests.sh
+++ b/testing/run-tests.sh
@@ -3,7 +3,8 @@
# Copyright (c) 2026 Authors of shirudo
#
# testing/run-tests.sh -- discover and run every t0xxx operator test in this
-# directory, prap-style. Target tests are listed by run-target-tests.sh.
+# directory and its named test groups. Target tests are listed by
+# run-target-tests.sh.
# CI-friendly; sets non-zero exit if any test
# fails.
@@ -27,6 +28,19 @@ for t in t0[0-9][0-9][0-9]-*.sh; do
fi
done
+for t in kernel-obs/t0[0-9][0-9][0-9]-*.sh; do
+ [ -e "$t" ] || continue
+ found=1
+ if sh "$t"; then
+ :
+ else
+ fail=$((fail + 1))
+ if [ -n "$SHIRUDO_TEST_SUITE_FAILURES_FILE" ]; then
+ printf '%s\n' "$t" >>"$SHIRUDO_TEST_SUITE_FAILURES_FILE" 2>/dev/null || :
+ fi
+ fi
+done
+
if [ "$found" -eq 0 ]; then
echo "# no tests yet" >&2
fi
diff --git a/upatches/kernel-obs/dns.todo b/upatches/kernel-obs/dns.todo
index 5b5afb5a..8d1509c2 100644
--- a/upatches/kernel-obs/dns.todo
+++ b/upatches/kernel-obs/dns.todo
@@ -5,7 +5,7 @@ the network-namespace cookie, address family, client/resolver addresses
and ports, and transaction ID, and attributes the answer to the querying
socket's owner. The items below are the remaining parser and
correlation gaps. Each behavior change should promote its corresponding
-case in `testing/dns_obs_matrix.py` from a known-gap probe to a gating
+case in `testing/kernel-obs/dns_obs_matrix.py` from a known-gap probe to a gating
test.
## Matching and response integrity