From 248a9f772b87ecc92763ee897925886f585eb995 Mon Sep 17 00:00:00 2001 From: caofuqi1 Date: Thu, 29 Dec 2022 15:29:55 +0800 Subject: [PATCH] netutils/cjson: Enable cjson test --- netutils/cjson/Kconfig | 12 ++++++++++++ netutils/cjson/Makefile | 20 ++++++++++++++++++++ testing/unity/Makefile | 1 + 3 files changed, 33 insertions(+) diff --git a/netutils/cjson/Kconfig b/netutils/cjson/Kconfig index 46d9a4c9c..d602ba852 100644 --- a/netutils/cjson/Kconfig +++ b/netutils/cjson/Kconfig @@ -20,4 +20,16 @@ config NETUTILS_CJSON_VERSION string "Version number" default "1.7.12" +config NETUTILS_CJSON_TEST + bool "Enable cJSON test" + default n + +if NETUTILS_CJSON_TEST + +config CJSON_UNITY_TEST_DIR + string "cJSON test directory" + default "/data" + +endif + endif diff --git a/netutils/cjson/Makefile b/netutils/cjson/Makefile index d5ad647a0..d349b3948 100644 --- a/netutils/cjson/Makefile +++ b/netutils/cjson/Makefile @@ -58,6 +58,26 @@ $(CJSON_UNPACKNAME): $(CJSON_TARBALL) $(Q) touch $(CJSON_UNPACKNAME) endif +ifneq ($(CONFIG_NETUTILS_CJSON_TEST),) +PROGNAME += cjson_test +MAINSRC += $(CJSON_SRCDIR)$(DELIM)test.c + +UNITY_CJSONTESTS := parse_examples parse_number parse_hex4 parse_string parse_array \ + parse_object parse_value print_string print_number print_array print_object \ + print_value cjson_add parse_with_opts compare_tests readme_examples minify_tests \ + misc_tests json_patch_tests old_utils_tests misc_utils_tests +UNITY_CJSONTESTCS := $(foreach n, $(UNITY_CJSONTESTS), $(CJSON_SRCDIR)$(DELIM)tests$(DELIM)$(n).c) +CJSONTEST_MAIN := $(foreach n, $(UNITY_CJSONTESTS), cjson_$(n)) +PROGNAME += $(CJSONTEST_MAIN) +MAINSRC += $(UNITY_CJSONTESTCS) + +CSRCS += $(CJSON_SRCDIR)/tests/unity_setup.c +CFLAGS += -Wno-unused-function + +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = $(CONFIG_DEFAULT_TASK_STACKSIZE) +endif + $(CJSON_SRCDIR)$(DELIM)cJSON.h: $(CJSON_UNPACKNAME) $(CJSON_SRCDIR)$(DELIM)cJSON_Utils.h: $(CJSON_UNPACKNAME) diff --git a/testing/unity/Makefile b/testing/unity/Makefile index 4a3790328..c7db299ce 100644 --- a/testing/unity/Makefile +++ b/testing/unity/Makefile @@ -42,6 +42,7 @@ APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)testing CFLAGS += ${INCDIR_PREFIX}$(APPS_INCDIR) CFLAGS += -DUNITY_INCLUDE_CONFIG_H +CFLAGS += -DUNITY_INCLUDE_DOUBLE CSRCS = $(UNITY_SRCDIR)$(DELIM)unity.c