Edge Design for LAN Drivers

I have a number of LAN based drivers that have automated unit tests that run before the drivers are deployed. Currently, that test harness is home grown and tests some internal libraries used by the drivers. However, I would like to expand that testing to include handling of messages sent by the hub. This is available for Zigbee/Zwave, but I would like to know if it can be leveraged for LAN devices:

The note at the top says it can’t, but I’d like to know why. It seems like the portion for sending ST events should be shared with LAN drivers. What is left to make this LAN compatible?

So the issue is that none of the LAN related APIs would be mocked appropriately so any calls to establish a socket and read/write to it wouldn’t be handled properly. The code for the test harness is available for download, so you are welcome to modify it for your testing, but it’s not so much a “can’t” as it is just not supported/implemented. Basically the way the test harness works is it replaces the select implementation in cosock and provides mocks for all the communication channels with the hub, then uses the expected send/receives and the fact that the main driver run loop calls select every time through to identify work ready for the driver to pass control back and forth between the test function and the driver code verifying that inputs and outputs are as expected by the test.

The reason that LAN drivers significantly complicate that is that 1) the data is just data, there’s far less structure to what can/should be pushed over a generic socket so it is far more difficult to provide a useful generic test interface. And 2) most LAN drivers manage reading/writing to the sockets they stand up outside of the main driver run loop which makes the coordination between the test framework and the driver under test more difficult to manage.

1 Like

Thanks @Zach_Varberg

Ideally, I wanted to setup a mock device and send messages to its capabilities to make sure the correct actions occur. For example, I have a Hue driver and internally there is a Hue library. I want to send a switch event to the device, verify that my library is called (don’t need to actually test Hue functionality here), and make sure the device state is correctly emitted afterward. I would test my Hue library off-hub as I do today. My question is mostly about mocking the events and then testing emitted state back out.