feat: DDP frame sync over UDP broadcast, DDP acks, DDP enable setting

- Driver acks each completed DDP frame; the test waits for the acks before broadcasting the sync.
- Sync listener on UDP 4049: a frame is held until the next sync, then shown.
- DDP pixels are shown at full brightness, ignoring the device brightness settings.
- "DDP and sync receive on" setting (NVS, network API, web UI); off ignores DDP and sync packets.
- ddp_test.py: finds devices on the subnet, drives them in lockstep at a fixed rate, runs animations.
- /api/ddp reports sync counters for diagnosis.
- Includes in-progress WebSocket, multi-driver web UI and Wi-Fi work from the same tree.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Haiku 5.5 committed 2026-11-11 14:10:55 +13:00
1 parent 47f4eba0d6
commit 4cd3bc7973
294 files changed
+48954 -301

No files matched your search

@@ -0,0 +1,81 @@
# mDNS host unit tests and fuzzing
This directory builds the mDNS component as a Linux host binary with stubs for ESP-IDF networking. It supports two modes:
- **Unit tests** — Unity/CMock regression tests (ASan/UBSan enabled)
- **Fuzzing** — AFL++ harness that feeds random packets into the receive path
## Prerequisites
- ESP-IDF installed and `IDF_PATH` set (`. $IDF_PATH/export.sh`)
- `libbsd-dev`
- For unit tests: `ruby` (CMock code generation)
- For fuzzing: AFL++ (`afl-cc`, `afl-fuzz`) and `dnslib` (`pip install dnslib`)
From the repository root:
```bash
cd components/mdns/tests/host_unit_test
```
Run `idf.py reconfigure` once before building. This generates `build/config/` headers used by the host build.
## Unit tests
Available test suites (pass one to `-DUNIT_TESTS=`):
| Suite | Description |
|-------|-------------|
| `test_receiver` | Packet receive / parse path |
| `test_sender` | Packet send path |
| `test_browse` | Browse lifecycle, cache replay, service filtering, goodbye/rediscovery |
| `test_cache` | Cached record insert/update/remove, sync batching, and result projection |
Example — build and run the receiver tests:
```bash
. $IDF_PATH/export.sh
idf.py reconfigure
mkdir -p build2 && cd build2
cmake -DUNIT_TESTS=test_receiver ..
cmake --build .
ctest --extra-verbose
```
Or run the binary directly:
```bash
./mdns_host_unit_test --test
```
Repeat with `-DUNIT_TESTS=test_sender` or `-DUNIT_TESTS=test_browse` in a separate build directory.
## Fuzzer tests
Build the AFL-instrumented harness (no `-DUNIT_TESTS`; uses `main.c`):
```bash
export IDF_PATH=/path/to/esp-idf # required in the fuzz container
cd input && python generate_cases.py && cd ..
cmake -B build2 -S . -G Ninja -DCMAKE_C_COMPILER=afl-cc
cmake --build build2
afl-fuzz -i input -o out -- build2/mdns_host_unit_test
```
The harness reads packets from stdin and exercises IPv4/IPv6 and port 5353/53 combinations. Crashes are written to `out/default/crashes/`.
### Reproducing a crash
Build the non-unit-test binary with a normal compiler, then pass a crash file:
```bash
cmake -B build2 -S .
cmake --build build2
./build2/mdns_host_unit_test out/default/crashes/id_000000,...
```
With sanitizers enabled, ASan/UBSan report buffer overruns and undefined behaviour directly during unit tests and fuzzing.