From ac3a843847ed6ae5bf42b122ea9c4f8b29aefb3c Mon Sep 17 00:00:00 2001 From: Minh Quang Luu <50074497+minminlittleshrimp@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:11:23 +0700 Subject: [PATCH] Rework logstorage (#545) * logstorage: rework "Logstorage changes" + Correct alignment in CMake options + Reactivate logstorage features unittest + Remove unregister forbidden commit and unit test + Fix logstorage file name unset when no counter available + Remove conflicted parts in dlt_user + Remove unnecessary test case in user Signed-off-by: Le Van Khanh Signed-off-by: LUU QUANG MINH * CI/CD: retrigger failed test cases in verbose mode In github Action, rerun all failed test cases for debugging purpose Signed-off-by: LUU QUANG MINH * unittest: modify logd converter test framework + Remove all config files + Setup environment in CMakelist + Remove system call inside test suites + Reactivate last test in user Signed-off-by: LUU QUANG MINH * Correct typo and +1 for strncpy Signed-off-by: minmin.littleshrimp * cmake: correct syntax linking against zlib in daemon Since the switching of mordern CMake target-based linking approach from -zl to ZLIB::ZLIB (flag -> target), the structure must follow: find_package() set() This is because finding package will create target and then calling ZLIB::ZLIB is refering to that created target. Hence, swap process to comply with the rule. Signed-off-by: minmin.littleshrimp --------- Signed-off-by: Le Van Khanh Signed-off-by: LUU QUANG MINH Signed-off-by: minmin.littleshrimp Co-authored-by: Le Van Khanh Co-authored-by: LUU QUANG MINH --- .github/workflows/cmake-ctest.yml | 2 +- CMakeLists.txt | 44 +- doc/design/dlt_offline_logstorage_design.md | 740 ------------------ include/dlt/dlt-logd-converter.hpp | 8 +- src/android/dlt-logd-converter.conf | 1 - src/console/dlt-convert.c | 20 +- src/daemon/dlt_daemon_offline_logstorage.c | 2 +- src/lib/dlt_user.c | 19 +- .../dlt_offline_logstorage.h | 5 +- .../dlt_offline_logstorage_behavior.c | 76 +- ...dlt_offline_logstorage_behavior_internal.h | 7 +- tests/CMakeLists.txt | 35 +- tests/component/disable_network/dlt.conf | 7 - .../disable_network/dlt_message_filter.conf | 10 - .../dlt-logd-converter/CMakeLists.txt | 15 - .../dlt-logd-converter/dlt-logdctxt.json | 18 - .../lib/context_unreg_forbid/CMakeLists.txt | 22 - .../lib/context_unreg_forbid/dlt.conf.in | 2 - tests/component/logstorage/CMakeLists.txt | 1 - .../logstorage_fsync/dlt_message_filter.conf | 10 - .../logstorage_multi_file/dlt.conf.in | 7 - .../logstorage_one_file/dlt.conf.in | 7 - tests/component/logstorage_filepath/dlt.conf | 7 - .../dlt_message_filter.conf | 10 - .../logstorage_max_cache_size/dlt.conf | 8 - .../dlt_message_filter.conf | 10 - .../component/logstorage_multi_file/dlt.conf | 7 - .../dlt_message_filter.conf | 10 - tests/component/logstorage_one_file/dlt.conf | 7 - .../dlt_message_filter.conf | 10 - tests/components/CMakeLists.txt | 2 + .../components/logd-converter/CMakeLists.txt | 28 + .../abnormal-dlt-logd-converter.conf | 0 .../logd-converter}/dlt-logd-converter.conf | 0 .../logd-converter/dlt-logdctxt.json | 18 + .../gtest_dlt_logd_converter.cpp | 36 +- .../logstorage}/CMakeLists.txt | 3 +- .../disable_network/CMakeLists.txt | 5 +- .../disable_network/disable_network.cpp | 0 .../logstorage/disable_network}/dlt.conf.in | 1 - .../disable_network/dlt_logstorage.conf | 0 .../logstorage_filepath/CMakeLists.txt | 5 +- .../logstorage_filepath/dlt.conf.in | 1 - .../logstorage_filepath/dlt_logstorage.conf | 0 .../logstorage_filepath.cpp | 4 +- .../logstorage_fsync/CMakeLists.txt | 5 +- .../logstorage/logstorage_fsync}/dlt.conf.in | 1 - .../logstorage_fsync/dlt_logstorage.conf | 0 .../logstorage/logstorage_fsync/logfsync.cpp | 0 .../logstorage_fsync/logstorage_fsync.cpp | 0 .../logstorage_max_cache_size/CMakeLists.txt | 9 +- .../logstorage_max_cache_size/dlt.conf.in | 1 - .../dlt_logstorage.conf | 8 +- .../logstorage_max_cache_size.cpp | 0 .../logstorage_multi_file/CMakeLists.txt | 7 +- .../logstorage_multi_file/dlt.conf.in | 6 + .../logstorage_multi_file/dlt_logstorage.conf | 0 .../logstorage_multi_file.cpp | 0 .../logstorage_one_file/CMakeLists.txt | 7 +- .../logstorage_one_file/dlt.conf.in | 8 + .../logstorage_one_file/dlt_logstorage.conf | 0 .../logstorage_one_file.cpp | 0 tests/gtest_dlt_user.cpp | 3 - tests/test_dlt.conf | 7 + 64 files changed, 236 insertions(+), 1056 deletions(-) delete mode 100644 doc/design/dlt_offline_logstorage_design.md delete mode 100644 tests/component/disable_network/dlt.conf delete mode 100644 tests/component/disable_network/dlt_message_filter.conf delete mode 100644 tests/component/dlt-logd-converter/CMakeLists.txt delete mode 100644 tests/component/dlt-logd-converter/dlt-logdctxt.json delete mode 100644 tests/component/lib/context_unreg_forbid/CMakeLists.txt delete mode 100644 tests/component/lib/context_unreg_forbid/dlt.conf.in delete mode 100644 tests/component/logstorage/CMakeLists.txt delete mode 100644 tests/component/logstorage/logstorage_fsync/dlt_message_filter.conf delete mode 100644 tests/component/logstorage/logstorage_multi_file/dlt.conf.in delete mode 100644 tests/component/logstorage/logstorage_one_file/dlt.conf.in delete mode 100644 tests/component/logstorage_filepath/dlt.conf delete mode 100644 tests/component/logstorage_filepath/dlt_message_filter.conf delete mode 100644 tests/component/logstorage_max_cache_size/dlt.conf delete mode 100644 tests/component/logstorage_max_cache_size/dlt_message_filter.conf delete mode 100644 tests/component/logstorage_multi_file/dlt.conf delete mode 100644 tests/component/logstorage_multi_file/dlt_message_filter.conf delete mode 100644 tests/component/logstorage_one_file/dlt.conf delete mode 100644 tests/component/logstorage_one_file/dlt_message_filter.conf create mode 100644 tests/components/CMakeLists.txt create mode 100644 tests/components/logd-converter/CMakeLists.txt rename tests/{component/dlt-logd-converter => components/logd-converter}/abnormal-dlt-logd-converter.conf (100%) rename tests/{component/dlt-logd-converter => components/logd-converter}/dlt-logd-converter.conf (100%) create mode 100644 tests/components/logd-converter/dlt-logdctxt.json rename tests/{component/dlt-logd-converter => components/logd-converter}/gtest_dlt_logd_converter.cpp (94%) rename tests/{component => components/logstorage}/CMakeLists.txt (84%) rename tests/{component => components/logstorage}/disable_network/CMakeLists.txt (90%) rename tests/{component => components/logstorage}/disable_network/disable_network.cpp (100%) rename tests/{component/logstorage/logstorage_fsync => components/logstorage/disable_network}/dlt.conf.in (65%) rename tests/{component => components/logstorage}/disable_network/dlt_logstorage.conf (100%) rename tests/{component => components/logstorage}/logstorage_filepath/CMakeLists.txt (90%) rename tests/{component => components}/logstorage/logstorage_filepath/dlt.conf.in (65%) rename tests/{component => components/logstorage}/logstorage_filepath/dlt_logstorage.conf (100%) rename tests/{component => components/logstorage}/logstorage_filepath/logstorage_filepath.cpp (92%) rename tests/{component => components}/logstorage/logstorage_fsync/CMakeLists.txt (85%) rename tests/{component/logstorage/disable_network => components/logstorage/logstorage_fsync}/dlt.conf.in (65%) rename tests/{component => components}/logstorage/logstorage_fsync/dlt_logstorage.conf (100%) rename tests/{component => components}/logstorage/logstorage_fsync/logfsync.cpp (100%) rename tests/{component => components}/logstorage/logstorage_fsync/logstorage_fsync.cpp (100%) rename tests/{component => components/logstorage}/logstorage_max_cache_size/CMakeLists.txt (78%) rename tests/{component => components}/logstorage/logstorage_max_cache_size/dlt.conf.in (65%) rename tests/{component => components/logstorage}/logstorage_max_cache_size/dlt_logstorage.conf (90%) rename tests/{component => components/logstorage}/logstorage_max_cache_size/logstorage_max_cache_size.cpp (100%) rename tests/{component => components/logstorage}/logstorage_multi_file/CMakeLists.txt (95%) create mode 100644 tests/components/logstorage/logstorage_multi_file/dlt.conf.in rename tests/{component => components/logstorage}/logstorage_multi_file/dlt_logstorage.conf (100%) rename tests/{component => components/logstorage}/logstorage_multi_file/logstorage_multi_file.cpp (100%) rename tests/{component => components/logstorage}/logstorage_one_file/CMakeLists.txt (94%) create mode 100644 tests/components/logstorage/logstorage_one_file/dlt.conf.in rename tests/{component => components/logstorage}/logstorage_one_file/dlt_logstorage.conf (100%) rename tests/{component => components/logstorage}/logstorage_one_file/logstorage_one_file.cpp (100%) create mode 100644 tests/test_dlt.conf diff --git a/.github/workflows/cmake-ctest.yml b/.github/workflows/cmake-ctest.yml index c1f469f6..d06044c9 100644 --- a/.github/workflows/cmake-ctest.yml +++ b/.github/workflows/cmake-ctest.yml @@ -34,7 +34,7 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build - run: ctest -C ${{env.BUILD_TYPE}} + run: ctest -C ${{env.BUILD_TYPE}} --rerun-failed --output-on-failure - name: Install dependencies run: sudo apt-get install lcov diff --git a/CMakeLists.txt b/CMakeLists.txt index 6031725f..4eaeabb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,20 +98,21 @@ set(DLT_USER "covesa" set(DLT_QNX_SLOG_ADAPTER_WAIT_BUFFER_TIMEOUT_MS "100" CACHE STRING "Timeout in milliseconds to wait before messages are dropped when input buffer is full") -option(WITH_DLT_PKGCONFIG "Set to ON to generate pkgconfig .pc files" ON) -option(WITH_DLT_CXX11_EXT "Set to ON to build C++11 extensions" OFF) -option(WITH_DLT_COREDUMPHANDLER "EXPERIMENTAL! Set to ON to build src/core_dump_handler binaries. EXPERIMENTAL" OFF) -option(WITH_DLT_LOGSTORAGE_CTRL_UDEV "PROTOTYPE! Set to ON to build logstorage control application with udev support" OFF) -option(WITH_DLT_LOGSTORAGE_GZIP "Set to ON to build logstorage control application with gzip compression support" OFF) -option(WITH_DLT_USE_IPv6 "Set to ON for IPv6 support" ON) -option(WITH_DLT_KPI "Set to ON to build src/kpi binaries" OFF) -option(WITH_DLT_FATAL_LOG_TRAP "Set to ON to enable DLT_LOG_FATAL trap(trigger segv inside dlt-user library)" OFF) -option(WITH_UDP_CONNECTION "Set to ON to enable dlt UDP multicast SUPPORT" OFF) -option(WITH_LIB_NO_VERSION "Set to ON to build library without any version" OFF) -option(WITH_LIB_SHORT_VERSION "Set to ON to build library with only major number in version" OFF) -option(WITH_DLT_DISABLE_MACRO "Set to ON to build code without Macro interface support" OFF) -option(WITH_LEGACY_INCLUDE_PATH "Set to ON to add /dlt to include paths for the CMake config file, in addition to only " ON) -option(WITH_EXTENDED_FILTERING "Set to OFF to build without extended filtering. Using json filter files is only supported for Linux based system with json-c and QNX." OFF) +option(WITH_DLT_PKGCONFIG "Set to ON to generate pkgconfig .pc files" ON) +option(WITH_DLT_CXX11_EXT "Set to ON to build C++11 extensions" OFF) +option(WITH_DLT_COREDUMPHANDLER "EXPERIMENTAL! Set to ON to build src/core_dump_handler binaries. EXPERIMENTAL" OFF) +option(WITH_DLT_LOGSTORAGE_CTRL_UDEV "PROTOTYPE! Set to ON to build logstorage control with udev support" OFF) +option(WITH_DLT_LOGSTORAGE_GZIP "Set to ON to build logstorage control with gzip compression support" OFF) +option(WITH_DLT_USE_IPv6 "Set to ON for IPv6 support" ON) +option(WITH_DLT_KPI "Set to ON to build src/kpi binaries" OFF) +option(WITH_DLT_FATAL_LOG_TRAP "Set to ON to enable DLT_LOG_FATAL trap(trigger segv inside dlt-user library)" OFF) +option(WITH_UDP_CONNECTION "Set to ON to enable dlt UDP multicast SUPPORT" OFF) +option(WITH_LIB_SHORT_VERSION "Set to ON to build library with only major number in version" OFF) +option(WITH_DLT_DISABLE_MACRO "Set to ON to build code without Macro interface support" OFF) +option(WITH_LEGACY_INCLUDE_PATH "Set to ON to add /dlt to include paths + for the CMake config file, in addition to only " ON) +option(WITH_EXTENDED_FILTERING "Set to OFF to build without extended filtering. + Json filter only supports Linux based system with json-c and QNX" OFF) option(WITH_DLT_DAEMON_VSOCK_IPC "Set to ON to enable VSOCK support in daemon" OFF) option(WITH_DLT_LIB_VSOCK_IPC "Set to ON to enable VSOCK support in library (DLT_IPC is not used in library)" OFF) @@ -124,17 +125,17 @@ set(DLT_WRITEV_TIMEOUT_USEC "0" CACHE STRING "Set usec timeout for writev to prevent blocking indefinitely") # RPM settings -set(COVESA_RPM_RELEASE "1") # ${DLT_REVISION}") +set(COVESA_RPM_RELEASE "1") # ${DLT_REVISION} set(LICENSE "Mozilla Public License Version 2.0") # Build, project and include settings find_package(Threads REQUIRED) if(WITH_DLT_LOGSTORAGE_GZIP) - set(ZLIB_LIBRARY "ZLIB::ZLIB") find_package(ZLIB 1.2.9 REQUIRED) -elseif(WITH_DLT_COREDUMPHANDLER OR WITH_DLT_FILETRANSFER) set(ZLIB_LIBRARY "ZLIB::ZLIB") +elseif(WITH_DLT_COREDUMPHANDLER OR WITH_DLT_FILETRANSFER) find_package(ZLIB REQUIRED) + set(ZLIB_LIBRARY "ZLIB::ZLIB") else() set(ZLIB_LIBRARY "") endif() @@ -354,7 +355,8 @@ if(WITH_EXTENDED_FILTERING) elseif("${CMAKE_SYSTEM_NAME}" MATCHES "QNX") set(DLT_JSON_LIBRARY json) else() - message(FATAL_ERROR "OS does not support extended filtering. Please build without cmake option '-DWITH_EXTENDED_FILTERING=OFF'") + message(FATAL_ERROR "OS does not support extended filtering. + Please build without cmake option '-DWITH_EXTENDED_FILTERING=OFF'") endif() add_definitions(-DEXTENDED_FILTERING) else() @@ -381,7 +383,8 @@ if(WITH_DLT_UNIT_TESTS) execute_process(COMMAND pkg-config --modversion gtest OUTPUT_VARIABLE GTEST_VERSION) string(REPLACE "\n" "" GTEST_VERSION ${GTEST_VERSION}) if(${GTEST_VERSION} VERSION_LESS 1.7.0) - message(WARNING "Please use Gtest version greater or equal to 1.7.0, or use option 'WITH_GIT_SUBMODULE' for latest version") + message(WARNING "Please use Gtest version greater or equal to 1.7.0, + or use option 'WITH_GIT_SUBMODULE' for latest version") endif() else() message(STATUS "No Gtest package found, preparing submodule ...") @@ -396,7 +399,8 @@ if(WITH_DLT_UNIT_TESTS) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} RESULT_VARIABLE GIT_SUBMOD_RESULT) if(NOT GIT_SUBMOD_RESULT EQUAL "0") - message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}. Please checkout submodule") + message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}. + Please checkout submodule") endif() endif() diff --git a/doc/design/dlt_offline_logstorage_design.md b/doc/design/dlt_offline_logstorage_design.md deleted file mode 100644 index 570f6afe..00000000 --- a/doc/design/dlt_offline_logstorage_design.md +++ /dev/null @@ -1,740 +0,0 @@ -# DLT Offline Logstorage Design Specification - -Back to [README.md](../../README.md) - -## Executive Summary - -This document describes DLT Offline Logstorage feature. It includes software -architecture and design. DLT Offline Logstorage offers the possibility to store -application logs on different storage devices by just plug-in the storage device -into the target. The configuration of what log messages will be stored is read -from a special configuration file which has to be installed on the storage -device before inserting into the target. - -Usage is available in [dlt_offline_logstorage.md](../dlt_offline_logstorage.md). - -## Scope - -This document is written to understand design and implementation, and should -help to use DLT Logstorage feature in the correct way. - -## Requirements - -## Design Considerations - -The following points are considered for the design of Offline Logstorage: - -**Reusability** - -The existing implementation of the DLT shall be reused with minor modification -and adaptation of the existing DLT design. - -**Portability** - -It shall be ensured that while updating the DLT source code care is taken not to -alter the platform dependencies of the existing DLT; thereby maintaining the -portability design in DLT. - -**API consistency** - -The interface between DLT Daemon, DLT Client and DLT applications shall not be -changed. - -## Architecture - -This chapter gives an overview of Offline Logstorage architecture inside DLT. -More details of design itself are given in later session. - -### Use Case View - -#### Configuration - -Use Case | Configuration ------ | ---- -Responsibilities | *DLT Daemon*: Apply log level filter, Change Offline Logstorage configuration, Store log message to device, *System Monitoring Instance*: Informs DLT Daemon about storage device -Trigger | Storage device is plugged into the system -Pre-Condition | Storage device contains a configuration file -Result | DLT Daemon is configured to store logs of configured applications into files on storage device -Exceptions | - -Variants | - - -#### Log to storage device - -Use Case | Log to storage device ------ | ---- -Responsibilities | *Application*: Log message, *DLT Daemon*: Apply log level filter, Store log message to device -Trigger | Application starts logging message through DLT interface -Pre-Condition | Storage device inserted and Logstorage configuration done -Result | Log message is stored in file on storage device -Exceptions | - -Variants | - - -#### Log to FLASH storage device - -Use Case | Log to FLASH storage device ------ | ---- -Responsibilities | *Application*: Log message, *DLT Daemon*: Apply log level filter, Store log messages in RAM, Store log message to device on a specific event -Trigger | Application starts logging message through DLT interface -Pre-Condition | DLT Daemon is configured to use a folder on the FLASH storage as Offline Logstorage device -Result | Log message is stored in file on storage device -Exceptions | - -Variants | - - -#### Update Log Level in Passive Node - -Use Case | Update Log Level in Passive Node ------ | ---- -Responsibilities | *User* Creates DLT Logstorage Configuration file, Stores DLT Logstorage Configuration file on a storage device, Notifies DLT Daemon to attach DLT Logstorage device (e.g. via HMI), *DLT Daemon*: Validates DLT Logstorage Configuration File, Sends Log Level change request to Application via connected passive Node DLT Daemon Application (DLT Library), Activates the received Log Level -Trigger | Notification send to DLT Daemon (e.g. via HMI) to activate a DLT Logstorage device -Pre-Condition | Storage device contains a configuration file, Configured storage location is writeable by DLT Daemon -Result | Application has updated the Log Level -Exceptions | DLT Logstorage Configuration file is missing or invalid, Configured storage location is not writable by DLT Daemon, The configured Application is not running, The configured node (ECU Identifier) is not connected -Variants | - - -#### Store Non-Verbose Log message - -Use Case | Store Non-Verbose Log Message ------ | ---- -Responsibilities | *Application*: Sends DLT Non-Verbose Log Message, *DLT Daemon*: Receives DLT Non-Verbose Log Message, Filters DLT Non-Verbose Log Message based on ECU identifier, Writes DLT Non-Verbose Log Message into configured log file -Trigger | Application reaches a state that results in sending a Log Message -Pre-Condition | Log Level is configured, Storage location is writable by DLT Daemon -Result | DLT Non-Verbose Log Message stored in log file -Exceptions | Received Log Message is filtered (no valid filter configuration found) -Variants | - - -### External View -DLT consists of the DLT Daemon which acts as central component of DLT. It is -responsible for receiving logs from applications and forwarding them to -connected DLT clients. In case of Logstorage, the logs are filtered and stored -directly into files on storage devices depending on given configuration. - -![External view](images/logstorage/dlt_logstorage_external.png "External view") - -The DLT Daemon furthermore provides an interface to send control messages to the -DLT Daemon or connected applications. This interface is used by DLT Offline -Logstorage. When the DLT Offline Logstorage Control Application is triggered due -to an attached storage device or executed by another application, it informs the -DLT Daemon about attached storage devices. The DLT Daemon will then read the -configuration file and start storing log messages to the device. The system has -to make sure that the device is mounted as read-write; otherwise no logs will be -stored onto the device. When a used device is removed, the Logstorage Control -application is triggered again and informs the DLT Daemon about the removal. The -DLT Daemon will stop storing logs onto the removed device. The extended -functionality is that the DLT Logstorage Configuration file might contain a -specific Log Level configuration for DLT Applications running on a Passive Node. -In this case, the Gateway DLT Daemon has to send a Log Level Change Control -message to the connected Passive DLT Daemon. The Passive DLT Daemon afterwards -forwards this request to the DLT Application itself. The DLT Application finally -configures its Log Level. Log messages sent by applications running on the -Passive Node are forwarded to the Gateway DLT Daemon via Passive DLT Daemon and -finally stored inside a DLT Logstorage Storage Device. - -## Interface Description - -There are no changes in the interface to DLT applications, but the description -of configuration file for Logstorage logging is given here. Internal design is -explained in later session. - -### Logstorage configuration file - -The Logstorage configuration file will provide the user with configurable -options to setup device settings, log filters and storage locations of the log -messages. To easily implement applications for creating project specific -configuration files, the used file format is INI. An example configuration file -describing all configuration parameters can be found below. Mandatory name of -the configuration file is: ***dlt_logstorage.conf***. - -``` -[FILTER1] -LogAppName=APP1 -ContextName=CON1,CON2 -LogLevel=DLT_LOG_INFO -File=App -FileSize=10000 -NOFiles=10 - -[FILTER2] -LogAppName=TEST -ContextName=.* -LogLevel=DLT_LOG_ERROR -File=Test -FileSize=250000 -NOFiles=5 -EcuID=ECU2 -SyncBehavior=ON_SPECIFIC_SIZE -SpecificSize=5000 - -[FILTER3] -LogAppName=TEST -ContextName=.* -LogLevel=DLT_LOG_ERROR -File=Test -FileSize=250000 -NOFiles=5 -SyncBehavior=ON_FILE_SIZE,ON_DEMAND -EcuID=ECU1 -``` - -As seen in example configuration file, a filter configuration consists of -- A **unique name** of the filter (for a certain storage device) -- **LogAppName**: Name of application to store logs from. Multiple applications - can be separated by ",". ".*" denotes all applications -- **ContextName**: Name or names of contexts to store logs from. Multiple - contexts can be separated by ",". ".*" denotes all contexts of the application -- **LogLevel**: Define log level -- **File**: Base name of the created files that containing the logs. -- **FileSize**: File size in bytes -- **NOFiles**: Number of created files before oldest is deleted and a new one is - created. The numbering will continue. E.g. If 10 files have to be created and - the first is deleted, the next one is *_011_.dlt* -- **EcuID (optional)**: Only handle messages coming from the specified ECU. -- **SyncBehavior (optional)**: Sync behavior of the Filter configuration. It is - possible to add a list of Sync strategies. -- **SpecificSize (optional)**: Size in bytes when messages are synced to files - when SyncBehavior is set to ON\_SPECIFIC\_SIZE - -**Note**: Not allowed is the combination of wildcards for LogAppName and -ContextName if EcuID is not specified. - -``` -[NON-VERBOSE-STORAGE-FILTER1] -EcuID=PASV -File=scc -FileSize=50000 -NOFiles=5 -[NON-VERBOSE-LOGLEVEL-CTRL1] -LogAppName=LOG -ContextName=TEST -LogLevel=DLT_LOG_DEBUG -EcuID=PASV -[NON-VERBOSE-LOGLEVEL-CTRL2] -LogAppName=.* -ContextName=.* -LogLevel=DLT_LOG_WARN -EcuID=PASV -``` - -In case of Non-Verbose Mode, two different configuration sections exist. -*[NON-VERBOSE-STORAGE-FILTER1]* describes where log messages of a Non-Verbose -passive Node (here: PASV) are stored. Furthermore, a configuration section to -control the log level of Non-Verbose applications exists. Either a log level for -a specific application/context can be defined (*[NON-VERBOSE=LOGLEVEL-CTRL1]*) -or the log level of all registered applications can be changed -(*[NON-VERBOSE=LOGLEVEL-CTRL2]*). - -### Offline Logstorage Control messages - -The DLT Daemon can be controlled with a standard set of control messages. To -control Offline Logstorage, the following control messages are added. - -- **DLT_SERVICE_ID_OFFLINE_LOGSTORAGE** - Send request to DLT Daemon to either enable or disable a Logstorage device - defined by its mount path. Conntection Types are: 0-Disconnect, 1-Connect, and - 2-Sync caches - - Parameter: - - ``` - typedef struct - { - uint32_t service_id; /**< service ID */ - char mount_point[DLT_MOUNT_PATH_MAX]; /**< storage device mount point */ - uint8_t connection_type; /**< connection status of the connected device connected/disconnected */ - char comid[DLT_ID_SIZE]; /**< communication interface */ - } DLT_PACKED DltServiceOfflineLogstorage; - ``` - -## Design - -It is not intended to describe the design of DLT itself before explaining the -DLT Offline Logstorage feature. Therefore it is necessary for the reader to have -good understanding of DLT's internal design to understand the design of DLT -Offline Logstorage. - -### Structural View - -![DLT Offline Logstorage inside DLT Daemon](images/logstorage/dlt_logstorage_structural.png "DLT Offline Logstorage inside DLT Daemon") - -DLT Daemon consists mainly of two parts: the LogProducer and a set of -LogConsumers. The LogProducer inside DLT acts as backend to libdlt.so which can -be seen as the implementation of the LogProducer frontend. Log messages are -filtered inside the LogProducer frontend based on the configured log level of -the context. The LogProducer backend inside DLT Daemon maintains tables of -connected applications and contexts to be able to send messages to the connected -DLT applications. This is used by DLT Offline Storage to change the log levels -of applications. A LogConsumer inside DLT Daemon forwards log messages to -connected DLT clients. When a DLT client connects to the Daemon, the DLT Daemon -opens the corresponding interface. In case of a connected DLT Viewer, a -TcpLogConsumer (socket connection over TCP/IP) or a SerialLogConsumer is used. -Each LogConsumer maintains its own ConsumerInfoTable. In case of DLT Offline -Logstorage, no external DLT Client is connected. Then DLT Daemon acts as DLT -Client by itself. This is done by implementing DLT Offline Logstorage as another -LogConsumer. For each LogConsumer (Storage Device) an -OfflineLogstorageConsumerInfoTable with following content is maintained: -- **Log storage file path**: Path to file system location for storing sets of - log files for that configuration. -- **File size**: The maximum size in bytes which each file in the set must reach - before a new file is created. -- **Total number of log files**: The total number of files to be created for the - set of files. If this number is reached, the first file is deleted and a new - file is created. -- **Log level**: The log level which a message needs to have to be stored -- **Application and Context Identifier**: Application and Context names to know - from which applications and contexts logs shall be stored. - -#### Application and context information - -The DLT Daemon maintains a list of applications and a list of contexts that are -running on the same ECU. To be able to set and reset log levels of applications -running on passive nodes, the (Gateway) DLT Daemon also has to store information -about applications and contexts running on passive nodes. This is currently not -possible. - -![Application and Context Information Handling](images/logstorage/dlt_logstorage_ap_ct_hdl.png "Application and Context Information Handling") - -The figure above depicts the updated handling of registered application and -context information. The Dlt Daemon will have a reference to a -DltDaemonApplicationList and DltDaemonContextList, instead of handling the data -itself (pointer to DltDaemonApplication, number of registered applications and -ECU identifier the registered users running on). Furthermore, the APIs to add, -delete, find, etc. applications are updated in a way that the dependency to -DltDaemon structure is removed. As a result, it is possible to instantiate the -application list multiple times (one time for each ECU in the system) without -changing the internal implementation of the list handling. - -### Dynamic View - -#### External components - -##### Interaction of Different Modules for Storing Log Messages - -##### Start Storing Log Messages - -![Interaction of different modules to start storing messages](images/logstorage/dlt_logstorage_start_str_msg.png "Interaction of different modules to start storing messages") - -The above diagram shows the interaction of different modules for triggering -storing of log messages in DLT. The user (tester in sequence diagram) inserts -the external device with a configuration file present in it. On plug-in of that -device, the udev Daemon mounts the device to specific DLT Offline Logstorage -location (/tmp/dltlogs/dltlogsdev\) and subsequently executes DLT -Logstorage Control Application with device number and connection status (in this -case *CONNECTED*) to trigger the DLT Daemon to start storing log messages to the -mounted device. The trigger is sent to the DLT Daemon from the DLT Logstorage -Control Application as a Service Request with the service ID of the -*DLT\_LOG\_STORAGE*. The DLT Daemon reads the configuration file from the device -and updates its OfflineLogstorageConsumerInfoTable entries. Then it calculates -the actual log level to be set at the DLT Application context by calculating the -union of log levels for that context from DLT Clients and all Log Storage -OfflineLogstorageConsumerInfoTables. This means, the lowest needed log level -will be set in the Application. E.g. there are two filter configuration set -storing the same log messages, but one of the configurations has DLT\_LOG\_FATAL, -the other DLT\_LOG\_WARN set. To ensure, that the second filter receives log -messages, DLT\_LOG\_WARN needs to be set in the application as log level. Next, -the DLT Daemon sends a DLT\_USER\_Command to all corresponding Applications to -update the log levels of their contexts. Upon receiving the set log level -command the DLT Application re-adjusts its log level and continues to log -messages with newly set log level. When Log messages are now received at the DLT -Daemon from DLT Applications, the DLT forwards the log messages to Offline -Logstorage and it filters the received messages based on the configuration in -its OfflineLogstorageConsumerInfoTable. Finally, the messages are written into -log files on the mounted device. - -##### Stop Storing of Log Messages - -![Interaction of different modules to stop storing log messages](images/logstorage/dlt_logstorage_stop_str_msg.png "Interaction of different modules to stop storing log messages") - -The above diagram shows the interaction of different modules to stop storing of -log messages in DLT using DLT Offline Logstorage feature. The user unplugs the -external device with a configuration file present in it. On unplug of such -device Udev Daemon executes the DLT Logstorage Control Application with device -number and connection status (in this case *DISCONNECTED*) to stop DLT Offline -Logstorage at DLT Daemon. The DLT Logstorage Control Application then sends a -Service Request to the DLT Daemon to trigger the DLT Daemon to stop logging to -the device to be unplugged. The DLT Daemon updates the -OfflineLogstorageConsumerInfoTable entries and also calculates a new log level -of all Application contexts which are affected by this change. Afterwards, the -DLT Daemon sends a command to all affected applications to update the log level -of their respective contexts. Upon receiving the set log level command, the DLT -application re-adjusts its log level and continues to log messages with newly -set log level. Finally, the device is un-mounted by the Udev Daemon. - -#### MultiNode handling - -##### Retrieve information about running application on passive node - -![Request application status](images/logstorage/dlt_logstorage_get_log_info.png "Request application status") - -The Gateway DLT Daemon needs actual information about current status of DLT -applications running on Passive Node. It might be that applications started or -stopped during system run time, so the GET\_LOG\_INFO request needs to be sent -periodically, because new applications/contexts might be registered in the -meanwhile. - -##### DLT Gateway Configuration - -To control the frequency of Passive Node control requests, another entry is -added to a Passive Node configuration. - -``` -[PassiveNode1] -... -; Send following control messages periodically () -SendPeriodicControl=0x03:5,0x05:10 -``` -By using *SendPeriodicControl* the user is able to control what control messages -shall be sent in a specific interval. If multiple control messages shall be sent -periodically, a comma separated list of commands can be specified. - -##### Store information about passive node applications - -Below diagram depicts update of registered applications and contexts of a -passive node DLT Daemon. Triggered by a GET\_LOG\_INFO request send by the -Gateway DLT Daemon, the passive node DLT Daemon sends a GET\_LOG\_INFO response. -The GET\_LOG\_INFO response does not contain any information about stopped -applications. Because of that, to avoid too much maintenance on Gateway DLT -Daemon, the passive node application and context list is cleared at first. While -parsing the GET\_LOG\_INFO response, applications and contexts are added to the -list again. As a result, the Gateway DLT Daemon always holds up-to-date -information about running DLT users on the passive node. - -![Internal update of passive node users](images/logstorage/dlt_logstorage_update_passive.png "Internal update of passive node users") - -##### Update Log Level of application running on Passive Node - -![Update log level](images/logstorage/dlt_logstorage_update_log_level.png "Update log level") - -Triggered by the DLT Logstorage Control application, the Gateway DLT Daemon -configures a new Logstorage device. When a Log Level change of a DLT Application -running on a passive node is requested, the Gateway DLT Daemon sends a control -request to the Passive DLT Daemon containing the information given in the DLT -Logstorage Configuration file. Finally, the request is forwarded to the actual -DLT Application that updates its Log Level. - -##### Store DLT Non-Verbose message in a DLT Logstorage device - -![Store DLT Non-Verbose message](images/logstorage/dlt_logstorage_str_non-verbose_msg.png "Store DLT Non-Verbose message") - -A DLT message is sent by a DLT Application running on a Passive Node to the -Passive DLT Daemon running on the same node. Because the Gateway DLT Daemon is -connected as DLT Client to the Passive DLT Daemon, the Passive DLT Daemon -forwards the log message to the Gateway DLT Daemon as usual. The Gateway DLT -Daemon itself filters the incoming DLT Non-Verbose message by ECU Identifier -(EcuID) and finally stores the message in a log file on the file system. - -#### Internal components - -![DLT Offline Logstorage -Sequence Diagram](images/logstorage/dlt_logstorage_sequence.png "DLT Offline Logstorage -Sequence Diagram") - -The above depicted sequence diagram shows the different stages involved in DLT -Offline Logstorage. The detailed design is explained through following sections -below. - -##### Configuring DLT and Setup Log Levels of Applications - -![DLT Offline Logstorage - Startup and Configure](images/logstorage/dlt_logstorage_startup_conf.png "DLT Offline Logstorage - Startup and Configure") - -This task involves reading of DLT Offline Logstorage configuration file and -updating the OfflineLogstorageConsumerInfoTable (context information table) with -configuration settings. The configuration files are located at preconfigured -locations or on external storage devices. The DLT Daemon reads the configuration -file from that location, adds entries into the -OfflineLogstorageConsumerInfoTable based on the settings provided in the -configuration file. As shown in the above sequence diagram the OfflineLogstorage -Consumer reads configuration (read\_configuration) from Storage Device and -updates the OfflineLogstorageConsumerInfoTable (add\_update\_table\_entry). -For each OfflineLogstorage Consumer (set of log files or device), an -OfflineLogstorageConsumerInfoTable is maintained. When a DLT application context -is registered, the LogProducer obtains the log level of individual application -context from each OfflineLogstorageConsumerInfoTable, makes a union of it and -sets this level as the log level for the context in the ContextTable. This log -level is in turn sent to the DLT application to ensure that the DLT application -sends all logs to OfflineLogstorage. Otherwise relevant log messages might be -filtered in DLT user library. OfflineLogstorage Consumer will obtain all the -stored configuration settings of each application context from -OfflineLogstorageConsumerInfoTable during logging of message from application. -This set log level will be used for filtering at the LogProducer (inside -libdlt.so). - -**Store filter configuration** - -This section describes more in detail what happens during -*add_update_table_entry()*. Internally, a hash table is set up using the -information from the parsed *dlt_logstorage.conf* file. This file contains -different kinds of data: -- Message information - - Application ID (LogAppName) - - Context ID (ContextName) - - Log level (LogLevel) - - Ecu ID (EcuID) -- Storage information - - Base file name (File) - - File size (FileSize) - - Number of files (NOFiles) - - Synchronization behavior (SyncBehavior) - -The basic idea is to describe a mapping between Message information (used as key -and filter criteria) and storage information (used as data). Furthermore, the -message information is used as filter criteria to decide if a certain message -has to be stored or not. - -##### Setup Application Context Log Level - -![Setup Application Context Log Level](images/logstorage/dlt_logstorage_setup_ap_ct_log_level.png "Setup Application Context Log Level") - -When an application using DLT is started, it registers itself at the DLT daemon. -Afterwards, it registers all its contexts. In case of enabled DLT Offline -Logstorage, the DLT Daemon checks if an entry of the registered Application in -one or multiple of the OfflineLogstorageConsumerInfoTables exits. If one or more -entries for the context are found, a union of all configured log levels is -created. This means, the DLT Daemon chooses the lowest configured log level. -Finally the DLT Daemon updates the log level of the registered context to this -log level by calling *set_user_log_level()*. This ensures that logs of a -configured log level are not filtered within the LogProducer (libdlt.so) and -forwarded to the OfflineLogstorage Consumer. - -##### Storing Log Messages to Devices - -![Store Log Information](images/logstorage/dlt_logstorage_str_msg.png "Store Log Information") - -Storing of log messages to devices involves following tasks: -- **Filtering of Log Information**: When DLT applications log information, the - log information is filtered at the LogProducer (inside libdlt.so) based on the - log level the application is configured to use. This is then forwarded by the - LogProducer (receiver inside DLT Daemon) to the OfflineLogstorage Consumer. On - receiving the log information, the OfflineLogstorage Consumer gets the - configured, application name, context name and log level from its - OfflineLogstorageConsumerInfoTable and filters the log information before - storing into the sets of files on the Storage Device. If the configured log - level obtained from OfflineLogstorageConsumerInfoTable is lesser than the log - level of message and application or context name are not present in the - OfflineLogstorageConsumerInfoTable, the OfflineLogstorage Consumer discards - the log message. *Note*: In case multiple devices, the OfflineLogstorage - Consumer obtains the log level from all OfflineLogstorageConsumerInfoTables. - More details on the implementation can be obtained below. -- **Storing Log Information**: After filtering the relevant log messages, the - OfflineLogstorage Consumer will store the log message in a file on the Storage - Device. - -**Filtering of incoming log messages** - -To filter a log message based on information given in the filter configuration, -a linked list is used. A member *key_list* consists of a combination of -application ID and context ID. Since DLT Offline Logstorage supports wildcards -and lists of IDs, the following cases have to be considered: - -If Ecu Identifier is not specified, Filter configuration contains -1. One application ID (App1) and one context ID (Ctx1): Key = ":App1:Ctx1" -2. One application ID (App1), wildcard for context ID: Key = ":App1:" -3. Wildcard of application ID, One context ID (Ctx1): Key = "::Ctx1" -4. Wildcard of application ID, list of context IDs (Ctx1,Ctx2): Keys="Ctx1"," - Ctx2" and the other way around -5. List of application (App1, App2) and context IDs (Ctx1, Ctx2): all - combinations of application ID and context ID are possible. - Keys = ":App1:Ctx1", ":App1:Ctx2", ":App2:Ctx1", ":App2,Ctx2" -6. Both application ID and context ID is not allowed to be set to wildcard. - -Data of a key value pair contains of all information given in -OfflineLogstorageConsumerInfoTable - apart from application ID and context ID. -When a message arrives at the filter, three checks have to be done. It has to be -checked if: -1. The combination of application and context ID is a valid key -2. The application ID is a valid key -3. The context ID is a valid key - -If one or more keys are valid the message is stored in the file of the -corresponding filter. If not, the incoming message will be ignored. In case of a -configured Ecu Identifier (ECU1), the following Keys are generated: -1. One application ID (App1) and one context ID (Ctx1): Key = "ECU1:App1:Ctx1" -2. One application ID (App1), wildcard for context ID: Key = "ECU1:App1:" -3. Wildcard of application ID, One context ID (Ctx1): Key = "ECU1::Ctx1" -4. Wildcard of application ID, list of context IDs (Ctx1,Ctx2): - Keys=" ECU1::Ctx1"," ECU1::Ctx2" and the other way around -5. List of application (App1, App2) and context IDs (Ctx1, Ctx2): all - combinations of application ID and context ID are possible. - Keys = "ECU1:App1:Ctx1", "ECU1:App1:Ctx2", "ECU1:App2:Ctx1", "ECU1:App2:Ctx2" -6. If application ID and context ID is set to wildcard, the following key is - generated: "ECU1::" -7. If application ID and context ID is not present in configuration file, - the following key is generated: "ECU1::" - -The diagram below shows the steps to be done to find files to store an incoming log message. - -![Steps Log Message Filtering](images/logstorage/dlt_logstorage_msg_filter.png "Steps Log Message Filtering") - -When an incoming message is received, it needs to be checked first if the -message is sent in Verbose or Non-Verbose mode. Depending on the mode, different -keys are created to search for valid filter configurations. In case of -Non-Verbose mode, only the following key can be created; "EcuID::", because a -Non-Verbose message usually does not contain any information about Application -and Context ID. In case of Verbose mode, all valid combinations of EcuID, -Application ID and Context ID are generated. The generated keys are used as -input to find valid configuration that contain information about log level, file -location etc. Using the filter information found in the configuration, the log -message gets stored in a file. - -### DLT Offline Logstorage Cache - -Usually, the DLT Offline Logstorage is used to store log information on an -attached external device as described above. Another use case is to store logs -to an internal storage device as described in Use Case View. In this case, -writing every log message to the storage device must be avoided since FLASH -storage devices have a limited number of write cycles. Therefore, the log -messages have to be buffered and synced to disk based on a certain strategy. - -The following strategies exist: -1. **Write every log message (ON_MSG)**: Each log message is persistently - written to the storage device. -2. **Write on close (ON_DAEMON_EXIT)**: Write data to disk before the DLT Daemon - is stopped. -3. **Write on demand (ON_DEMAND)**: Write data on disk whenever the write is - triggered from an external application. -4. **Write on file size reached (ON_FILE_SIZE)**: The log file size for a - specific filter is specified in the DLT Logstorage configuration file. A - memory region with the same size will be allocated and filled with data. - Whenever the buffer is filled with data, this data is written into a log file. -5. **Write after specific size (ON_SPECIFIC_SIZE)**: This is basically the same - as (4), but writes data into a log file after a the incoming data size reached - the specified "write after" data size. -6. **A combination of the above scenarios**: Combinations with ON\_MSG or - combination of ON\_FILE\_SIZE and ON\_SPECIFIC\_SIZE are not allowed. - -Write every log message is the standard DLT Offline Logstorage strategy which -has been discussed in detail above. All other strategies base on having a log -message cache available. - -#### Write on close strategy - -In this scenario, all log messages are stored in a ring buffer with the size -specified in *FileSize*. When the DLT Daemon is terminated, all logs that belong -to filter configurations having the *ON_DAEMON_EXIT* sync strategy enabled are -synced to disk. This is shown in diagram below. The daemon receives a -termination signal which is handled in the installed signal handler. The main -event loop is stopped and the DLT Daemon cleans up all internal data structures. -It calls the *logstorage_cleanup()* function which itself cleans up all active -Logstorage devices. In this stage, every filter configurations configured with -the *ON_DAEMON_EXIT* flag will sync its cached log messages to disk in a new -log file. - -![Sync on daemon exit](images/logstorage/dlt_logstorage_sync_on_daemon_exit.png "Sync on daemon exit") - -#### Write on demand strategy - -In this scenario, all log messages are stored in a ring buffer with the size -specified in *FileSize*. When the DLT Logstorage Control Application sends a -trigger, all logs that belong to filter configurations having the *ON\_DEMAND* -sync strategy enabled are synced to disk. This is shown in diagram below. The -DLT Logstorage Control Application will send a DLT Daemon control command that -is forwarded by the DLT Daemon to the Offline Logstorage. Two different exist: -If the command is sent without a mount point as parameter, all Logstorage caches -configured with the on demand sync strategy are synced to disk. If the command -is sent with a mount point, only the Logstorage caches of the corresponding -Logstorage device are synced to disk. In case the mount point is not valid, the -DLT Daemon returns an error response to the DLT Logstorage Control application. - -![Sync on demand](images/logstorage/dlt_logstorage_sync_on_demand.png "Sync on demand") - -#### Offline Logstorage Ring buffer cache - -Every Offline Logstorage filter configuration will have its own buffer with a -specific size. If the buffer is full and the content was not synced to disk -before, older log messages will be overwritten from the beginning as shown in -diagram below. - -![DLT Offline Logstorage Ring buffer](images/logstorage/dlt_logstorage_ring_buffer.png "DLT Offline Logstorage Ring buffer") - -#### Strategy initialization - -The user can specify which strategies he wants to add to a filter configuration. -Here it must be ensured that *ON_MSG* cannot be combined with any strategy -based on a Logstorage cache. - -For each filter configuration, depend on the value `File`, a list of newest file -which is keeping the data of newest file name and wrap-around id for corresponding -`File`. - -``` -struct DltNewestFileName -{ - char *file_name; /* The unique name of file in whole a dlt_logstorage.conf */ - char *newest_file; /* The real newest name of file which is associated with filename.*/ - unsigned int wrap_id; /* Identifier of wrap around happened for this file_name */ - DltNewestFileName *next; /* Pointer to next */ -}; -``` - -#### Storage preparation based on strategy - -For each Logstorage configuration, the storage preparation step is executed -once. - -In case of *ON\_MSG" strategy, the file on the storage device is created. -The newest file info must be updated to the working file info after preparation. - - -In case of cache based strategies, the file on the storage device is created and -the Logstorage cache (ring buffer) is initialized. - -Following diagram shows the -difference between caching strategy initialization and non-caching *ON_MSG* -strategy. - -![Storage preparation](images/logstorage/dlt_logstorage_preparation.png "Storage preparation") - -#### Storing log messages based on strategy - -The default behavior of Offline Logstorage writes every log message directly -into a file (*ON_MSG*). In case of caching strategies, the log message is -stored into a ring buffer (refer -[Offline Logstorage Ring buffer cache](#Offline-Logstorage-Ring-buffer-cache)). -Following diagram shows the difference between caching strategy initialization -and non-caching *ON_MSG* strategy. - -![Write log message](images/logstorage/dlt_logstorage_wrt_msg.png "Write log message") - -#### Synchronization based on strategy - -The default behavior of Offline Logstorage syncs the file directly after a log -message is written into the file (*ON_MSG*). Before synchronization to file, -the working log file is compared against the log files to ensure that -the log data is written to the newest file. If they are different each other, -the working log file is closed and try to open the newest one for writing. -fsync() is called before fclose() instead of on every message because invoking -it per message basis has too much impact on performance. - -In case of other log strategies, -the ring buffer is synced to a file depending on the configured sync strategies. -The sync function is called from different places in the Logstorage code. -Therefore, the current situation has to be given as parameter. If the filter -configuration is configured with a specific strategy the ring buffer will be -flushed to a file. If the certain strategy is not configured, the function -returns without actually syncing the ring buffer. The action of update log files -is always performed to ensure that the newest file is used to synchronize the data in ring buffer. -The newest file info must be updated to the working file info after sync. - -![Sync messages](images/logstorage/dlt_logstorage_sync_msg.png "Sync messages") - -Syncing the ring buffer includes additional internal steps as shown in diagram -below. - -![Sync ring buffer](images/logstorage/dlt_logstorage_sync_ring_buffer.png "Sync ring buffer") - -## Security - -The current implementation of DLT Offline Logstorage raises the following -security related problems. -1. DLT Offline Logstorage is designed in a way that it is enough to attach an - external storage device to the target containing a valid configuration file to - receive logs from applications. If corresponding udev rules are installed on - the target the storing of log messages starts immediately. Another possibility - to start storing of log messages is to send a trigger through - *dlt-logstorage-ctrl* application to the DLT Daemon. -2. Furthermore, DLT Offline Logstorage chances the configured log level of - applications, which is needed to fulfill its requirements, but generates - security problems. It in a real production system, it may be not allowed to - receive INFO or VERBOSE messages, but the current implementation does not have - any possibility to avoid certain log levels. - -## Known Limitations - -No. | Description ------ | ---- -1 | A combination of wildcards for Application ID ***and*** Context ID is only possible when EcuID is specified. diff --git a/include/dlt/dlt-logd-converter.hpp b/include/dlt/dlt-logd-converter.hpp index 0959a8f8..07958154 100644 --- a/include/dlt/dlt-logd-converter.hpp +++ b/include/dlt/dlt-logd-converter.hpp @@ -62,10 +62,14 @@ using namespace std; /* MACRO */ -#define CONFIGURATION_FILE_DIR "/vendor/etc/dlt-logd-converter.conf" -#define JSON_FILE_DIR "/vendor/etc/dlt-logdctxt.json" #define MAX_LINE 1024 #define DLT_FAIL_TO_GET_LOG_MSG 0 +#define CONFIGURATION_FILE_DIR "/vendor/etc/dlt-logd-converter.conf" +#define JSON_FILE_DIR "/vendor/etc/dlt-logdctxt.json" +#define T_CONFIGURATION_FILE_DIR "dlt-logd-converter.conf" +#define T_JSON_FILE_DIR "dlt-logdctxt.json" +#define T_ABNORMAL_CONFIGURATION_FILE_DIR "abnormal-dlt-logd-converter.conf" + typedef struct { diff --git a/src/android/dlt-logd-converter.conf b/src/android/dlt-logd-converter.conf index 190f141c..a9559ab5 100644 --- a/src/android/dlt-logd-converter.conf +++ b/src/android/dlt-logd-converter.conf @@ -15,4 +15,3 @@ AndroidLogdJSONpath = /vendor/etc/dlt-logdctxt.json # The common context ID for the case where the JSON path is found, # but applications are not listed in JSON file (Default: OTHE) AndroidLogdContextID = OTHE - diff --git a/src/console/dlt-convert.c b/src/console/dlt-convert.c index 41800db8..332e94ef 100644 --- a/src/console/dlt-convert.c +++ b/src/console/dlt-convert.c @@ -120,12 +120,23 @@ void usage() printf(" -v Verbose mode\n"); printf(" -c Count number of messages\n"); printf(" -f filename Enable filtering of messages\n"); - printf(" -b number First messages to be handled\n"); - printf(" -e number Last message to be handled\n"); + printf(" -b number First messages to be handled\n"); + printf(" -e number Last messages to be handled\n"); printf(" -w Follow dlt file while file is increasing\n"); printf(" -t Handling input compressed files (tar.gz)\n"); } +char *get_filename_ext(const char *filename) +{ + if (filename == NULL) + fprintf(stderr, "ERROR: %s: invalid arguments\n", __FUNCTION__); + + char *dot = strrchr(filename, '.'); + if(!dot || dot == filename) + return ""; + return dot + 1; +} + void empty_dir(const char *dir) { struct dirent **files = { 0 }; @@ -206,7 +217,8 @@ int main(int argc, char *argv[]) /* For handling compressed files */ char tmp_filename[FILENAME_SIZE] = { 0 }; - struct stat st = { 0 }; + struct stat st; + memset(&st, 0, sizeof(struct stat)); struct dirent **files = { 0 }; int n = 0; int i = 0; @@ -409,7 +421,6 @@ int main(int argc, char *argv[]) if (ovalue) close(ohandle); - dlt_file_free(&file, vflag); return -1; } @@ -418,7 +429,6 @@ int main(int argc, char *argv[]) if (ovalue) close(ohandle); - dlt_file_free(&file, vflag); return -1; } diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c index d1a98efb..1254d5fa 100644 --- a/src/daemon/dlt_daemon_offline_logstorage.c +++ b/src/daemon/dlt_daemon_offline_logstorage.c @@ -1161,7 +1161,7 @@ int dlt_daemon_logstorage_cleanup(DltDaemon *daemon, (&daemon->storage_handle[i])->uconfig.logfile_timestamp = daemon_local->flags.offlineLogstorageTimestamp; (&daemon->storage_handle[i])->uconfig.logfile_optional_counter = - daemon_local->flags.offlineLogstorageOptionalCounter; + daemon_local->flags.offlineLogstorageOptionalCounter; dlt_logstorage_device_disconnected( &daemon->storage_handle[i], diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c index f435a12e..65c0f149 100644 --- a/src/lib/dlt_user.c +++ b/src/lib/dlt_user.c @@ -1555,8 +1555,9 @@ DltReturnValue dlt_unregister_app_util(bool force_sending_messages) DltReturnValue ret = DLT_RETURN_OK; /* forbid dlt usage in child after fork */ - if (g_dlt_is_child) + if (g_dlt_is_child) { return DLT_RETURN_ERROR; + } if (!DLT_USER_INITALIZED) { dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__); @@ -1569,14 +1570,15 @@ DltReturnValue dlt_unregister_app_util(bool force_sending_messages) DLT_SEM_LOCK(); int count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer)); + if (!force_sending_messages || - (force_sending_messages && count == 0)) - { + (force_sending_messages && (count == 0))) { /* Clear and free local stored application information */ dlt_set_id(dlt_user.appID, ""); - if (dlt_user.application_description != NULL) + if (dlt_user.application_description != NULL) { free(dlt_user.application_description); + } dlt_user.application_description = NULL; } @@ -1619,14 +1621,16 @@ DltReturnValue dlt_unregister_context(DltContext *handle) DltReturnValue ret = DLT_RETURN_OK; /* forbid dlt usage in child after fork */ - if (g_dlt_is_child) + if (g_dlt_is_child) { return DLT_RETURN_ERROR; + } log.handle = NULL; log.context_description = NULL; - if (dlt_user_log_init(handle, &log) <= DLT_RETURN_ERROR) + if (dlt_user_log_init(handle, &log) <= DLT_RETURN_ERROR) { return DLT_RETURN_ERROR; + } DLT_SEM_LOCK(); @@ -1640,8 +1644,9 @@ DltReturnValue dlt_unregister_context(DltContext *handle) dlt_user.dlt_ll_ts[handle->log_level_pos].log_level = DLT_USER_INITIAL_LOG_LEVEL; dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status = DLT_USER_INITIAL_TRACE_STATUS; - if (dlt_user.dlt_ll_ts[handle->log_level_pos].context_description != NULL) + if (dlt_user.dlt_ll_ts[handle->log_level_pos].context_description != NULL) { free(dlt_user.dlt_ll_ts[handle->log_level_pos].context_description); + } if (dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr != NULL) { free(dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr); diff --git a/src/offlinelogstorage/dlt_offline_logstorage.h b/src/offlinelogstorage/dlt_offline_logstorage.h index d5d74fc2..61e8896c 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage.h +++ b/src/offlinelogstorage/dlt_offline_logstorage.h @@ -72,18 +72,15 @@ #define DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN 15 /* Maximum size for key */ #define DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN 100 /* Maximum file name length of the log file including path under mount point */ -#define DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN 4 #define DLT_OFFLINE_LOGSTORAGE_GZ_FILE_EXTENSION_LEN 7 #define DLT_OFFLINE_LOGSTORAGE_INDEX_LEN 3 #define DLT_OFFLINE_LOGSTORAGE_MAX_INDEX 999 #define DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN 16 #define DLT_OFFLINE_LOGSTORAGE_INDEX_OFFSET (DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + \ - DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN + \ DLT_OFFLINE_LOGSTORAGE_INDEX_LEN) #define DLT_OFFLINE_LOGSTORAGE_MAX_LOG_FILE_LEN (DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN + \ DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + \ - DLT_OFFLINE_LOGSTORAGE_INDEX_LEN + \ - DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN + 1) + DLT_OFFLINE_LOGSTORAGE_INDEX_LEN + 1) #define DLT_OFFLINE_LOGSTORAGE_CONFIG_FILE_NAME "dlt_logstorage.conf" diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c index a84461bc..28d34e0d 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior.c @@ -39,7 +39,7 @@ unsigned int g_logstorage_cache_size; /** * dlt_logstorage_concat * - * Concatenates two strings but keeps the size of the result less then dst_size. + * Concatenates two strings but keeps the size of the result less than dst_size. * * @param dst The destination string * @param src The source string to concat @@ -50,7 +50,7 @@ DLT_STATIC void dlt_logstorage_concat_logfile_name(char *log_file_name, const ch size_t src_len = strlen(append); if (dst_len < DLT_MOUNT_PATH_MAX) { - size_t rem_len = DLT_MOUNT_PATH_MAX - dst_len - 1; + size_t rem_len = DLT_MOUNT_PATH_MAX - dst_len + 1; strncat(log_file_name, append, rem_len); } else { dlt_vlog(LOG_ERR, "Log file name reached max len: %s [%d]\n", log_file_name, DLT_MOUNT_PATH_MAX); @@ -259,10 +259,9 @@ void dlt_logstorage_rearrange_file_name(DltLogStorageFileList **head) * @param file file name to extract the index from * @return index on success, -1 if no index is found */ -unsigned int -dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_config, - DltLogStorageFilterConfig *config, - char *file) +unsigned int dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_config, + DltLogStorageFilterConfig *config, + char *file) { if (file_config == NULL || config == NULL || file == NULL) return -1; @@ -279,7 +278,7 @@ dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_config, */ basename_len = strlen(config->file_name); sptr = file + basename_len + 1; - eptr = strchr(file + basename_len + 1, file_config->logfile_delimiter); + eptr = strchr(sptr, file_config->logfile_delimiter); idx = strtol(sptr, &eptr, 10); if (idx == 0) @@ -371,20 +370,15 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, config->records = NULL; } - char suffix[10]; - int suffix_len; - memset(suffix, 0, 10); - if (config->gzip_compression) { - suffix_len = DLT_OFFLINE_LOGSTORAGE_GZ_FILE_EXTENSION_LEN; - strncpy(suffix, ".dlt.gz", suffix_len); - } - else { - suffix_len = DLT_OFFLINE_LOGSTORAGE_FILE_EXTENSION_LEN; - strncpy(suffix, ".dlt", suffix_len); - } - + char* suffix = NULL; for (i = 0; i < cnt; i++) { - const char* suffix = ".dlt"; + if (config->gzip_compression) { + suffix = strdup(".dlt.gz"); + } + else { + suffix = strdup(".dlt"); + } + int len = 0; len = strlen(file_name); @@ -404,7 +398,7 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, } else { /* _idx.dlt or _idx_.dlt */ if (files[i]->d_name[len] == file_config->logfile_delimiter) { - current_idx = dlt_logstorage_get_idx_of_log_file(file_config, config, + current_idx = dlt_logstorage_get_idx_of_log_file(file_config, config, files[i]->d_name); } else { continue; @@ -476,6 +470,11 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, free(files); + if (suffix) { + free(suffix); + suffix = NULL; + } + return ret; } @@ -488,9 +487,9 @@ int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, * @param fpath The file path * @param mode The mode to open the file with */ -DLT_STATIC void -dlt_logstorage_open_log_output_file(DltLogStorageFilterConfig *config, - const char *fpath, const char *mode) +DLT_STATIC void dlt_logstorage_open_log_output_file(DltLogStorageFilterConfig *config, + const char *fpath, + const char *mode) { FILE *file = fopen(fpath, mode); config->fd = fileno(file); @@ -533,6 +532,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config, char file_name[DLT_OFFLINE_LOGSTORAGE_MAX_LOG_FILE_LEN + 1] = { '\0' }; unsigned int num_log_files = 0; struct stat s; + memset(&s, 0, sizeof(struct stat)); DltLogStorageFileList **tmp = NULL; DltLogStorageFileList **newest = NULL; @@ -577,7 +577,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config, strcat(absolute_file_path, storage_path); strcat(absolute_file_path, file_name); config->working_file_name = strdup(file_name); - dlt_logstorage_open_log_output_file(config, absolute_file_path, "a"); + dlt_logstorage_open_log_output_file(config, absolute_file_path, "a+"); /* Add file to file list */ *tmp = malloc(sizeof(DltLogStorageFileList)); @@ -620,7 +620,7 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config, if ((ret == 0) && ((is_sync && (s.st_size < (int)config->file_size)) || (!is_sync && (s.st_size + msg_size <= (int)config->file_size)))) { - dlt_logstorage_open_log_output_file(config, absolute_file_path, "a"); + dlt_logstorage_open_log_output_file(config, absolute_file_path, "a+"); config->current_write_file_offset = s.st_size; } else { @@ -628,7 +628,29 @@ int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config, unsigned int idx = 0; /* get index of newest log file */ - idx = dlt_logstorage_get_idx_of_log_file(file_config, config, config->working_file_name); + if (config->num_files == 1 && file_config->logfile_optional_counter) { + idx = 1; + } else { + idx = dlt_logstorage_get_idx_of_log_file(file_config, config, + config->working_file_name); + } + + /* Check if file logging shall be stopped */ + if (config->overwrite == DLT_LOGSTORAGE_OVERWRITE_DISCARD_NEW) { + dlt_vlog(LOG_DEBUG, + "%s: num_files=%d, current_idx=%d (filename=%s)\n", + __func__, config->num_files, idx, + config->file_name); + + if (config->num_files == idx) { + dlt_vlog(LOG_INFO, + "%s: logstorage limit reached, stopping capture for filter: %s\n", + __func__, config->file_name); + config->skip = 1; + return 0; + } + } + idx += 1; /* wrap around if max index is reached or an error occurred diff --git a/src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h b/src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h index fbc22ae6..ec820d51 100644 --- a/src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h +++ b/src/offlinelogstorage/dlt_offline_logstorage_behavior_internal.h @@ -60,10 +60,9 @@ unsigned int dlt_logstorage_sort_file_name(DltLogStorageFileList **head); void dlt_logstorage_rearrange_file_name(DltLogStorageFileList **head); -unsigned int -dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_config, - DltLogStorageFilterConfig *config, - char *file); +unsigned int dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_config, + DltLogStorageFilterConfig *config, + char *file); int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config, char *path, diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 057c2cac..42f67915 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,10 @@ +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -isystem ${gtest_SOURCE_DIR}/include") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${gtest_SOURCE_DIR}/include -std=gnu++0x") + configure_file(${PROJECT_SOURCE_DIR}/tests/testfile.dlt ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) configure_file(${PROJECT_SOURCE_DIR}/tests/testfilter.txt ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) configure_file(${PROJECT_SOURCE_DIR}/tests/testfile_filetransfer.txt ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) +configure_file(${PROJECT_SOURCE_DIR}/tests/test_dlt.conf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) if("${GTEST_BOTH_LIBRARIES}" STREQUAL "") set(GTEST_LIBS gtest gtest_main) @@ -42,9 +46,12 @@ foreach(target IN LISTS TARGET_LIST) set(target_SRCS ${target_SRCS} ${PROJECT_SOURCE_DIR}/src/daemon/dlt_daemon_common.c) endif() add_executable(${target} ${target_SRCS}) - target_link_libraries(${target} ${DLT_LIBRARIES}) + target_link_libraries(${target} ${DLT_LIBRARIES} ${DLT_CONTROL_LIBRARIES}) add_test(NAME ${target} COMMAND ${target}) + target_compile_definitions(${target} + PRIVATE + DLTPATH=${CMAKE_CURRENT_SOURCE_DIR}) endforeach() ################### @@ -60,23 +67,25 @@ if(WITH_DLT_SHM_ENABLE) endif() foreach(target IN LISTS TARGET_LIST) - set(target_SRCS ${target}.cpp) + set(target_SRCS ${target}) add_executable(${target} ${target_SRCS} ${systemd_SRCS}) - target_link_libraries(${target} ${DLT_DAEMON_LIBRARIES}) - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${target}.sh) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${target}.sh ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) + target_link_libraries(${target} ${DLT_DAEMON_LIBRARIES} ${ZLIB_LIBRARY}) + if(EXISTS ${PROJECT_SOURCE_DIR}/tests/${target}.sh) + configure_file(${PROJECT_SOURCE_DIR}/tests/${target}.sh ${PROJECT_BINARY_DIR}/tests COPYONLY) add_test(NAME ${target} - COMMAND /bin/sh -e -c "\ - sh $.sh ; \ - $ || TESTS_FAILED=1 && TESTS_FAILED=0 \ - sleep 0.5 ; \ - killall -v $ || echo 'Could not find any daemon to kill' ; - exit $TESTS_FAILED") - set_tests_properties(${target} PROPERTIES ENVIRONMENT "PATH=$:$ENV{PATH}") + COMMAND /bin/sh -e -c "\ + sh $.sh ; \ + $ || TESTS_FAILED=1 && TESTS_FAILED=0 \ + sleep 0.5 ; \ + killall -v dlt-daemon || echo 'Could not find any daemon to kill' ; + exit $TESTS_FAILED") + set_tests_properties(${target} PROPERTIES ENVIRONMENT "PATH=$:$ENV{PATH}; \ + DLT_UT_DAEMON_PATH=$") else() add_test(NAME ${target} COMMAND ${target}) endif() + set_tests_properties(${target} PROPERTIES TIMEOUT "${seconds}") endforeach() ##################### @@ -92,3 +101,5 @@ if(WITH_EXTENDED_FILTERING) COMMAND gtest_dlt_json_filter) set_tests_properties(${target} PROPERTIES TIMEOUT "${seconds}") endif() + +add_subdirectory(components) diff --git a/tests/component/disable_network/dlt.conf b/tests/component/disable_network/dlt.conf deleted file mode 100644 index 2e6183fa..00000000 --- a/tests/component/disable_network/dlt.conf +++ /dev/null @@ -1,7 +0,0 @@ -MessageFilterConfigFile = ../../../../tests/component/disable_network/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock - -OfflineLogstorageTimestamp = 0 -OfflineLogstorageMaxDevices = 1 -OfflineLogstorageDirPath = . -OfflineLogstorageOptionalIndex = 1 diff --git a/tests/component/disable_network/dlt_message_filter.conf b/tests/component/disable_network/dlt_message_filter.conf deleted file mode 100644 index 71a7edd0..00000000 --- a/tests/component/disable_network/dlt_message_filter.conf +++ /dev/null @@ -1,10 +0,0 @@ -[General] -Name = Genivi-LogMode -DefaultLevel = 100 - -[Filter1] -Name = Both -Level = 100 -Clients = * -ControlMessages = * -Injections = * diff --git a/tests/component/dlt-logd-converter/CMakeLists.txt b/tests/component/dlt-logd-converter/CMakeLists.txt deleted file mode 100644 index 8a91654f..00000000 --- a/tests/component/dlt-logd-converter/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -########################## -# DLT logd-converter test -########################## -configure_file(${PROJECT_SOURCE_DIR}/tests/component/dlt-logd-converter/dlt-logd-converter.conf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) -configure_file(${PROJECT_SOURCE_DIR}/tests/component/dlt-logd-converter/dlt-logdctxt.json ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) -configure_file(${PROJECT_SOURCE_DIR}/tests/component/dlt-logd-converter/abnormal-dlt-logd-converter.conf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) - -set(dlt_logd_converter_SRC ${PROJECT_SOURCE_DIR}/src/android/dlt-logd-converter.cpp) -set(gtest_dlt_logd_converter_SRC ${PROJECT_SOURCE_DIR}/tests/component/dlt-logd-converter/gtest_dlt_logd_converter.cpp) - -add_executable(gtest_dlt_logd_converter ${dlt_logd_converter_SRC} ${gtest_dlt_logd_converter_SRC}) -target_link_libraries(gtest_dlt_logd_converter ${DLT_LIBRARIES}) - -add_test(NAME gtest_dlt_logd_converter - COMMAND gtest_dlt_logd_converter) diff --git a/tests/component/dlt-logd-converter/dlt-logdctxt.json b/tests/component/dlt-logd-converter/dlt-logdctxt.json deleted file mode 100644 index 6bcdf781..00000000 --- a/tests/component/dlt-logd-converter/dlt-logdctxt.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "QTIV": { - "tag": "QtiVehicleHal", - "description": "" - }, - "NETW": { - "tag": "NetworkSecurityConfig", - "description": "" - }, - "PROC": { - "tag": "ProcessState", - "description": "" - }, - "ZYGO": { - "tag": "Zygote", - "description": "" - } - } diff --git a/tests/component/lib/context_unreg_forbid/CMakeLists.txt b/tests/component/lib/context_unreg_forbid/CMakeLists.txt deleted file mode 100644 index ae13c4cb..00000000 --- a/tests/component/lib/context_unreg_forbid/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -set(NAME context_unreg_forbid) -set(MESSAGE_FILTER_CONFIGURATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf) - -add_executable(${NAME} ${NAME}.cpp) -target_include_directories(${NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/) - -target_link_libraries(${NAME} PRIVATE dlt) - -add_test(NAME ${NAME} COMMAND /bin/sh -e -c "\ -$ -c ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf & -sleep 0.2 -$ & -sleep 0.1 -killall $ -sleep 0.5 -") - -set_tests_properties(${NAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CTEST_LD_PATHS}") - -set_tests_properties(${NAME} PROPERTIES PASS_REGULAR_EXPRESSION "\ -dlt_unregister_context: Contexts and application are already unregistered") diff --git a/tests/component/lib/context_unreg_forbid/dlt.conf.in b/tests/component/lib/context_unreg_forbid/dlt.conf.in deleted file mode 100644 index b3eabc52..00000000 --- a/tests/component/lib/context_unreg_forbid/dlt.conf.in +++ /dev/null @@ -1,2 +0,0 @@ -MessageFilterConfigFile = @MESSAGE_FILTER_CONFIGURATION_FILE@/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock \ No newline at end of file diff --git a/tests/component/logstorage/CMakeLists.txt b/tests/component/logstorage/CMakeLists.txt deleted file mode 100644 index 9f50123f..00000000 --- a/tests/component/logstorage/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(logstorage_fsync) diff --git a/tests/component/logstorage/logstorage_fsync/dlt_message_filter.conf b/tests/component/logstorage/logstorage_fsync/dlt_message_filter.conf deleted file mode 100644 index 71a7edd0..00000000 --- a/tests/component/logstorage/logstorage_fsync/dlt_message_filter.conf +++ /dev/null @@ -1,10 +0,0 @@ -[General] -Name = Genivi-LogMode -DefaultLevel = 100 - -[Filter1] -Name = Both -Level = 100 -Clients = * -ControlMessages = * -Injections = * diff --git a/tests/component/logstorage/logstorage_multi_file/dlt.conf.in b/tests/component/logstorage/logstorage_multi_file/dlt.conf.in deleted file mode 100644 index 8f6fd8d8..00000000 --- a/tests/component/logstorage/logstorage_multi_file/dlt.conf.in +++ /dev/null @@ -1,7 +0,0 @@ -MessageFilterConfigFile = @MESSAGE_FILTER_CONFIGURATION_FILE@/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock - -OfflineLogstorageTimestamp = 0 -OfflineLogstorageMaxDevices = 1 -OfflineLogstorageDirPath = . -OfflineLogstorageOptionalIndex = 1 \ No newline at end of file diff --git a/tests/component/logstorage/logstorage_one_file/dlt.conf.in b/tests/component/logstorage/logstorage_one_file/dlt.conf.in deleted file mode 100644 index 8f6fd8d8..00000000 --- a/tests/component/logstorage/logstorage_one_file/dlt.conf.in +++ /dev/null @@ -1,7 +0,0 @@ -MessageFilterConfigFile = @MESSAGE_FILTER_CONFIGURATION_FILE@/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock - -OfflineLogstorageTimestamp = 0 -OfflineLogstorageMaxDevices = 1 -OfflineLogstorageDirPath = . -OfflineLogstorageOptionalIndex = 1 \ No newline at end of file diff --git a/tests/component/logstorage_filepath/dlt.conf b/tests/component/logstorage_filepath/dlt.conf deleted file mode 100644 index b982735c..00000000 --- a/tests/component/logstorage_filepath/dlt.conf +++ /dev/null @@ -1,7 +0,0 @@ -MessageFilterConfigFile = ../../../../tests/component/logstorage_filepath/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock - -OfflineLogstorageTimestamp = 0 -OfflineLogstorageMaxDevices = 1 -OfflineLogstorageDirPath = . -OfflineLogstorageOptionalIndex = 1 diff --git a/tests/component/logstorage_filepath/dlt_message_filter.conf b/tests/component/logstorage_filepath/dlt_message_filter.conf deleted file mode 100644 index 71a7edd0..00000000 --- a/tests/component/logstorage_filepath/dlt_message_filter.conf +++ /dev/null @@ -1,10 +0,0 @@ -[General] -Name = Genivi-LogMode -DefaultLevel = 100 - -[Filter1] -Name = Both -Level = 100 -Clients = * -ControlMessages = * -Injections = * diff --git a/tests/component/logstorage_max_cache_size/dlt.conf b/tests/component/logstorage_max_cache_size/dlt.conf deleted file mode 100644 index fba4c007..00000000 --- a/tests/component/logstorage_max_cache_size/dlt.conf +++ /dev/null @@ -1,8 +0,0 @@ -MessageFilterConfigFile = ../../../../tests/component/logstorage_max_cache_size/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock - -OfflineLogstorageTimestamp = 0 -OfflineLogstorageMaxDevices = 1 -OfflineLogstorageDirPath = . -OfflineLogstorageOptionalIndex = 1 -OfflineLogstorageCacheSize = 70 diff --git a/tests/component/logstorage_max_cache_size/dlt_message_filter.conf b/tests/component/logstorage_max_cache_size/dlt_message_filter.conf deleted file mode 100644 index 71a7edd0..00000000 --- a/tests/component/logstorage_max_cache_size/dlt_message_filter.conf +++ /dev/null @@ -1,10 +0,0 @@ -[General] -Name = Genivi-LogMode -DefaultLevel = 100 - -[Filter1] -Name = Both -Level = 100 -Clients = * -ControlMessages = * -Injections = * diff --git a/tests/component/logstorage_multi_file/dlt.conf b/tests/component/logstorage_multi_file/dlt.conf deleted file mode 100644 index 684828ce..00000000 --- a/tests/component/logstorage_multi_file/dlt.conf +++ /dev/null @@ -1,7 +0,0 @@ -MessageFilterConfigFile = ../../../../tests/component/logstorage_multi_file/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock - -OfflineLogstorageTimestamp = 0 -OfflineLogstorageMaxDevices = 1 -OfflineLogstorageDirPath = . -OfflineLogstorageOptionalIndex = 1 diff --git a/tests/component/logstorage_multi_file/dlt_message_filter.conf b/tests/component/logstorage_multi_file/dlt_message_filter.conf deleted file mode 100644 index 71a7edd0..00000000 --- a/tests/component/logstorage_multi_file/dlt_message_filter.conf +++ /dev/null @@ -1,10 +0,0 @@ -[General] -Name = Genivi-LogMode -DefaultLevel = 100 - -[Filter1] -Name = Both -Level = 100 -Clients = * -ControlMessages = * -Injections = * diff --git a/tests/component/logstorage_one_file/dlt.conf b/tests/component/logstorage_one_file/dlt.conf deleted file mode 100644 index f6b90172..00000000 --- a/tests/component/logstorage_one_file/dlt.conf +++ /dev/null @@ -1,7 +0,0 @@ -MessageFilterConfigFile = ../../../../tests/component/logstorage_one_file/dlt_message_filter.conf -ControlSocketPath = ./dlt-ctrl.sock - -OfflineLogstorageTimestamp = 0 -OfflineLogstorageMaxDevices = 1 -OfflineLogstorageDirPath = . -OfflineLogstorageOptionalIndex = 1 diff --git a/tests/component/logstorage_one_file/dlt_message_filter.conf b/tests/component/logstorage_one_file/dlt_message_filter.conf deleted file mode 100644 index 71a7edd0..00000000 --- a/tests/component/logstorage_one_file/dlt_message_filter.conf +++ /dev/null @@ -1,10 +0,0 @@ -[General] -Name = Genivi-LogMode -DefaultLevel = 100 - -[Filter1] -Name = Both -Level = 100 -Clients = * -ControlMessages = * -Injections = * diff --git a/tests/components/CMakeLists.txt b/tests/components/CMakeLists.txt new file mode 100644 index 00000000..a1c1e721 --- /dev/null +++ b/tests/components/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(logstorage) +add_subdirectory(logd-converter) diff --git a/tests/components/logd-converter/CMakeLists.txt b/tests/components/logd-converter/CMakeLists.txt new file mode 100644 index 00000000..b3180fa3 --- /dev/null +++ b/tests/components/logd-converter/CMakeLists.txt @@ -0,0 +1,28 @@ +########################## +# DLT logd-converter test +########################## + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt-logd-converter.conf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt-logdctxt.json ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/abnormal-dlt-logd-converter.conf ${CMAKE_CURRENT_BINARY_DIR} COPYONLY) + +set(dlt_logd_converter_SRC ${CMAKE_SOURCE_DIR}/src/android/dlt-logd-converter.cpp) +set(gtest_dlt_logd_converter_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gtest_dlt_logd_converter.cpp) + +add_executable(gtest_dlt_logd_converter ${dlt_logd_converter_SRC} ${gtest_dlt_logd_converter_SRC}) +target_link_libraries(gtest_dlt_logd_converter ${DLT_LIBRARIES}) + +add_test(NAME gtest_dlt_logd_converter + COMMAND /bin/sh -e -c "\ + $ & + sleep 0.1 + $ || TESTS_FAILED=1 && TESTS_FAILED=0 & + sleep 1 + killall -v dlt-daemon || echo 'Could not find any daemon to kill' + exit $TESTS_FAILED") + +set_tests_properties(${target} PROPERTIES ENVIRONMENT "\ + PATH=$:$ENV{PATH}; \ + DLT_UT_DAEMON_PATH=$") + +set_tests_properties(${target} PROPERTIES TIMEOUT "${seconds}") \ No newline at end of file diff --git a/tests/component/dlt-logd-converter/abnormal-dlt-logd-converter.conf b/tests/components/logd-converter/abnormal-dlt-logd-converter.conf similarity index 100% rename from tests/component/dlt-logd-converter/abnormal-dlt-logd-converter.conf rename to tests/components/logd-converter/abnormal-dlt-logd-converter.conf diff --git a/tests/component/dlt-logd-converter/dlt-logd-converter.conf b/tests/components/logd-converter/dlt-logd-converter.conf similarity index 100% rename from tests/component/dlt-logd-converter/dlt-logd-converter.conf rename to tests/components/logd-converter/dlt-logd-converter.conf diff --git a/tests/components/logd-converter/dlt-logdctxt.json b/tests/components/logd-converter/dlt-logdctxt.json new file mode 100644 index 00000000..e3ff23eb --- /dev/null +++ b/tests/components/logd-converter/dlt-logdctxt.json @@ -0,0 +1,18 @@ +{ + "QTIV": { + "tag": "QtiVehicleHal", + "description": "" + }, + "NETW": { + "tag": "NetworkSecurityConfig", + "description": "" + }, + "PROC": { + "tag": "ProcessState", + "description": "" + }, + "ZYGO": { + "tag": "Zygote", + "description": "" + } +} diff --git a/tests/component/dlt-logd-converter/gtest_dlt_logd_converter.cpp b/tests/components/logd-converter/gtest_dlt_logd_converter.cpp similarity index 94% rename from tests/component/dlt-logd-converter/gtest_dlt_logd_converter.cpp rename to tests/components/logd-converter/gtest_dlt_logd_converter.cpp index f2312a3c..4f3f560e 100644 --- a/tests/component/dlt-logd-converter/gtest_dlt_logd_converter.cpp +++ b/tests/components/logd-converter/gtest_dlt_logd_converter.cpp @@ -40,13 +40,6 @@ #include "gtest/gtest.h" #include "dlt-logd-converter.hpp" -/* MACRO */ -#undef CONFIGURATION_FILE_DIR -#undef JSON_FILE_DIR -#define CONFIGURATION_FILE_DIR "dlt-logd-converter.conf" -#define JSON_FILE_DIR "dlt-logdctxt.json" -#define ABNORMAL_CONFIGURATION_FILE_DIR "abnormal-dlt-logd-converter.conf" - extern dlt_logd_configuration *logd_conf; extern unordered_map map_ctx_json; extern bool json_is_available; @@ -69,7 +62,7 @@ struct log_msg t_log_msg; string t_load_json_file() { - ifstream file(JSON_FILE_DIR); + ifstream file(T_JSON_FILE_DIR); char *token; string pattern; string json_sequence; @@ -221,10 +214,10 @@ TEST(t_load_configuration_file, normal) { logd_conf->appID = strdup("LOGD"); logd_conf->ctxID = strdup("LOGF"); - logd_conf->json_file_dir = strdup(JSON_FILE_DIR); + logd_conf->json_file_dir = strdup(T_JSON_FILE_DIR); logd_conf->default_ctxID = strdup("OTHE"); - logd_conf->conf_file_dir = strdup(CONFIGURATION_FILE_DIR); - int ret = load_configuration_file(CONFIGURATION_FILE_DIR); + logd_conf->conf_file_dir = strdup(T_CONFIGURATION_FILE_DIR); + int ret = load_configuration_file(T_CONFIGURATION_FILE_DIR); EXPECT_EQ(DLT_RETURN_OK, ret); EXPECT_STREQ("LOGD", logd_conf->appID); @@ -237,10 +230,10 @@ TEST(t_load_configuration_file, abnormal) { logd_conf->appID = strdup("LOGD"); logd_conf->ctxID = strdup("LOGF"); - logd_conf->json_file_dir = strdup(JSON_FILE_DIR); + logd_conf->json_file_dir = strdup(T_JSON_FILE_DIR); logd_conf->default_ctxID = strdup("OTHE"); - logd_conf->conf_file_dir = strdup(CONFIGURATION_FILE_DIR); - int ret = load_configuration_file(ABNORMAL_CONFIGURATION_FILE_DIR); + logd_conf->conf_file_dir = strdup(T_CONFIGURATION_FILE_DIR); + int ret = load_configuration_file(T_ABNORMAL_CONFIGURATION_FILE_DIR); EXPECT_EQ(DLT_RETURN_OK, ret); EXPECT_STREQ("DLOG", logd_conf->appID); @@ -258,7 +251,7 @@ TEST(t_clean_mem, normal) { logd_conf->appID = strdup("LOGD"); logd_conf->ctxID = strdup("LOGF"); - logd_conf->json_file_dir = strdup(JSON_FILE_DIR); + logd_conf->json_file_dir = strdup(T_JSON_FILE_DIR); logd_conf->default_ctxID = strdup("OTHE"); logd_conf->conf_file_dir = strdup(CONFIGURATION_FILE_DIR); @@ -300,8 +293,6 @@ TEST(t_clean_mem, normal) TEST(t_json_parser, normal) { - EXPECT_EQ(DLT_RETURN_OK, system("dlt-daemon -d > /dev/null")); - EXPECT_EQ(DLT_RETURN_OK, system("sleep 0.2")); DLT_REGISTER_APP("LOGD", "logd -> dlt adapter"); DLT_REGISTER_CONTEXT(dlt_ctx_self, "LOGF", "logd retriever"); @@ -322,14 +313,10 @@ TEST(t_json_parser, normal) map_ctx_json.clear(); DLT_UNREGISTER_APP_FLUSH_BUFFERED_LOGS(); - EXPECT_LT(DLT_RETURN_OK, system("kill -9 $(pgrep -f \"dlt-daemon -d\") > /dev/null")); } TEST(t_find_tag_in_json, normal) { - EXPECT_EQ(DLT_RETURN_OK, system("dlt-daemon -d > /dev/null")); - EXPECT_EQ(DLT_RETURN_OK, system("sleep 0.2")); - string json_ctxID; string json_tag; string json_description; @@ -371,8 +358,6 @@ TEST(t_find_tag_in_json, normal) map_malloc.second = nullptr; } map_ctx_json.clear(); - - EXPECT_LT(DLT_RETURN_OK, system("kill -9 $(pgrep -f \"dlt-daemon -d\") > /dev/null")); } TEST(t_find_tag_in_json, nullpointer) @@ -527,9 +512,6 @@ TEST(t_signal_handler, normal) TEST(t_logd_parser_loop, normal) { - EXPECT_EQ(DLT_RETURN_OK, system("dlt-daemon -d > /dev/null")); - EXPECT_EQ(DLT_RETURN_OK, system("sleep 0.2")); - struct logger_list *t_list = nullptr; t_list = new logger_list; t_list->mode = READ_ONLY; @@ -673,8 +655,6 @@ TEST(t_logd_parser_loop, normal) dlt_log_data = nullptr; delete t_logger_list; t_logger_list = nullptr; - - EXPECT_LT(DLT_RETURN_OK, system("kill -9 $(pgrep -f \"dlt-daemon -d\") > /dev/null")); } diff --git a/tests/component/CMakeLists.txt b/tests/components/logstorage/CMakeLists.txt similarity index 84% rename from tests/component/CMakeLists.txt rename to tests/components/logstorage/CMakeLists.txt index 12f183cf..d140b290 100644 --- a/tests/component/CMakeLists.txt +++ b/tests/components/logstorage/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(logstorage_filepath) -add_subdirectory(logstorage_one_file) add_subdirectory(logstorage_multi_file) +add_subdirectory(logstorage_one_file) add_subdirectory(logstorage_max_cache_size) +add_subdirectory(logstorage_fsync) add_subdirectory(disable_network) diff --git a/tests/component/disable_network/CMakeLists.txt b/tests/components/logstorage/disable_network/CMakeLists.txt similarity index 90% rename from tests/component/disable_network/CMakeLists.txt rename to tests/components/logstorage/disable_network/CMakeLists.txt index 09be8c7f..39d9d408 100644 --- a/tests/component/disable_network/CMakeLists.txt +++ b/tests/components/logstorage/disable_network/CMakeLists.txt @@ -5,15 +5,14 @@ target_include_directories(${NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/) target_link_libraries(${NAME} PRIVATE dlt) set(APPID "DSNW") -set(MESSAGE_FILTER_CONFIGURATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf) add_test(NAME ${NAME} COMMAND /bin/sh -e -c "\ if [ ${CMAKE_CURRENT_SOURCE_DIR} != ${CMAKE_CURRENT_BINARY_DIR} ]; then cp ${CMAKE_CURRENT_SOURCE_DIR}/dlt_logstorage.conf ${CMAKE_CURRENT_BINARY_DIR}/; fi rm -rf ${CMAKE_CURRENT_BINARY_DIR}/*.dlt -$ -c ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf & +$ -c ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf & sleep 0.1 $ -o ${CMAKE_CURRENT_BINARY_DIR}/dlt-receive.dlt localhost & sleep 0.1 diff --git a/tests/component/disable_network/disable_network.cpp b/tests/components/logstorage/disable_network/disable_network.cpp similarity index 100% rename from tests/component/disable_network/disable_network.cpp rename to tests/components/logstorage/disable_network/disable_network.cpp diff --git a/tests/component/logstorage/logstorage_fsync/dlt.conf.in b/tests/components/logstorage/disable_network/dlt.conf.in similarity index 65% rename from tests/component/logstorage/logstorage_fsync/dlt.conf.in rename to tests/components/logstorage/disable_network/dlt.conf.in index 8f6fd8d8..33cc28f5 100644 --- a/tests/component/logstorage/logstorage_fsync/dlt.conf.in +++ b/tests/components/logstorage/disable_network/dlt.conf.in @@ -1,4 +1,3 @@ -MessageFilterConfigFile = @MESSAGE_FILTER_CONFIGURATION_FILE@/dlt_message_filter.conf ControlSocketPath = ./dlt-ctrl.sock OfflineLogstorageTimestamp = 0 diff --git a/tests/component/disable_network/dlt_logstorage.conf b/tests/components/logstorage/disable_network/dlt_logstorage.conf similarity index 100% rename from tests/component/disable_network/dlt_logstorage.conf rename to tests/components/logstorage/disable_network/dlt_logstorage.conf diff --git a/tests/component/logstorage_filepath/CMakeLists.txt b/tests/components/logstorage/logstorage_filepath/CMakeLists.txt similarity index 90% rename from tests/component/logstorage_filepath/CMakeLists.txt rename to tests/components/logstorage/logstorage_filepath/CMakeLists.txt index a1a7ba56..eb758dba 100644 --- a/tests/component/logstorage_filepath/CMakeLists.txt +++ b/tests/components/logstorage/logstorage_filepath/CMakeLists.txt @@ -5,8 +5,7 @@ target_include_directories(${NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/) target_link_libraries(${NAME} PRIVATE dlt) set(CTXNUM 2) -set(MESSAGE_FILTER_CONFIGURATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf) add_test(NAME ${NAME} COMMAND /bin/sh -e -c "\ if [ ${CMAKE_CURRENT_SOURCE_DIR} != ${CMAKE_CURRENT_BINARY_DIR} ]; @@ -15,7 +14,7 @@ fi rm -rf ${CMAKE_CURRENT_BINARY_DIR}/test rm -rf ${CMAKE_CURRENT_BINARY_DIR}/aa mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/test -$ -c ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf & +$ -c ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf & sleep 0.2 $ -c ${CTXNUM} & sleep 1 diff --git a/tests/component/logstorage/logstorage_filepath/dlt.conf.in b/tests/components/logstorage/logstorage_filepath/dlt.conf.in similarity index 65% rename from tests/component/logstorage/logstorage_filepath/dlt.conf.in rename to tests/components/logstorage/logstorage_filepath/dlt.conf.in index 8f6fd8d8..33cc28f5 100644 --- a/tests/component/logstorage/logstorage_filepath/dlt.conf.in +++ b/tests/components/logstorage/logstorage_filepath/dlt.conf.in @@ -1,4 +1,3 @@ -MessageFilterConfigFile = @MESSAGE_FILTER_CONFIGURATION_FILE@/dlt_message_filter.conf ControlSocketPath = ./dlt-ctrl.sock OfflineLogstorageTimestamp = 0 diff --git a/tests/component/logstorage_filepath/dlt_logstorage.conf b/tests/components/logstorage/logstorage_filepath/dlt_logstorage.conf similarity index 100% rename from tests/component/logstorage_filepath/dlt_logstorage.conf rename to tests/components/logstorage/logstorage_filepath/dlt_logstorage.conf diff --git a/tests/component/logstorage_filepath/logstorage_filepath.cpp b/tests/components/logstorage/logstorage_filepath/logstorage_filepath.cpp similarity index 92% rename from tests/component/logstorage_filepath/logstorage_filepath.cpp rename to tests/components/logstorage/logstorage_filepath/logstorage_filepath.cpp index 5d4e1120..1a253911 100644 --- a/tests/component/logstorage_filepath/logstorage_filepath.cpp +++ b/tests/components/logstorage/logstorage_filepath/logstorage_filepath.cpp @@ -34,8 +34,8 @@ int main(int argc, char *argv[]) DLT_REGISTER_APP("FPTH", "Logstorage filepath"); for(i = 0; i < num_context; i++) { - char ctid[DLT_ID_SIZE + 1], ctdesc[255]; - snprintf(ctid, DLT_ID_SIZE + 1, "CT%02d", i + 1); + char ctid[DLT_ID_SIZE+1], ctdesc[255]; + snprintf(ctid, DLT_ID_SIZE+1, "CT%02d", i + 1); snprintf(ctdesc, 255, "Test Context %02d", i + 1); DLT_REGISTER_CONTEXT(ctx[i], ctid, ctdesc); } diff --git a/tests/component/logstorage/logstorage_fsync/CMakeLists.txt b/tests/components/logstorage/logstorage_fsync/CMakeLists.txt similarity index 85% rename from tests/component/logstorage/logstorage_fsync/CMakeLists.txt rename to tests/components/logstorage/logstorage_fsync/CMakeLists.txt index 230f4e22..20ca5d77 100644 --- a/tests/component/logstorage/logstorage_fsync/CMakeLists.txt +++ b/tests/components/logstorage/logstorage_fsync/CMakeLists.txt @@ -13,12 +13,11 @@ target_link_libraries(${NAME} PRIVATE dlt) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt_logstorage.conf ${CMAKE_CURRENT_BINARY_DIR}) set(APPID "FSNC") -set(MESSAGE_FILTER_CONFIGURATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf) add_test(NAME ${NAME} COMMAND /bin/sh -e -c "\ rm -f ${CMAKE_CURRENT_BINARY_DIR}/${APPID}*.dlt -$ -c ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf & +$ -c ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf & sleep 0.2 $ -c 1 -n 100 & sleep 0.1 diff --git a/tests/component/logstorage/disable_network/dlt.conf.in b/tests/components/logstorage/logstorage_fsync/dlt.conf.in similarity index 65% rename from tests/component/logstorage/disable_network/dlt.conf.in rename to tests/components/logstorage/logstorage_fsync/dlt.conf.in index 8f6fd8d8..33cc28f5 100644 --- a/tests/component/logstorage/disable_network/dlt.conf.in +++ b/tests/components/logstorage/logstorage_fsync/dlt.conf.in @@ -1,4 +1,3 @@ -MessageFilterConfigFile = @MESSAGE_FILTER_CONFIGURATION_FILE@/dlt_message_filter.conf ControlSocketPath = ./dlt-ctrl.sock OfflineLogstorageTimestamp = 0 diff --git a/tests/component/logstorage/logstorage_fsync/dlt_logstorage.conf b/tests/components/logstorage/logstorage_fsync/dlt_logstorage.conf similarity index 100% rename from tests/component/logstorage/logstorage_fsync/dlt_logstorage.conf rename to tests/components/logstorage/logstorage_fsync/dlt_logstorage.conf diff --git a/tests/component/logstorage/logstorage_fsync/logfsync.cpp b/tests/components/logstorage/logstorage_fsync/logfsync.cpp similarity index 100% rename from tests/component/logstorage/logstorage_fsync/logfsync.cpp rename to tests/components/logstorage/logstorage_fsync/logfsync.cpp diff --git a/tests/component/logstorage/logstorage_fsync/logstorage_fsync.cpp b/tests/components/logstorage/logstorage_fsync/logstorage_fsync.cpp similarity index 100% rename from tests/component/logstorage/logstorage_fsync/logstorage_fsync.cpp rename to tests/components/logstorage/logstorage_fsync/logstorage_fsync.cpp diff --git a/tests/component/logstorage_max_cache_size/CMakeLists.txt b/tests/components/logstorage/logstorage_max_cache_size/CMakeLists.txt similarity index 78% rename from tests/component/logstorage_max_cache_size/CMakeLists.txt rename to tests/components/logstorage/logstorage_max_cache_size/CMakeLists.txt index c0c4020a..2ce7c67b 100644 --- a/tests/component/logstorage_max_cache_size/CMakeLists.txt +++ b/tests/components/logstorage/logstorage_max_cache_size/CMakeLists.txt @@ -1,6 +1,5 @@ set(NAME logstorage_max_cache_size) -set(MESSAGE_FILTER_CONFIGURATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf) add_executable(${NAME} ${NAME}.cpp) target_include_directories(${NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/) @@ -10,14 +9,14 @@ add_test(NAME ${NAME} COMMAND /bin/sh -e -c " if [ ${CMAKE_CURRENT_SOURCE_DIR} != ${CMAKE_CURRENT_BINARY_DIR} ]; then cp ${CMAKE_CURRENT_SOURCE_DIR}/dlt_logstorage.conf ${CMAKE_CURRENT_BINARY_DIR}/; fi -$ -c ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf & +$ -c ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf & sleep 0.5 $ sleep 0.5 -killall $") +killall $ +") set(PASSEXPRESSION "Max size of Logstorage Cache already used") set_tests_properties(${NAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CTEST_LD_PATHS}") set_tests_properties(${NAME} PROPERTIES PASS_REGULAR_EXPRESSION ${PASSEXPRESSION}) - diff --git a/tests/component/logstorage/logstorage_max_cache_size/dlt.conf.in b/tests/components/logstorage/logstorage_max_cache_size/dlt.conf.in similarity index 65% rename from tests/component/logstorage/logstorage_max_cache_size/dlt.conf.in rename to tests/components/logstorage/logstorage_max_cache_size/dlt.conf.in index 8f6fd8d8..33cc28f5 100644 --- a/tests/component/logstorage/logstorage_max_cache_size/dlt.conf.in +++ b/tests/components/logstorage/logstorage_max_cache_size/dlt.conf.in @@ -1,4 +1,3 @@ -MessageFilterConfigFile = @MESSAGE_FILTER_CONFIGURATION_FILE@/dlt_message_filter.conf ControlSocketPath = ./dlt-ctrl.sock OfflineLogstorageTimestamp = 0 diff --git a/tests/component/logstorage_max_cache_size/dlt_logstorage.conf b/tests/components/logstorage/logstorage_max_cache_size/dlt_logstorage.conf similarity index 90% rename from tests/component/logstorage_max_cache_size/dlt_logstorage.conf rename to tests/components/logstorage/logstorage_max_cache_size/dlt_logstorage.conf index d367d4f7..67fa5742 100644 --- a/tests/component/logstorage_max_cache_size/dlt_logstorage.conf +++ b/tests/components/logstorage/logstorage_max_cache_size/dlt_logstorage.conf @@ -3,7 +3,7 @@ LogAppName=LMAX ContextName=CT01 LogLevel=DLT_LOG_INFO File=LMAXSTOP -FileSize=20000 +FileSize=8000000 NOFiles=1 SyncBehavior=ON_FILE_SIZE EcuID=ECU1 @@ -14,7 +14,7 @@ LogAppName=LMAX ContextName=CT02 LogLevel=DLT_LOG_INFO File=LMAX -FileSize=20000 +FileSize=8000000 NOFiles=1 SyncBehavior=ON_FILE_SIZE EcuID=ECU1 @@ -25,7 +25,7 @@ LogAppName=LMAX ContextName=CT03 LogLevel=DLT_LOG_INFO File=LMAXFILESTOP -FileSize=20000 +FileSize=8000000 NOFiles=1 SyncBehavior=ON_FILE_SIZE EcuID=ECU1 @@ -36,7 +36,7 @@ LogAppName=LMAX ContextName=CT04 LogLevel=DLT_LOG_INFO File=LMAXFILE -FileSize=20000 +FileSize=8000000 NOFiles=1 SyncBehavior=ON_FILE_SIZE EcuID=ECU1 diff --git a/tests/component/logstorage_max_cache_size/logstorage_max_cache_size.cpp b/tests/components/logstorage/logstorage_max_cache_size/logstorage_max_cache_size.cpp similarity index 100% rename from tests/component/logstorage_max_cache_size/logstorage_max_cache_size.cpp rename to tests/components/logstorage/logstorage_max_cache_size/logstorage_max_cache_size.cpp diff --git a/tests/component/logstorage_multi_file/CMakeLists.txt b/tests/components/logstorage/logstorage_multi_file/CMakeLists.txt similarity index 95% rename from tests/component/logstorage_multi_file/CMakeLists.txt rename to tests/components/logstorage/logstorage_multi_file/CMakeLists.txt index 3dcd90dd..40cf54c3 100644 --- a/tests/component/logstorage_multi_file/CMakeLists.txt +++ b/tests/components/logstorage/logstorage_multi_file/CMakeLists.txt @@ -5,19 +5,18 @@ target_include_directories(${NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/) target_link_libraries(${NAME} PRIVATE dlt) set(CTXNUM 12) -set(MESSAGE_FILTER_CONFIGURATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf) add_test(NAME ${NAME} COMMAND /bin/sh -e -c "\ if [ ${CMAKE_CURRENT_SOURCE_DIR} != ${CMAKE_CURRENT_BINARY_DIR} ]; then cp ${CMAKE_CURRENT_SOURCE_DIR}/dlt_logstorage.conf ${CMAKE_CURRENT_BINARY_DIR}/; fi rm -f ${CMAKE_CURRENT_BINARY_DIR}/MLTI*.dlt -$ -c ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf & +$ -c ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf & sleep 0.2 $ -c ${CTXNUM} & sleep 0.1 -$ -s -C ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf +$ -s -C ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf sleep 2 killall $ sleep 0.5 diff --git a/tests/components/logstorage/logstorage_multi_file/dlt.conf.in b/tests/components/logstorage/logstorage_multi_file/dlt.conf.in new file mode 100644 index 00000000..33cc28f5 --- /dev/null +++ b/tests/components/logstorage/logstorage_multi_file/dlt.conf.in @@ -0,0 +1,6 @@ +ControlSocketPath = ./dlt-ctrl.sock + +OfflineLogstorageTimestamp = 0 +OfflineLogstorageMaxDevices = 1 +OfflineLogstorageDirPath = . +OfflineLogstorageOptionalIndex = 1 \ No newline at end of file diff --git a/tests/component/logstorage_multi_file/dlt_logstorage.conf b/tests/components/logstorage/logstorage_multi_file/dlt_logstorage.conf similarity index 100% rename from tests/component/logstorage_multi_file/dlt_logstorage.conf rename to tests/components/logstorage/logstorage_multi_file/dlt_logstorage.conf diff --git a/tests/component/logstorage_multi_file/logstorage_multi_file.cpp b/tests/components/logstorage/logstorage_multi_file/logstorage_multi_file.cpp similarity index 100% rename from tests/component/logstorage_multi_file/logstorage_multi_file.cpp rename to tests/components/logstorage/logstorage_multi_file/logstorage_multi_file.cpp diff --git a/tests/component/logstorage_one_file/CMakeLists.txt b/tests/components/logstorage/logstorage_one_file/CMakeLists.txt similarity index 94% rename from tests/component/logstorage_one_file/CMakeLists.txt rename to tests/components/logstorage/logstorage_one_file/CMakeLists.txt index 60c94e78..aab6847b 100644 --- a/tests/component/logstorage_one_file/CMakeLists.txt +++ b/tests/components/logstorage/logstorage_one_file/CMakeLists.txt @@ -6,19 +6,18 @@ target_include_directories(${NAME} PRIVATE ${CMAKE_SOURCE_DIR}/include/) target_link_libraries(${NAME} PRIVATE dlt) set(CTXNUM 12) -set(MESSAGE_FILTER_CONFIGURATION_FILE ${CMAKE_CURRENT_SOURCE_DIR}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf.in ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf) add_test(NAME ${NAME} COMMAND /bin/sh -e -c "\ if [ ${CMAKE_CURRENT_SOURCE_DIR} != ${CMAKE_CURRENT_BINARY_DIR} ]; then cp ${CMAKE_CURRENT_SOURCE_DIR}/dlt_logstorage.conf ${CMAKE_CURRENT_BINARY_DIR}/; fi rm -f ${CMAKE_CURRENT_BINARY_DIR}/LONE*.dlt -$ -c ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf & +$ -c ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf & sleep 0.2 $ -c ${CTXNUM} & sleep 0.1 -$ -s -C ${CMAKE_CURRENT_SOURCE_DIR}/dlt.conf +$ -s -C ${CMAKE_CURRENT_BINARY_DIR}/dlt.conf sleep 1 killall $ sleep 0.5 diff --git a/tests/components/logstorage/logstorage_one_file/dlt.conf.in b/tests/components/logstorage/logstorage_one_file/dlt.conf.in new file mode 100644 index 00000000..f4c1238c --- /dev/null +++ b/tests/components/logstorage/logstorage_one_file/dlt.conf.in @@ -0,0 +1,8 @@ +ControlSocketPath = ./dlt-ctrl.sock + +ControlSocketPath = ./dlt-ctrl.sock + +OfflineLogstorageTimestamp = 0 +OfflineLogstorageMaxDevices = 1 +OfflineLogstorageDirPath = . +OfflineLogstorageOptionalIndex = 1 \ No newline at end of file diff --git a/tests/component/logstorage_one_file/dlt_logstorage.conf b/tests/components/logstorage/logstorage_one_file/dlt_logstorage.conf similarity index 100% rename from tests/component/logstorage_one_file/dlt_logstorage.conf rename to tests/components/logstorage/logstorage_one_file/dlt_logstorage.conf diff --git a/tests/component/logstorage_one_file/logstorage_one_file.cpp b/tests/components/logstorage/logstorage_one_file/logstorage_one_file.cpp similarity index 100% rename from tests/component/logstorage_one_file/logstorage_one_file.cpp rename to tests/components/logstorage/logstorage_one_file/logstorage_one_file.cpp diff --git a/tests/gtest_dlt_user.cpp b/tests/gtest_dlt_user.cpp index c94e49f8..dfd7860d 100644 --- a/tests/gtest_dlt_user.cpp +++ b/tests/gtest_dlt_user.cpp @@ -189,8 +189,6 @@ TEST(t_dlt_user_log_write_start, abnormal) DltContext context; DltContextData contextData; - - EXPECT_LE(DLT_RETURN_OK, dlt_register_app("TUSR", "dlt_user.c tests")); EXPECT_LE(DLT_RETURN_OK, dlt_register_context(&context, "TEST", "dlt_user.c t_dlt_user_log_write_start abnormal")); @@ -5342,4 +5340,3 @@ int main(int argc, char **argv) ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } - diff --git a/tests/test_dlt.conf b/tests/test_dlt.conf new file mode 100644 index 00000000..eaf71291 --- /dev/null +++ b/tests/test_dlt.conf @@ -0,0 +1,7 @@ +# Set ECU ID (Default: ECU1) +ECUId = ECU2 + +######################################################################## +# Control Application # +######################################################################## +ControlSocketPath = /test/dlt-ctrl.sock