Classes | Functions | Variables
pilz_modbus_client_test Namespace Reference

Classes

class  HoldingRegisterIncreaser
 Strictly increases the holding register each time the "readHoldingRegister" method is called. More...
 
class  LibModbusClientTest
 
class  PilzModbusClientExecutor
 Helper class to simplify the threading of the PilzModbusClient. More...
 
class  PilzModbusClientTests
 Test if PilzModbusClient correctly publishes ROS-Modbus messages. More...
 
class  RegisterBuffer
 

Functions

void callbackDummy (const ModbusMsgInStampedConstPtr &)
 
 MATCHER (IsDisconnect, "")
 
 MATCHER_P (IsSuccessfullRead, vec, "")
 
static std::vector< unsigned int > PORTS_FOR_TEST (END_PORT - START_PORT)
 
 TEST_F (LibModbusClientTest, testModbusClientDtor)
 Test increases function coverage by ensuring that all Dtor variants are called. More...
 
 TEST_F (LibModbusClientTest, testNewInit)
 Test construction via new. More...
 
 TEST_F (LibModbusClientTest, testInitialization)
 Test successfull init. More...
 
 TEST_F (LibModbusClientTest, testFailingInitIfNoServer)
 Test unsuccessfull init if no server is present. More...
 
 TEST_F (LibModbusClientTest, testReadRegisters)
 Tests that holding registers set on the server are correctly read by the client. More...
 
 TEST_F (PilzModbusClientTests, testInitialization)
 Test that PilzModbusClient initializes its client properly. More...
 
 TEST_F (LibModbusClientTest, testWritingRegisters)
 Tests that holding registers are correctly written by client. More...
 
 TEST_F (PilzModbusClientTests, testInitializationWithRetry)
 Test that initialization is repeated if it does not work at first try. More...
 
 TEST_F (PilzModbusClientTests, doubleInitialization)
 Test that double initialization fails on seconds try. More...
 
 TEST_F (LibModbusClientTest, testNegativeNumberOfRegistersToRead)
 Tests that exception is thrown if the user tries to call the write function with a negative number of write of registers to read. More...
 
 TEST_F (PilzModbusClientTests, failingInitialization)
 Test the initialization of the modbus read client if init fails. More...
 
 TEST_F (LibModbusClientTest, testOutOfRangeRegisterSize)
 Tests that exception is thrown if the user tries to call the write function with a register containing too mainy elements. More...
 
 TEST_F (PilzModbusClientTests, failingInitializationWithRetry)
 Test that repeated failed initialization yields in a failed init for the caller. More...
 
 TEST_F (LibModbusClientTest, testDisconnectBeforeReadWriteOp)
 Tests that exception is thrown if modbus connections fails before call to write & read function. More...
 
 TEST_F (PilzModbusClientTests, properReadingAndDisconnect)
 Test that PilzModbusClient properly reads from the registers and reacts to disconnects. More...
 
 TEST_F (LibModbusClientTest, testDisconnectDuringReadWriteOp)
 Tests that exception is thrown if modbus connections fails during write & read operation. More...
 
 TEST_F (PilzModbusClientTests, runningWithoutInit)
 Try to run the modbus read client without a foregoing call to init() More...
 
 TEST_F (LibModbusClientTest, testReadRegistersNoInit)
 Tests that after a failed init (e.g. no available modbus server) reading throws a exception. More...
 
 TEST_F (LibModbusClientTest, testReadRegistersTerminatedServer)
 Tests that after a failed init (e.g. after disconnect from server) reading throws a exception. More...
 
 TEST_F (PilzModbusClientTests, terminateRunningClient)
 Test that a running modbus read client can be stopped with the terminate method. More...
 
 TEST_F (LibModbusClientTest, setResponseTimeout)
 Tests that setting reponse timeout on the client will return the same timeout on getResponseTimeoutInMs. More...
 
 TEST_F (PilzModbusClientTests, testTopicNameChange)
 Tests that topic name can be changed. More...
 
 TEST_F (PilzModbusClientTests, testSettingOfTimeOut)
 Tests that response timeout can be changed. More...
 
 TEST_F (PilzModbusClientTests, testSettingReadFrequency)
 Tests that the frequency with which the registers are read, can be changed. More...
 
 TEST_F (PilzModbusClientTests, testWritingOfHoldingRegister)
 Tests that modbus client can properly write and read from holding register (with one call). More...
 
 TEST_F (PilzModbusClientTests, testSplitIntoBlocksFcn)
 Tests the split_into_blocks method. More...
 

Variables

static unsigned int ACTIVE_PORT_IDX { 0 }
 
static constexpr unsigned int DEFAULT_MODBUS_PORT_TEST { 502 }
 
constexpr unsigned int DEFAULT_READ_IDX { 77 }
 
constexpr unsigned int DEFAULT_REGISTER_SIZE { 514 }
 
constexpr unsigned int DEFAULT_WRITE_IDX { 512 }
 
constexpr unsigned int END_PORT { 20600 }
 
static constexpr unsigned int REGISTER_FIRST_IDX_TEST { 512 }
 
static constexpr unsigned int REGISTER_SIZE_TEST { 2 }
 
static constexpr unsigned int RESPONSE_TIMEOUT { 10 }
 
constexpr unsigned int START_PORT { 20500 }
 
static constexpr double WAIT_FOR_SERVICE_TIMEOUT_S { 3.0 }
 
static constexpr double WAIT_FOR_START_TIMEOUT_S { 3.0 }
 
static constexpr double WAIT_FOR_STOP_TIMEOUT_S { 3.0 }
 
static constexpr double WAIT_SLEEPTIME_S { 0.1 }
 

Function Documentation

◆ callbackDummy()

void pilz_modbus_client_test::callbackDummy ( const ModbusMsgInStampedConstPtr &  )

Definition at line 322 of file unittest_pilz_modbus_client.cpp.

◆ MATCHER()

pilz_modbus_client_test::MATCHER ( IsDisconnect  ,
""   
)

Definition at line 145 of file unittest_pilz_modbus_client.cpp.

◆ MATCHER_P()

pilz_modbus_client_test::MATCHER_P ( IsSuccessfullRead  ,
vec  ,
""   
)

Definition at line 141 of file unittest_pilz_modbus_client.cpp.

◆ PORTS_FOR_TEST()

static std::vector<unsigned int> pilz_modbus_client_test::PORTS_FOR_TEST ( END_PORT START_PORT)
static

◆ TEST_F() [1/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testModbusClientDtor   
)

Test increases function coverage by ensuring that all Dtor variants are called.

Definition at line 95 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [2/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testNewInit   
)

Test construction via new.

This test is used to at least once call the default destructor used for destructing objects allocated on the heap. (If this test is missing function coverage will drop)

Definition at line 107 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [3/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testInitialization   
)

Test successfull init.

Definition at line 115 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [4/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testFailingInitIfNoServer   
)

Test unsuccessfull init if no server is present.

Definition at line 130 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [5/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testReadRegisters   
)

Tests that holding registers set on the server are correctly read by the client.

Definition at line 139 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [6/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
testInitialization   
)

Test that PilzModbusClient initializes its client properly.

Definition at line 153 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [7/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testWritingRegisters   
)

Tests that holding registers are correctly written by client.

Definition at line 160 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [8/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
testInitializationWithRetry   
)

Test that initialization is repeated if it does not work at first try.

Definition at line 171 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [9/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
doubleInitialization   
)

Test that double initialization fails on seconds try.

Definition at line 189 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [10/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testNegativeNumberOfRegistersToRead   
)

Tests that exception is thrown if the user tries to call the write function with a negative number of write of registers to read.

Definition at line 195 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [11/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
failingInitialization   
)

Test the initialization of the modbus read client if init fails.

Definition at line 208 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [12/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testOutOfRangeRegisterSize   
)

Tests that exception is thrown if the user tries to call the write function with a register containing too mainy elements.

Definition at line 219 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [13/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
failingInitializationWithRetry   
)

Test that repeated failed initialization yields in a failed init for the caller.

Definition at line 226 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [14/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testDisconnectBeforeReadWriteOp   
)

Tests that exception is thrown if modbus connections fails before call to write & read function.

Definition at line 243 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [15/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
properReadingAndDisconnect   
)

Test that PilzModbusClient properly reads from the registers and reacts to disconnects.

Definition at line 244 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [16/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testDisconnectDuringReadWriteOp   
)

Tests that exception is thrown if modbus connections fails during write & read operation.

Definition at line 257 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [17/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
runningWithoutInit   
)

Try to run the modbus read client without a foregoing call to init()

Definition at line 278 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [18/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testReadRegistersNoInit   
)

Tests that after a failed init (e.g. no available modbus server) reading throws a exception.

Definition at line 280 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [19/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
testReadRegistersTerminatedServer   
)

Tests that after a failed init (e.g. after disconnect from server) reading throws a exception.

Definition at line 291 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [20/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
terminateRunningClient   
)

Test that a running modbus read client can be stopped with the terminate method.

Definition at line 298 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [21/26]

pilz_modbus_client_test::TEST_F ( LibModbusClientTest  ,
setResponseTimeout   
)

Tests that setting reponse timeout on the client will return the same timeout on getResponseTimeoutInMs.

Definition at line 308 of file unittest_libmodbus_client.cpp.

◆ TEST_F() [22/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
testTopicNameChange   
)

Tests that topic name can be changed.

Definition at line 329 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [23/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
testSettingOfTimeOut   
)

Tests that response timeout can be changed.

Definition at line 349 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [24/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
testSettingReadFrequency   
)

Tests that the frequency with which the registers are read, can be changed.

This test does NOT precisly check (tolerance ca. 10%) if the exact frequency could be set. It just checks that the frequency was changed.

Test Sequence:

  • 1. Various frequencies are checked. Measure the number of register accesses within ~1 seconds.

Expected Results:

  • 1. The measured frequence is within a 10% tolerance

Definition at line 434 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [25/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
testWritingOfHoldingRegister   
)

Tests that modbus client can properly write and read from holding register (with one call).

Definition at line 485 of file unittest_pilz_modbus_client.cpp.

◆ TEST_F() [26/26]

pilz_modbus_client_test::TEST_F ( PilzModbusClientTests  ,
testSplitIntoBlocksFcn   
)

Tests the split_into_blocks method.

Definition at line 541 of file unittest_pilz_modbus_client.cpp.

Variable Documentation

◆ ACTIVE_PORT_IDX

unsigned int pilz_modbus_client_test::ACTIVE_PORT_IDX { 0 }
static

Definition at line 40 of file unittest_libmodbus_client.cpp.

◆ DEFAULT_MODBUS_PORT_TEST

constexpr unsigned int pilz_modbus_client_test::DEFAULT_MODBUS_PORT_TEST { 502 }
static

Definition at line 54 of file unittest_pilz_modbus_client.cpp.

◆ DEFAULT_READ_IDX

constexpr unsigned int pilz_modbus_client_test::DEFAULT_READ_IDX { 77 }

Definition at line 45 of file unittest_libmodbus_client.cpp.

◆ DEFAULT_REGISTER_SIZE

constexpr unsigned int pilz_modbus_client_test::DEFAULT_REGISTER_SIZE { 514 }

Definition at line 43 of file unittest_libmodbus_client.cpp.

◆ DEFAULT_WRITE_IDX

constexpr unsigned int pilz_modbus_client_test::DEFAULT_WRITE_IDX { 512 }

Definition at line 44 of file unittest_libmodbus_client.cpp.

◆ END_PORT

constexpr unsigned int pilz_modbus_client_test::END_PORT { 20600 }

Definition at line 39 of file unittest_libmodbus_client.cpp.

◆ REGISTER_FIRST_IDX_TEST

constexpr unsigned int pilz_modbus_client_test::REGISTER_FIRST_IDX_TEST { 512 }
static

Definition at line 55 of file unittest_pilz_modbus_client.cpp.

◆ REGISTER_SIZE_TEST

constexpr unsigned int pilz_modbus_client_test::REGISTER_SIZE_TEST { 2 }
static

Definition at line 56 of file unittest_pilz_modbus_client.cpp.

◆ RESPONSE_TIMEOUT

constexpr unsigned int pilz_modbus_client_test::RESPONSE_TIMEOUT { 10 }
static

Definition at line 57 of file unittest_pilz_modbus_client.cpp.

◆ START_PORT

constexpr unsigned int pilz_modbus_client_test::START_PORT { 20500 }

Definition at line 38 of file unittest_libmodbus_client.cpp.

◆ WAIT_FOR_SERVICE_TIMEOUT_S

constexpr double pilz_modbus_client_test::WAIT_FOR_SERVICE_TIMEOUT_S { 3.0 }
static

Definition at line 62 of file unittest_pilz_modbus_client.cpp.

◆ WAIT_FOR_START_TIMEOUT_S

constexpr double pilz_modbus_client_test::WAIT_FOR_START_TIMEOUT_S { 3.0 }
static

Definition at line 59 of file unittest_pilz_modbus_client.cpp.

◆ WAIT_FOR_STOP_TIMEOUT_S

constexpr double pilz_modbus_client_test::WAIT_FOR_STOP_TIMEOUT_S { 3.0 }
static

Definition at line 61 of file unittest_pilz_modbus_client.cpp.

◆ WAIT_SLEEPTIME_S

constexpr double pilz_modbus_client_test::WAIT_SLEEPTIME_S { 0.1 }
static

Definition at line 60 of file unittest_pilz_modbus_client.cpp.



prbt_hardware_support
Author(s):
autogenerated on Wed Nov 25 2020 03:10:38