You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2023/01/26 06:13:08 UTC
[nuttx-apps] branch master updated: testing/cmocka: forwarding cmocka log message to syslog channel
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 1f4292c25 testing/cmocka: forwarding cmocka log message to syslog channel
1f4292c25 is described below
commit 1f4292c250cff43481d30587ec71a7dc952bee9f
Author: haopengxiang <ha...@xiaomi.com>
AuthorDate: Mon Nov 7 00:39:35 2022 +0800
testing/cmocka: forwarding cmocka log message to syslog channel
and ignore cmocka files in apps
Signed-off-by: chao an <an...@xiaomi.com>
---
testing/cmocka/.gitignore | 1 +
testing/cmocka/Makefile | 2 ++
testing/cmocka/cmocka_main.c | 6 +++---
testing/cmocka/cmocka_platform.h | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/testing/cmocka/.gitignore b/testing/cmocka/.gitignore
new file mode 100644
index 000000000..d39b28da2
--- /dev/null
+++ b/testing/cmocka/.gitignore
@@ -0,0 +1 @@
+/cmocka
diff --git a/testing/cmocka/Makefile b/testing/cmocka/Makefile
index e7266706f..794a31db7 100644
--- a/testing/cmocka/Makefile
+++ b/testing/cmocka/Makefile
@@ -22,6 +22,8 @@ include $(APPDIR)/Make.defs
CSRCS += $(wildcard cmocka/src/*.c)
CFLAGS += -Dprint_error=nx_print_error
+CFLAGS += -DCMOCKA_PLATFORM_INCLUDE
+CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/testing/cmocka
PROGNAME = $(CONFIG_TESTING_CMOCKA_PROGNAME)
PRIORITY = $(CONFIG_TESTING_CMOCKA_PRIORITY)
diff --git a/testing/cmocka/cmocka_main.c b/testing/cmocka/cmocka_main.c
index 8c72584d3..7a189fcb4 100644
--- a/testing/cmocka/cmocka_main.c
+++ b/testing/cmocka/cmocka_main.c
@@ -48,9 +48,9 @@ int main(int argc, FAR char *argv[])
const char prefix[] = CONFIG_TESTING_CMOCKA_PROGNAME"_";
FAR const struct builtin_s *builtin;
int len = strlen(prefix);
- FAR char *bypass[argc];
- FAR char *cases[argc];
- FAR char *skip[argc];
+ FAR char *bypass[argc + 1];
+ FAR char *cases[argc + 1];
+ FAR char *skip[argc + 1];
int num_bypass = 1;
int num_cases = 0;
int num_skip = 0;
diff --git a/testing/cmocka/cmocka_platform.h b/testing/cmocka/cmocka_platform.h
new file mode 100644
index 000000000..e452615db
--- /dev/null
+++ b/testing/cmocka/cmocka_platform.h
@@ -0,0 +1,37 @@
+/****************************************************************************
+ * apps/testing/cmocka/cmocka_platform.h
+ *
+ * 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
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+#ifndef __APPS_TESTING_CMOCKA_CMOCKA_PLATFORM_H
+#define __APPS_TESTING_CMOCKA_CMOCKA_PLATFORM_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <syslog.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define cmocka_vprint_message(f,a) vsyslog(LOG_INFO,f,a)
+#define cmocka_vprint_error(f,a) vsyslog(LOG_ERR,f,a)
+
+#endif /* __APPS_TESTING_CMOCKA_CMOCKA_PLATFORM_H */