test: read and write shades.cfg and backups on the PC

The records move to ConfigRecords, free of the file system and the
shade model, with 33 unit tests: each record's size against the header,
a round trip of each, the layouts of versions 2 to 24, and a real backup
when CONFIG_BACKUP names one.

The tests found, and this fixes:
- A quoted value as long as its field (a hostname of 30 or more
  characters, a full NTP server, MQTT host or time zone) was read short,
  and every value after it shifted.
- A comma in a shade, group or room name shifted the rest of its record.
  Names are read at their fixed width.
- 4.0 boards without Ethernet declared the network record 28 bytes longer
  than they wrote it, so a restore of the radio without the network read
  the radio from the middle of its record.  Records are read and skipped
  to their newline, and backup() measures what it writes.
- A restore cleared rooms beyond the backup's only on load.

A restore now takes the backup's rolling codes even when they are lower
than NVS's; a load still keeps the higher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-29 16:59:52 +01:00
parent 6db449e878
commit 8c59cf4903
8 changed files with 1881 additions and 915 deletions

View file

@ -112,7 +112,7 @@ build_flags =
platform = native
test_framework = unity
test_build_src = yes
build_src_filter = -<*> +<Utils.cpp> +<SomfyFrame.cpp> +<JsonFormatter.cpp> +<ShadeMotion.cpp> +<ShadeSensors.cpp> +<ShadeBehaviour.cpp> +<PulseDecoder.cpp> +<TxBuffer.cpp> +<RadioScheduler.cpp> +<ShadeRequests.cpp> +<entryPoints/MqttCommands.cpp> +<ItemSnapshot.cpp> +<ModelEditor.cpp> +<ShadeChanges.cpp> +<ProtoSchema.cpp> +<ProtoFrame.cpp> +<ProtoSync.cpp> +<ProtoParse.cpp> +<ProtoSlots.cpp> +<ProtoOps.cpp> +<ProtoEdits.cpp> +<ProtoSettings.cpp> +<ProtoAssembly.cpp>
build_src_filter = -<*> +<Utils.cpp> +<ConfigRecords.cpp> +<MqttDisco.cpp> +<SomfyFrame.cpp> +<JsonFormatter.cpp> +<ShadeMotion.cpp> +<ShadeSensors.cpp> +<ShadeBehaviour.cpp> +<PulseDecoder.cpp> +<TxBuffer.cpp> +<RadioScheduler.cpp> +<ShadeRequests.cpp> +<entryPoints/MqttCommands.cpp> +<ItemSnapshot.cpp> +<ModelEditor.cpp> +<ShadeChanges.cpp> +<ProtoSchema.cpp> +<ProtoFrame.cpp> +<ProtoSync.cpp> +<ProtoParse.cpp> +<ProtoSlots.cpp> +<ProtoOps.cpp> +<ProtoEdits.cpp> +<ProtoSettings.cpp> +<ProtoAssembly.cpp>
lib_deps =
bblanchon/ArduinoJson@^7.2.2
build_flags =