diff --git a/netutils/mqttc/CMakeLists.txt b/netutils/mqttc/CMakeLists.txt index 246cd1919..ae03435be 100644 --- a/netutils/mqttc/CMakeLists.txt +++ b/netutils/mqttc/CMakeLists.txt @@ -1,24 +1,24 @@ -############################################################################ +# ############################################################################## # apps/netutils/mqttc/CMakeLists.txt # # SPDX-License-Identifier: Apache-2.0 # -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. The -# ASF licenses this file to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance with the -# License. You may obtain a copy of the License at +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# License for the specific language governing permissions and limitations under +# the License. # -############################################################################ +# ############################################################################## if(CONFIG_NETUTILS_MQTTC) @@ -124,4 +124,24 @@ if(CONFIG_NETUTILS_MQTTC) mqttc) endif() endif() + + if(CONFIG_NETUTILS_MQTTC_TEST) + set(MQTT_TEST_CFLAGS ${CFLAGS} -Dopen_nb_socket=test_open_nb_socket + -Dpublish_callback=test_publish_callback) + + nuttx_add_application( + NAME + cmocka_mqttc_test + STACKSIZE + ${CONFIG_NETUTILS_MQTTC_TEST_STACKSIZE} + PRIORITY + ${SCHED_PRIORITY_DEFAULT} + SRCS + ${MQTTC_DIR}/tests.c + COMPILE_FLAGS + ${MQTT_TEST_CFLAGS} + DEPENDS + cmocka + mqttc) + endif() endif() diff --git a/netutils/mqttc/Kconfig b/netutils/mqttc/Kconfig index 2c1d0b883..aa8e23d04 100644 --- a/netutils/mqttc/Kconfig +++ b/netutils/mqttc/Kconfig @@ -17,6 +17,10 @@ config NETUTILS_MQTTC_EXAMPLE ---help--- Enable MQTT-C example +config NETUTILS_MQTTC_TEST + tristate "Enable MQTT-C test" + default n + if NETUTILS_MQTTC_EXAMPLE config NETUTILS_MQTTC_EXAMPLE_STACKSIZE @@ -25,6 +29,14 @@ config NETUTILS_MQTTC_EXAMPLE_STACKSIZE endif +if NETUTILS_MQTTC_TEST + +config NETUTILS_MQTTC_TEST_STACKSIZE + int "Task's stack size" + default 8192 + +endif + config NETUTILS_MQTTC_WITH_MBEDTLS bool "Enable MQTT-C with mbedtls" default n diff --git a/netutils/mqttc/Makefile b/netutils/mqttc/Makefile index 730ce5139..d8d2a3638 100644 --- a/netutils/mqttc/Makefile +++ b/netutils/mqttc/Makefile @@ -83,4 +83,17 @@ endif endif +ifneq ($(CONFIG_NETUTILS_MQTTC_TEST),) +$(MQTTC_UNPACK)$(DELIM)tests.c_CFLAGS += \ + -I$(APPDIR)$(DELIM)testing$(DELIM)cmocka$(DELIM)cmocka$(DELIM)include \ + -Dopen_nb_socket=test_open_nb_socket \ + -Dpublish_callback=test_publish_callback + +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = $(CONFIG_NETUTILS_MQTTC_TEST_STACKSIZE) +MODULE = $(CONFIG_NETUTILS_MQTTC_TEST) +MAINSRC += $(MQTTC_UNPACK)$(DELIM)tests.c +PROGNAME += cmocka_mqttc_test +endif + include $(APPDIR)/Application.mk