Skip to content

Commit 344102e

Browse files
zs39xiaoxiang781216
authored andcommitted
apps/netutils: Modify the MQTT compilation file to enable MQTT testing
Signed-off-by: zhangshuai39 <[email protected]>
1 parent fe8a3b9 commit 344102e

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

netutils/mqttc/CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,24 @@ if(CONFIG_NETUTILS_MQTTC)
118118
mqttc)
119119
endif()
120120
endif()
121+
122+
if(CONFIG_NETUTILS_MQTTC_TEST)
123+
set(MQTT_TEST_CFLAGS ${CFLAGS} -Dopen_nb_socket=test_open_nb_socket
124+
-Dpublish_callback=test_publish_callback)
125+
126+
nuttx_add_application(
127+
NAME
128+
cmocka_mqttc_test
129+
STACKSIZE
130+
${CONFIG_NETUTILS_MQTTC_TEST_STACKSIZE}
131+
PRIORITY
132+
${SCHED_PRIORITY_DEFAULT}
133+
SRCS
134+
${MQTTC_DIR}/tests.c
135+
COMPILE_FLAGS
136+
${MQTT_TEST_CFLAGS}
137+
DEPENDS
138+
cmocka
139+
mqttc)
140+
endif()
121141
endif()

netutils/mqttc/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ config NETUTILS_MQTTC_EXAMPLE
1717
---help---
1818
Enable MQTT-C example
1919

20+
config NETUTILS_MQTTC_TEST
21+
tristate "Enable MQTT-C test"
22+
default n
23+
2024
if NETUTILS_MQTTC_EXAMPLE
2125

2226
config NETUTILS_MQTTC_EXAMPLE_STACKSIZE
@@ -25,6 +29,14 @@ config NETUTILS_MQTTC_EXAMPLE_STACKSIZE
2529

2630
endif
2731

32+
if NETUTILS_MQTTC_TEST
33+
34+
config NETUTILS_MQTTC_TEST_STACKSIZE
35+
int "Task's stack size"
36+
default 8192
37+
38+
endif
39+
2840
config NETUTILS_MQTTC_WITH_MBEDTLS
2941
bool "Enable MQTT-C with mbedtls"
3042
default n

netutils/mqttc/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,17 @@ endif
8181

8282
endif
8383

84+
ifneq ($(CONFIG_NETUTILS_MQTTC_TEST),)
85+
$(MQTTC_UNPACK)$(DELIM)tests.c_CFLAGS += \
86+
-I$(APPDIR)$(DELIM)testing$(DELIM)cmocka$(DELIM)cmocka$(DELIM)include \
87+
-Dopen_nb_socket=test_open_nb_socket \
88+
-Dpublish_callback=test_publish_callback
89+
90+
PRIORITY = SCHED_PRIORITY_DEFAULT
91+
STACKSIZE = $(CONFIG_NETUTILS_MQTTC_TEST_STACKSIZE)
92+
MODULE = $(CONFIG_NETUTILS_MQTTC_TEST)
93+
MAINSRC += $(MQTTC_UNPACK)$(DELIM)tests.c
94+
PROGNAME += cmocka_mqttc_test
95+
endif
96+
8497
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)