stephane / libmodbus

A Modbus library for Linux, Mac OS, FreeBSD and Windows
http://libmodbus.org
GNU Lesser General Public License v2.1
3.29k stars 1.71k forks source link

Need more tests… #12

Closed public closed 13 years ago

public commented 13 years ago

There's currently no tests covering data corruption, timeouts etc.

There should be some. I intend to write some at some point in the near future but if someone get's there before me I'll help out.

stephane commented 13 years ago

No, there are already unit tests for timeout/bad queries (see tests directory) and I've recently created new functions to submit raw requests in this goal (see github log).

public commented 13 years ago

Which tests do this exactly? I can't identify which test suite checks timeout and invalid CRC behavior.

stephane commented 13 years ago

tests/unit-test-{client|server].c, the filename is clear, isn't it? If you want to add something just send an email or issue a pull request on github. The issue tracker is dedicated to bugs.

public commented 13 years ago

Sorry if this is the wrong place for this discussion. It just seems better to record this stuff in public and there's no official mailing list.

I can't see how the unit tests are testing the CRC paths. It seems that it requests a bad response from the server using UT_REGISTERS_NB_SPECIAL, and that mangles the number of records returned in the response so it doesn't match what the client expects. This doesn't test for random single bit corruption in messages, or other types of invalid data that can be caused by EMC or buggy hardware.

stephane commented 13 years ago

Yes it is, Please take time to consult the website first! http://libmodbus.org/reportbug/

I've already think about using a fuzzer to generate random and invalid data so it 's why I've created modbus_send_raw_request (http://hachoir.org/). Feel free to submit patches.

CRC is only used in RTU framing and the algo is already bullet proof and used for real on many applications every day so I don't care about this specific test.

public commented 13 years ago

Ah sorry about that, I'm subscribed now!