tests: provide tests for emcute#11823
Conversation
|
Ok, some details on the test server now that I cleaned it up a bit: it is a You can generate this graphic yourself, using the following within a reachable portion of the test script: MQTTSNServer.graph(options="-Gratio=.4", format="png",
target="mqttsn_test_server.png")This allows me to test some expected packet exchanges and include also some unexpected data exchanges. If the automaton reaches an error state, an exception is thrown. If it reaches the END state, the automaton's |
c321de1 to
b8c22cc
Compare
|
I rebased and squashed to current master, since I closed #11822 due to |
|
Adapted for #12382. |
|
Rebased to current master to incorporate latest fixes. |
edae2c2 to
13ad5bf
Compare
benpicco
left a comment
There was a problem hiding this comment.
Since this hasn't gotten any reviews yet, just squash.
There is nothing controversial about additional tests, this this should be able to go in fast.
61b3cb4 to
98271b5
Compare
|
Rebased and squashed to current master, left |
98271b5 to
215b44e
Compare
Updated and also fixed some static errors and required adaptations for current master. |
|
Not sure what happened, but I missed some boards somehow... |
215b44e to
1914d62
Compare
1914d62 to
5507b1b
Compare
|
Test failure unrelated. |
|
I wonder what's wrong with the micropython test. It keeps failing for |
|
Maybe its not the test, but the test + a certain worker within Murdock that fails. The set of test runner workers is (due to the hardware requirements) quite small. |
|
Murdock is happy now. |
benpicco
left a comment
There was a problem hiding this comment.
Can't say much about the content of the tests, but they already caught some bugs so we should really have them in to prevent new bugs from sneaking in.

Contribution description
This provides a test application for
emcutebased on the MQTT-SN layer forscapyI provided in #11822. Since it uses UDP sockets it can be run without root, but requiresscapynonetheless.Attached to this PR are fixes that I found with these tests.Fixesemcute: fix payload copy error for emcude_pub
(now in emcute: fix payload copy error for emcute_pub #11957)lenis used with thememcpy()to copy the payload totbuf. With apayload provided that is just long enough to fill
tbuf,len += 6leads to the
memcpy()overriding data aftertbuf(e.g. themutexthat is unlocked right after) and thus resulting in potentialsegmentation faults.
Additionally
+ 6can only be applied if the total packet length isbelow 256 (see spec), so
len + posis what needs to be provided to thecorresponding send functions instead (
posadapts to the header lengthof the PUBLISH message)
emcute: fix length field calculation
(now in emcute: fix length field calculation #11958)The length field in an MQTT packet carries the total length of the
packet. If it is below 256 (i.e. fits in one byte) only one byte is
used for the length field. If it is larger than that 3 bytes are used,
with the first byte having the value
0x01and the remaining bytesrepresenting the length in as a 2 byte unsigned integer in network byte
order. Resulting from that it can be assessed that the check in
emcutes'sset_len()function is wrong as it needs to be checked iflenis lesser or equal to0xff - 1.len <= (0xff - 1)can besimplified to
len < 0xff. For some larger packages this safes 2 bytesof wasted packet space.
Testing procedure
Make sure you have a recent version of
scapyforpython3installed.Run
(the blacklisted boards are excluded of course).
Issues/PRs references
Requires on #11822.