Skip to content

Conversation

@zs39
Copy link
Contributor

@zs39 zs39 commented Dec 17, 2025

Summary

Modify the build and test files to make the MQTT test cases run.
Previously, native MQTT test cases were not compiled. Now, these native test cases are compiled in to make them run. However, some test cases do have issues that were not introduced by this patch but existed in the original test cases.

Impact

Only affects MQTT testing

Testing

The compilation is successful and the test commands can be executed normally.
`nsh> cmocka_mqttc_test
Staring MQTT-C unit-tests.
Using broker: "test.mosquitto.org:1883"

[MQTT Packet Serialization/Deserialization Tests]
[==========] framing_tests: Running 11 test(s).
[ RUN ] TEST__framing__fixed_header
[ OK ] TEST__framing__fixed_header
[ RUN ] TEST__framing__connect
[ OK ] TEST__framing__connect
[ RUN ] TEST__framing__connack
[ OK ] TEST__framing__connack
[ RUN ] TEST__framing__publish
[ OK ] TEST__framing__publish
[ RUN ] TEST__framing__pubxxx
[ OK ] TEST__framing__pubxxx
[ RUN ] TEST__framing__subscribe
[ OK ] TEST__framing__subscribe
[ RUN ] TEST__framing__suback
[ OK ] TEST__framing__suback
[ RUN ] TEST__framing__unsubscribe
[ OK ] TEST__framing__unsubscribe
[ RUN ] TEST__framing__unsuback
[ OK ] TEST__framing__unsuback
[ RUN ] TEST__framing__ping
[ OK ] TEST__framing__ping
[ RUN ] TEST__framing__disconnect
[ OK ] TEST__framing__disconnect
[==========] framing_tests: 11 test(s) run.
[ PASSED ] 11 test(s).

[MQTT-C Utilities Tests]
[==========] util_tests: Running 4 test(s).
[ RUN ] TEST__utility__message_queue
[ OK ] TEST__utility__message_queue
[ RUN ] TEST__utility__pid_lfsr
[ OK ] TEST__utility__pid_lfsr
[ RUN ] TEST__utility__connect_disconnect
Failed to open socket (getaddrinfo): EAI_AGAIN
[ ERROR ] --- client.socketfd != -1
[ LINE ] --- MQTT-C/tests.c:280: error: Failure!
[ FAILED ] TEST__utility__connect_disconnect
[ RUN ] TEST__utility__ping
Failed to open socket (getaddrinfo): EAI_AGAIN
[ ERROR ] --- client.socketfd != -1
[ LINE ] --- MQTT-C/tests.c:482: error: Failure!
[ FAILED ] TEST__utility__ping
[==========] util_tests: 4 test(s) run.
[ PASSED ] 2 test(s).
[ FAILED ] util_tests: 2 test(s), listed below:
[ FAILED ] TEST__utility__connect_disconnect
[ FAILED ] TEST__utility__ping

2 FAILED TEST(S)

[MQTT-C API Tests]
[==========] api_tests: Running 3 test(s).
[ RUN ] TEST__api__connect_ping_disconnect
Failed to open socket (getaddrinfo): EAI_AGAIN
[ ERROR ] --- __mqtt_send(&client) > 0
[ LINE ] --- MQTT-C/tests.c:640: error: Failure!
[ FAILED ] TEST__api__connect_ping_disconnect
[ RUN ] TEST__api__publish_subscribe__single
Failed to open socket (getaddrinfo): EAI_AGAIN
Failed to open socket (getaddrinfo): EAI_AGAIN
[ ERROR ] --- __mqtt_send(&sender) > 0
[ LINE ] --- MQTT-C/tests.c:687: error: Failure!
[ FAILED ] TEST__api__publish_subscribe__single
[ RUN ] TEST__api__publish_subscribe__multiple
Failed to open socket (getaddrinfo): EAI_AGAIN
Failed to open socket (getaddrinfo): EAI_AGAIN
error: MQTT_ERROR_SOCKET_ERROR
[ ERROR ] --- rv > 0
[ LINE ] --- MQTT-C/tests.c:758: error: Failure!
[ FAILED ] TEST__api__publish_subscribe__multiple
[==========] api_tests: 3 test(s) run.
[ PASSED ] 0 test(s).
[ FAILED ] api_tests: 3 test(s), listed below:
[ FAILED ] TEST__api__connect_ping_disconnect
[ FAILED ] TEST__api__publish_subscribe__single
[ FAILED ] TEST__api__publish_subscribe__multiple

3 FAILED TEST(S)
`

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @zs39 very nice addition mqtt is very popular! :-)

  • Please check CI errors, cmake formatting needs fix.
  • Could you please provide testing logs before and after the change? If this is "modification" then something was not working before right? If this is "introducing mqtt tests" then its a new feature not present before?
  • Thank you for providing logs where tests fail. Could you please provide logs where tests pass?

@zs39
Copy link
Contributor Author

zs39 commented Dec 18, 2025

Thank you @zs39 very nice addition mqtt is very popular! :-)

  • Please check CI errors, cmake formatting needs fix.
  • Could you please provide testing logs before and after the change? If this is "modification" then something was not working before right? If this is "introducing mqtt tests" then its a new feature not present before?
  • Thank you for providing logs where tests fail. Could you please provide logs where tests pass?

This patch only compiles the native MQTT test cases; they weren't originally compiled and run. The native test cases themselves might have inherent issues, which won't be fixed in this patch.@cederom

Modify the build and test files to make the MQTT test cases run.

Signed-off-by: zhangshuai39 <[email protected]>
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @zs39 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants