Testing the Linux sensors
This page is published from the agent repository. Edit on GitHub View source
The Linux sensors are tested at four levels. Only the first two run on every pull request; loading probes needs a privileged kernel, which CI runners do not offer.
1. Unit tests (every CI leg)
cargo test --workspace --exclude sensor-linux-ebpf runs them. Code is split so that what can be
tested without a kernel is pure and compiles on every OS:
| Pure module | What its tests pin |
|---|---|
normalize.rs | Every wire → schema mapping; open-flag masking; argv truth table; rename path resolution; FILETIME conversion |
proc.rs | cmdline/environ/stat parsing, argv windows to tokens, comm with spaces and ) |
btf.rs | Synthetic BTF blobs, refusal of truncated or incomplete BTF, the running kernel's BTF when present |
syscall.rs | Dispatch handler ids unique and in range |
parent_image.rs, sensor-linux-container, unit_procs.rs | Caches and scans over fake /proc and cgroup trees, injected liveness tests |
dns_udp.rs, tls_client_hello.rs | Wire parsers on valid, truncated and hostile input |
path_filter.rs | The filter's decision table, run as ordinary Rust |
| audit, netlink, journal, logs, procmem, uprobes | Parsers and mappings on captured and synthetic input |
The eBPF crate itself has no tests: it is no_std for a BPF target. Logic it shares with userspace
lives in the wire crate so it can be tested there (is_filtered_path, the pending-exit packing,
parse_exec_record).
Kernel-dependent tests skip themselves rather than fail when the host cannot run them (no
journalctl, no root, no BPF-LSM).
2. Build with embedded probes (every CI run)
The test job has no bpf-linker, so the probes are not compiled there. A separate linux-ebpf
job installs the pinned nightly and bpf-linker, runs clippy on sensor-linux,
sensor-linux-uprobes and agent with the probes embedded, and fails if either crate was built
without its embedded object. This catches code that is only dead, or only broken, in one of the two
build variants.
3. Parser robustness and fuzzing
Every parser of bytes that come from outside the agent has a never-panic contract: a panic on a drain path kills the sensor.
| Parser | Deterministic suite | Fuzz target |
|---|---|---|
parse_exec_record | wire/tests/exec_record.rs | exec_record_parse |
parse_audit_message | audit/tests/robustness.rs | audit_parse |
DiagMsg, ProcEvent, ConntrackFlow, netlink_messages (framing) | netlink/tests/robustness.rs | netlink_parse |
| access-log and MySQL parsers | unit tests | logs_parse |
The deterministic suites use a seeded LCG, so they are reproducible without a fuzzer. The
scheduled fuzz workflow currently runs audit_parse and netlink_parse; the other two targets run
locally with cargo +nightly fuzz run --fuzz-dir tests/fuzz <target> (see tests/fuzz/README.md).
4. Live tests on a lab host
These need root and a real kernel:
agent status: loads the embedded object and every raw tracepoint program through the verifier without attaching; exits non-zero on any rejection. The first check on a new kernel.apps/agent/tests/lsm_io_uring_evasion.rs: thefile_openhook fires for anio_uringwrite (needs BPF-LSM andfio).apps/agent/tests/probe_open_synthetic_bits.rs: no syntheticFLAG_*bit survives normalization of a probe-shaped open (runs without root; lives in the agent because it needs the normalizer and the rules).examples/accept_map_pressure.rsandexamples/pending_syscall_exit_pressure.rs: thousands of threads blocked inaccept()must not blind lateraccept,memfd_createorrecvfromevents. The load runs in child processes, because the sensor drops events from its own pid. Each file's header gives the build and run commands, including theulimit -nneeded.
Checklist for a probe change
cargo testfor the pure parts andcargo clippywith embedded probes.- On a lab VM:
agent statuson the oldest kernel in the matrix (5.14/5.15 verifiers reject what newer ones accept), then a real run producing the event. - If a new byte parser was added: a never-panic suite in the crate's
tests/and a fuzz target.