Merge pull request #60 from cjkas/test/snapshot-worst-case

test: prove no read item can outgrow the snapshot unit
This commit is contained in:
cjkas 2026-10-17 23:36:08 +02:00 • committed by GitHub
commit 2056930005
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 153 additions and 6 deletions

View file

@ -128,6 +128,10 @@ enum class snapshot_doc_t : uint8_t {
// (device, radio and firmware details) into the open top-level object.
typedef void (*snapshot_header_t)(JsonFormatter &json, const model_snapshot_t &snap);
// The buffer each room, shade, group and linked shade is formatted into on its
// own. test_snapshot_limits checks the largest possible item of each fits.
#define SNAPSHOT_UNIT_SIZE 3072
// Writes a document from a snapshot a piece at a time for a chunked response.
// Each room, shade, group and linked shade is formatted into unit on its own;
// one that doesn't fit is logged and left out so the JSON stays valid.

View file

@ -285,7 +285,7 @@ static void discoveryHeader(JsonFormatter &json, const model_snapshot_t &snap) {
// window allows, so there is no growing response buffer either.
struct SnapshotRead {
uint8_t slot;
char unit[3072];
char unit[SNAPSHOT_UNIT_SIZE];
SnapshotWriter writer;
SnapshotRead(uint8_t slot, snapshot_doc_t doc, uint8_t id, snapshot_header_t header)
: slot(slot), writer(snapshotSlots.snapshot(slot), doc, id, header, unit, sizeof(unit)) {}