apps/netutils: Modify the MQTT compilation file to enable MQTT testing #3255
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)
`