Readme.md
1# Testing
2
3## Mocked Modbus Testing
4
5The `socat` command is utilized to create pseudo-terminals (PTYs), enabling the
6setup of virtual serial ports for communication between a Modbus client and
7server. In this testing framework, the Modbus client (implemented as a test
8client using gtest) sends Modbus commands to a test server, which processes
9these requests and returns responses. The test environment setup is responsible
10for configuring the pseudo-terminals and launching the test server instance. The
11server logic resides in `modbus_server_tester.cpp::ServerTester`, with further
12details provided in the following sections.
13
14### ServerTester
15
16`ServerTester` acts as a mock Modbus server, intercepting Modbus messages and
17generating appropriate responses. The replies are determined by the mocked
18Modbus addresses, allowing targeted code paths to be exercised on the client
19side. `ServerTester` is capable of handling both single and segmented response
20scenarios, and also provides error responses to facilitate negative testing. The
21test server currently handles the following Modbus command:
22
23- ReadHoldingRegisters
24