summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorssugiura <ssugiura@jp.adit-jv.com>2021-01-25 05:22:48 +0000
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2021-10-05 11:19:26 +0900
commitcf79abb110c7ff8b5b75c6f48beeddd9d92dfbd3 (patch)
tree987909a796700d018cddcdf196fd238967616f5a /src
parentd2200fc25e3ae0c04e349a80b979476ee156d215 (diff)
downloadDLT-daemon-cf79abb110c7ff8b5b75c6f48beeddd9d92dfbd3.tar.gz
Implemention of tests for the dlt-qnx-system module
Following files are added to execute and verify the behavior of dlt-qnx-system module: - dlt-test-qnx-system: A test binary to send log messages to slogger2 with specific number of log messages, delay, and payload length. - start-qnx-system-test: A shell script to invoke the test execution and verify its result from received DLT log. Signed-Off By: Saya Sugiura <ssugiura@jp.adit-jv.com>
Diffstat (limited to 'src')
-rw-r--r--src/tests/CMakeLists.txt10
-rw-r--r--src/tests/dlt-test-qnx-slogger.c135
2 files changed, 145 insertions, 0 deletions
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
index 54151ea..9744fc0 100644
--- a/src/tests/CMakeLists.txt
+++ b/src/tests/CMakeLists.txt
@@ -46,5 +46,15 @@ foreach(target
COMPONENT base)
endforeach()
+if(WITH_DLT_QNX_SYSTEM)
+ set(dlt-test-qnx-slogger_SRCS dlt-test-qnx-slogger.c)
+ add_executable(dlt-test-qnx-slogger ${dlt-test-qnx-slogger_SRCS})
+ target_link_libraries(dlt-test-qnx-slogger dlt)
+ set_target_properties(dlt-test-qnx-slogger PROPERTIES LINKER_LANGUAGE C)
+ install(TARGETS dlt-test-qnx-slogger
+ RUNTIME DESTINATION bin
+ COMPONENT base)
+endif()
+
install(FILES dlt-test-filetransfer-file dlt-test-filetransfer-image.png
DESTINATION share/dlt-filetransfer)
diff --git a/src/tests/dlt-test-qnx-slogger.c b/src/tests/dlt-test-qnx-slogger.c
new file mode 100644
index 0000000..973fbe0
--- /dev/null
+++ b/src/tests/dlt-test-qnx-slogger.c
@@ -0,0 +1,135 @@
+/*
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2021 Advanced Driver Information Technology.
+ * This code is developed by Advanced Driver Information Technology.
+ * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+ *
+ * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
+ *
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License (MPL), v. 2.0.
+ * If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * For further information see http://www.genivi.org/.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/slog.h>
+#include <sys/slogcodes.h>
+
+#include "dlt.h"
+#include "dlt_common.h" /* for dlt_get_version() */
+
+#define COUNT 10
+#define DELAY 500
+#define LENGTH 100
+
+void usage()
+{
+ char version[255];
+
+ dlt_get_version(version, 255);
+
+ printf("Usage: dlt-test-qnx-slogger [options]\n");
+ printf("Generate messages and send them to slogger2\n");
+ printf("%s\n", version);
+ printf("Options:\n");
+ printf(" -h Usage\n");
+ printf(" -n count Number of messages to be generated (Default: %d)\n", COUNT);
+ printf(" -d delay Milliseconds to wait between sending messages (Default: %d)\n", DELAY);
+ printf(" -l length Message payload length (Default: %d bytes)\n", LENGTH);
+}
+
+int main(int argc, char *argv[]) {
+ int i = 0;
+ int count = COUNT;
+ int delay = DELAY;
+ int length = LENGTH;
+ char *str = NULL;
+ struct timespec ts;
+
+ int c;
+
+ while ((c = getopt(argc, argv, "hn:d:l:")) != -1)
+ {
+ switch(c)
+ {
+ case 'n':
+ {
+ count = atoi(optarg);
+ break;
+ }
+ case 'd':
+ {
+ delay = atoi(optarg);
+ break;
+ }
+ case 'l':
+ {
+ length = atoi(optarg);
+ break;
+ }
+ case 'h':
+ {
+ usage();
+ return -1;
+ }
+ case '?':
+ {
+ if ((optopt == 'n') || (optopt == 'd') || (optopt == 'l'))
+ fprintf(stderr, "Option -%c requires an argument\n", optopt);
+ else if (isprint(optopt))
+ fprintf(stderr, "Unknown option `-%c`\n", optopt);
+ else
+ fprintf(stderr, "Unknown option character `\\x%x`\n", optopt);
+
+ /* unknown or wrong option used, show usage information and terminate */
+ usage();
+ return -1;
+ }
+ default:
+ {
+ usage();
+ return -1;
+ }
+ }
+ }
+
+ /* Generate string */
+ if (length > 0)
+ {
+ str = (char *) malloc((size_t) length + 1);
+ if (str == NULL)
+ {
+ fprintf(stderr, "Cannot allocate memory\n");
+ return -1;
+ }
+ memset(str, 'X', (size_t) length);
+ str[length] = '\n';
+ }
+
+ /* Calculate delay */
+ if (delay > 0) {
+ ts.tv_sec = delay / 1000;
+ ts.tv_nsec = (delay % 1000) * 1000000;
+ }
+
+
+ for (i = 0; i < count; i++)
+ {
+ slogf(_SLOG_SETCODE(_SLOGC_TEST, 0), _SLOG_INFO, "%s", str);
+ nanosleep(&ts, NULL);
+ }
+
+ if (str != NULL)
+ {
+ free(str);
+ str = NULL;
+ }
+
+ return 0;
+}