SOFT-6671: Add unit tests for RPC device load functions#1095
Open
evgeny-boger wants to merge 12 commits into
Open
SOFT-6671: Add unit tests for RPC device load functions#1095evgeny-boger wants to merge 12 commits into
evgeny-boger wants to merge 12 commits into
Conversation
Move readonly filtering from CreateRegisterList() to callers so that readonly parameters can be read for condition evaluation. In deviceLoad, read condition-referenced parameters first, then filter channels by their condition expressions before reading channel registers. This avoids unnecessary serial I/O for channels that don't apply to the current device configuration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update CreateRegisterList test expectations to include readonly params - Add ReadonlyParametersFiltered test verifying caller-side filtering - Add GetConditionParametersRegisterList test for dependency extraction - Add GetChannelsRegisterList tests for condition-based filtering - Add device_load_conditions test template with conditional channels Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Document how to build and run tests using contactless/devenv Docker image with QEMU user-mode emulation for ARM binaries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix GetParametersRegisterList checking Channels instead of Parameters, which silently skipped errors for unknown parameter names. Add missing return after successful read/write in ReadModbusRegister and WriteModbusRegister to avoid redundant retries on success. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that requesting a non-existent parameter throws TRPCException. This test caught a copy-paste bug where Channels was checked instead of Parameters. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move ReadModbusRegister, WriteModbusRegister, and IsAllFFFE from rpc_device_load_task.cpp and rpc_device_load_config_task.cpp into shared rpc_helpers.h/.cpp, eliminating code duplication. Both callers now use the shared versions via TRPCDeviceRequest& (the common base class). Bug fixes included in the extraction: - Add missing return after successful Modbus read/write in the rpc_device_load_config_task copy (registers were read/written 3x) - Re-throw non-fatal TModbusExceptionError on last retry instead of silently returning with uninitialized value - Use IsAllFFFE (handles string and multi-word registers) in MarkUnsupportedParameters instead of a 16-bit-only inline check - Always restore continuous-read mode in MarkUnsupported, not only for devices loaded from config Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactor anonymous-namespace functions in rpc_device_load_task.cpp and rpc_device_load_config_task.cpp into named detail namespaces to make them testable. Add 19 modbus-level tests covering SetContinuousRead, MarkUnsupported, ReadWbRegister, ReadDeviceModel, CheckTemplate, and ExecRPCRequest. Also add 12 tests for ReadModbusRegister/WriteModbusRegister retry and exception handling in rpc_helpers_test.cpp. Coverage: rpc_device_load_task.cpp 53%→83%, rpc_device_load_config_task.cpp 15%→44%. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
KraPete
approved these changes
Mar 3, 2026
Contributor
|
с учетом влитых пуллреквестов, думаю, этот проще закрыть и попросить Claude сделать новые тесты для непокрытого кода, а то как-то многовато конфликтов |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Описание
Добавлены юнит-тесты для внутренних функций RPC загрузки устройств (
rpc_device_load_task.cppиrpc_device_load_config_task.cpp), которые ранее были скрыты в анонимных пространствах имён и не поддавались тестированию.Изменения:
rpc_device_load_task.cppиrpc_device_load_config_task.cppвынесены в именованныеdetail-пространства имён (rpc_device_load_detail,rpc_device_load_config_detail)TFakeSerialPort+TModbusExpectationsBaseSetContinuousRead,MarkUnsupported,ReadRegistersIntoJson,ExecRPCRequest,ReadWbRegister,ReadDeviceModel,CheckTemplate,MarkUnsupportedParametersТестирование
rpc_device_load_task.cppувеличено с ~53% до ~70%+rpc_device_load_config_task.cppувеличено с ~15% до ~30%+