Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ release/
*.orig
*~
.idea

.cache
compile_commands.json
74 changes: 74 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"configurations": [
{
"name": "CPPDBG: Debug cmake launch target",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.getLaunchTargetPath}",
"stopAtEntry": false,
"cwd": "${command:cmake.getLaunchTargetDirectory}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "CMake: build"
},
{
"name": "CPPDBG: Debug dtl-viewer",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/${command:cmake.activeConfigurePresetName}/bin/dlt-viewer",
"args": [
"${input:dltFile}"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/gdb",
"preLaunchTask": "Delete dlt index folder"
},
],
"inputs": [
{
"type": "pickString",
"id": "dltFile",
"description": "Choose dlt file",
"options": [
"${env:HOME}/dlt/medium.dlt",
"${env:HOME}/dlt/big.dlt",
"${env:HOME}/dlt/test.dlt",
"${command:cmake.buildDirectory}/qdlt/tests/testfile_10.dlt",
"${command:cmake.buildDirectory}/src/benchmark/testfile.dlt",
"${command:cmake.buildDirectory}/src/benchmark/big.dlt",
],
"default": "component"
},
],
"version": "2.0.0"
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"streambuf": "cpp"
}
}
44 changes: 44 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Delete dlt index folder",
"type": "shell",
"command": "rm",
"args": [
"-f",
"~/dlt/index/*",
],
"problemMatcher": []
},
{
"label": "Delete index folder",
"type": "shell",
"command": "rm",
"args": [
"-rf",
"${command:cmake.buildDirectory}/index",
],
"problemMatcher": []
},
{
"label": "CMake: build",
"type": "shell",
"command": "cmake",
"args": [
"--build",
"${command:cmake.buildDirectory}",
],
"problemMatcher": []
},
{
"label": "Delete Index and Build",
"dependsOn": [
"Delete index folder",
"CMake: build"
],
"problemMatcher": [],
"dependsOrder": "sequence"
}
]
}
78 changes: 78 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "common",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"installDir": "${sourceDir}/build/${presetName}/install",
"cacheVariables": {
"DLT_APP_DIR_NAME": "DLTViewer",
"DLT_EXECUTABLE_INSTALLATION_PATH": "DLTViewer/usr/bin",
"DLT_LIBRARY_INSTALLATION_PATH": "DLTViewer/usr/lib",
"DLT_PARSER": "OFF",
"DLT_PLUGIN_INSTALLATION_PATH": "DLTViewer/usr/bin/plugins",
"DLT_RESOURCE_INSTALLATION_PATH": "DLTViewer/usr/share",
"DLT_USE_QT_RPATH": "ON"
}
},
{
"name": "debug-gcc",
"inherits": "common",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "release-gcc",
"inherits": "common",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "relwithdebinfo-gcc",
"inherits": "common",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "relwithdebinfo-clang",
"inherits": "common",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++"
}
}
],
"buildPresets": [
{
"name": "build-debug-gcc",
"description": "",
"displayName": "",
"configurePreset": "debug-gcc"
}
],
"testPresets": [
{
"name": "test-debug-gcc",
"description": "",
"displayName": "",
"configurePreset": "debug-gcc"
}
]
}
2 changes: 1 addition & 1 deletion qdlt/qdltfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int QDltFile::sizeFilter() const

bool QDltFile::open(QString _filename, bool append)
{
qDebug() << "Open file" << _filename << "started";
// qDebug() << "Open file" << _filename << "started";

/* check if file is already opened */
if(!append)
Expand Down
17 changes: 17 additions & 0 deletions qdlt/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,20 @@ add_test(
NAME test_qdltargument
COMMAND $<TARGET_FILE:test_qdltargument>
)


add_executable(test_parse_dlt_file
test_parse_dlt_file.cpp
)
target_link_libraries(
test_parse_dlt_file
PRIVATE
GTest::gtest_main
qdlt
)
add_test(
NAME test_parse_dlt_file
COMMAND $<TARGET_FILE:test_parse_dlt_file>
)
file(COPY testfile_10.dlt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)

85 changes: 85 additions & 0 deletions qdlt/tests/test_parse_dlt_file.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include "dlt_common.h"

#include <boost/interprocess/file_mapping.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <gtest/gtest.h>

#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <vector>

#define DLT_DAEMON_TEXTSIZE 10024

// TEST(ParseDltFile, initialize_open_free) {
// DltFile file;
// static char text[DLT_DAEMON_TEXTSIZE];
// /* Get PWD so file can be used*/
// std::filesystem::path openfile{std::filesystem::current_path() / "testfile_10.dlt"};
// std::filesystem::path output{"/tmp/output_testfile_10.txt"};
//
// /* Normal Use-Case, expected 0 */
// EXPECT_LE(0, dlt_file_init(&file, 0));
// EXPECT_LE(0, dlt_file_open(&file, openfile.c_str(), 0));
//
// while (dlt_file_read(&file, 0) >= 0) {
// // throw std::exception{};
// }
//
// for (int i = 0; i < file.counter; i++) {
// EXPECT_LE(0, dlt_file_message(&file, i, 0));
// EXPECT_LE(0, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
// }
//
// // for (int i = 0; i < file.counter; i++) {
// // EXPECT_LE(0, dlt_file_message(&file, i, 0));
// // EXPECT_LE(0, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
// // }
//
// EXPECT_LE(0, dlt_file_free(&file, 0));
// }

TEST(ParseDltFile, memory_mapped_file) {
using namespace boost::interprocess;

// Define file names
const char* FileName = "testfile_10.dlt";

// Open the file mapping and map it as read-only
boost::interprocess::file_mapping m_file(FileName, read_only);

mapped_region region(m_file, read_only);

// Get the address of the mapped region
void* addr = region.get_address();
std::size_t size = region.get_size();

// Check that memory was initialized to 1
const char* mem = static_cast<char*>(addr);
for (std::size_t i = 0; i < size; ++i)
if (*mem++ != 1)
std::cout << *mem;
}

// TEST(ParseDltFile, filebuffer) {
// // Define file names
// const char* FileName = "testfile_10.dlt";
// const std::size_t FileSize = 10000;
//
// // Now test it reading the file
// std::filebuf fbuf;
// fbuf.open(FileName, std::ios_base::in | std::ios_base::binary);
//
// // Read it to memory
// std::vector<char> vect(FileSize, 0);
// fbuf.sgetn(&vect[0], std::streamsize(vect.size()));
//
// // Check that memory was initialized to 1
// const char* mem = static_cast<char*>(&vect[0]);
// for (std::size_t i = 0; i < FileSize; ++i)
// if (*mem++ != 1)
// std::cout << *mem;
// }
Binary file added qdlt/tests/testfile_10.dlt
Binary file not shown.
4 changes: 2 additions & 2 deletions scripts/linux/version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ set(QT5_MIN_VERSION_REQ "5.5.1")
set(QT6_MIN_VERSION_REQ "6.2.0")

# try to find QT6
find_package(Qt6 "6" COMPONENTS Core Network PrintSupport SerialPort Widgets)
find_package(Qt6 "6" COMPONENTS Core Network PrintSupport SerialPort Widgets Test)
if(Qt6_FOUND)
set(QT_PREFIX Qt6)
message(STATUS "Found Qt6 version: ${Qt6Core_VERSION}")
Expand All @@ -26,7 +26,7 @@ if(Qt6_FOUND)
message(FATAL_ERROR "Due to SerialPort QT6 minimum version required: ${QT6_MIN_VERSION_REQ}")
endif()
else()
find_package(Qt5 "5" REQUIRED COMPONENTS Core Network PrintSupport SerialPort Widgets)
find_package(Qt5 "5" REQUIRED COMPONENTS Core Network PrintSupport SerialPort Widgets Test)
if(Qt5_FOUND)
set(QT_PREFIX Qt5)
message(STATUS "Found Qt5 version: ${Qt5Core_VERSION}")
Expand Down
25 changes: 22 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ else()
QT5_ADD_RESOURCES(UI_RESOURCES_RCC resources/resource.qrc)
endif()

add_executable(dlt-viewer
main.cpp
add_library(dlt_common
mainwindow.cpp
project.cpp
ecudialog.cpp
Expand Down Expand Up @@ -55,13 +54,23 @@ add_executable(dlt-viewer
ecutree.cpp
)

target_link_libraries(dlt-viewer
target_link_libraries(dlt_common
qdlt
${QT_PREFIX}::Core
${QT_PREFIX}::Network
${QT_PREFIX}::Widgets
${QT_PREFIX}::SerialPort)

target_include_directories(dlt_common
PUBLIC
.
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/dlt_common_autogen/include>
$<INSTALL_INTERFACE:include>
)

add_executable(dlt-viewer main.cpp)
target_link_libraries(dlt-viewer PRIVATE dlt_common)

if(CMAKE_COMPILER_IS_GNUCXX)
# https://stackoverflow.com/questions/45329372/ubuntu-recognizes-executable-as-shared-library-and-wont-run-it-by-clicking
# https://forum.juce.com/t/cmake-executable-build-shows-up-as-shared-library-on-linux-mint/45503/6
Expand Down Expand Up @@ -108,3 +117,13 @@ install(DIRECTORY
COMPONENT dlt_viewer)

include(cmake/${CMAKE_SYSTEM_NAME}.cmake OPTIONAL)

find_package(GTest)
# configure unit tests only if gtest found on the system
if (GTest_FOUND)
message(STATUS "Tests enabled")
enable_testing()
add_subdirectory(tests)
endif()

add_subdirectory(benchmark)
Loading
Loading