Skip to content

Commit 67e1c0f

Browse files
RuiMarioCostaRui Costa
authored andcommitted
update branch
1 parent 83c219b commit 67e1c0f

File tree

12 files changed

+284
-5
lines changed

12 files changed

+284
-5
lines changed

.vscode/launch.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "CPPDBG: Debug cmake launch target",
5+
"type": "cppdbg",
6+
"request": "launch",
7+
"program": "${command:cmake.getLaunchTargetPath}",
8+
"stopAtEntry": false,
9+
"cwd": "${command:cmake.getLaunchTargetDirectory}",
10+
"environment": [],
11+
"externalConsole": false,
12+
"MIMode": "gdb",
13+
"setupCommands": [
14+
{
15+
"description": "Enable pretty-printing for gdb",
16+
"text": "-enable-pretty-printing",
17+
"ignoreFailures": true
18+
},
19+
{
20+
"description": "Set Disassembly Flavor to Intel",
21+
"text": "-gdb-set disassembly-flavor intel",
22+
"ignoreFailures": true
23+
}
24+
],
25+
"miDebuggerPath": "/usr/bin/gdb",
26+
"preLaunchTask": "CMake: build"
27+
},
28+
{
29+
"name": "CPPDBG: Debug dtl-viewer",
30+
"type": "cppdbg",
31+
"request": "launch",
32+
"program": "${workspaceFolder}/build/${command:cmake.activeConfigurePresetName}/bin/dlt-viewer",
33+
"args": [
34+
"${input:dltFile}"
35+
],
36+
"stopAtEntry": false,
37+
"cwd": "${workspaceFolder}",
38+
"environment": [],
39+
"externalConsole": false,
40+
"MIMode": "gdb",
41+
"setupCommands": [
42+
{
43+
"description": "Enable pretty-printing for gdb",
44+
"text": "-enable-pretty-printing",
45+
"ignoreFailures": true
46+
},
47+
{
48+
"description": "Set Disassembly Flavor to Intel",
49+
"text": "-gdb-set disassembly-flavor intel",
50+
"ignoreFailures": true
51+
}
52+
],
53+
"miDebuggerPath": "/usr/bin/gdb",
54+
"preLaunchTask": "Delete dlt index folder"
55+
},
56+
],
57+
"inputs": [
58+
{
59+
"type": "pickString",
60+
"id": "dltFile",
61+
"description": "Choose dlt file",
62+
"options": [
63+
"${env:HOME}/dlt/medium.dlt",
64+
"${env:HOME}/dlt/big.dlt",
65+
"${env:HOME}/dlt/test.dlt",
66+
"${command:cmake.buildDirectory}/qdlt/tests/testfile_10.dlt",
67+
"${command:cmake.buildDirectory}/src/benchmark/testfile.dlt",
68+
"${command:cmake.buildDirectory}/src/benchmark/big.dlt",
69+
],
70+
"default": "component"
71+
},
72+
],
73+
"version": "2.0.0"
74+
}

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"files.associations": {
3+
"streambuf": "cpp"
4+
}
5+
}

.vscode/tasks.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Delete dlt index folder",
6+
"type": "shell",
7+
"command": "rm",
8+
"args": [
9+
"-f",
10+
"~/dlt/index/*",
11+
],
12+
"problemMatcher": []
13+
},
14+
{
15+
"label": "Delete index folder",
16+
"type": "shell",
17+
"command": "rm",
18+
"args": [
19+
"-rf",
20+
"${command:cmake.buildDirectory}/index",
21+
],
22+
"problemMatcher": []
23+
},
24+
{
25+
"label": "CMake: build",
26+
"type": "shell",
27+
"command": "cmake",
28+
"args": [
29+
"--build",
30+
"${command:cmake.buildDirectory}",
31+
],
32+
"problemMatcher": []
33+
},
34+
{
35+
"label": "Delete Index and Build",
36+
"dependsOn": [
37+
"Delete index folder",
38+
"CMake: build"
39+
],
40+
"problemMatcher": [],
41+
"dependsOrder": "sequence"
42+
}
43+
]
44+
}

CMakePresets.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": 7,
2+
"version": 6,
33
"cmakeMinimumRequired": {
44
"major": 3,
55
"minor": 23,
@@ -13,7 +13,6 @@
1313
"binaryDir": "${sourceDir}/build/${presetName}",
1414
"installDir": "${sourceDir}/build/${presetName}/install",
1515
"cacheVariables": {
16-
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
1716
"DLT_APP_DIR_NAME": "DLTViewer",
1817
"DLT_EXECUTABLE_INSTALLATION_PATH": "DLTViewer/usr/bin",
1918
"DLT_LIBRARY_INSTALLATION_PATH": "DLTViewer/usr/lib",

qdlt/tests/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,20 @@ add_test(
4747
NAME test_qdltargument
4848
COMMAND $<TARGET_FILE:test_qdltargument>
4949
)
50+
51+
52+
add_executable(test_parse_dlt_file
53+
test_parse_dlt_file.cpp
54+
)
55+
target_link_libraries(
56+
test_parse_dlt_file
57+
PRIVATE
58+
GTest::gtest_main
59+
qdlt
60+
)
61+
add_test(
62+
NAME test_parse_dlt_file
63+
COMMAND $<TARGET_FILE:test_parse_dlt_file>
64+
)
65+
file(COPY testfile_10.dlt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
66+

qdlt/tests/test_parse_dlt_file.cpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include "dlt_common.h"
2+
3+
#include <boost/interprocess/file_mapping.hpp>
4+
#include <boost/interprocess/mapped_region.hpp>
5+
#include <gtest/gtest.h>
6+
7+
#include <cstddef>
8+
#include <cstdlib>
9+
#include <cstring>
10+
#include <filesystem>
11+
#include <fstream>
12+
#include <iostream>
13+
#include <vector>
14+
15+
#define DLT_DAEMON_TEXTSIZE 10024
16+
17+
// TEST(ParseDltFile, initialize_open_free) {
18+
// DltFile file;
19+
// static char text[DLT_DAEMON_TEXTSIZE];
20+
// /* Get PWD so file can be used*/
21+
// std::filesystem::path openfile{std::filesystem::current_path() / "testfile_10.dlt"};
22+
// std::filesystem::path output{"/tmp/output_testfile_10.txt"};
23+
//
24+
// /* Normal Use-Case, expected 0 */
25+
// EXPECT_LE(0, dlt_file_init(&file, 0));
26+
// EXPECT_LE(0, dlt_file_open(&file, openfile.c_str(), 0));
27+
//
28+
// while (dlt_file_read(&file, 0) >= 0) {
29+
// // throw std::exception{};
30+
// }
31+
//
32+
// for (int i = 0; i < file.counter; i++) {
33+
// EXPECT_LE(0, dlt_file_message(&file, i, 0));
34+
// EXPECT_LE(0, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 0));
35+
// }
36+
//
37+
// // for (int i = 0; i < file.counter; i++) {
38+
// // EXPECT_LE(0, dlt_file_message(&file, i, 0));
39+
// // EXPECT_LE(0, dlt_message_print_ascii(&file.msg, text, DLT_DAEMON_TEXTSIZE, 1));
40+
// // }
41+
//
42+
// EXPECT_LE(0, dlt_file_free(&file, 0));
43+
// }
44+
45+
TEST(ParseDltFile, memory_mapped_file) {
46+
using namespace boost::interprocess;
47+
48+
// Define file names
49+
const char* FileName = "testfile_10.dlt";
50+
51+
// Open the file mapping and map it as read-only
52+
boost::interprocess::file_mapping m_file(FileName, read_only);
53+
54+
mapped_region region(m_file, read_only);
55+
56+
// Get the address of the mapped region
57+
void* addr = region.get_address();
58+
std::size_t size = region.get_size();
59+
60+
// Check that memory was initialized to 1
61+
const char* mem = static_cast<char*>(addr);
62+
for (std::size_t i = 0; i < size; ++i)
63+
if (*mem++ != 1)
64+
std::cout << *mem;
65+
}
66+
67+
// TEST(ParseDltFile, filebuffer) {
68+
// // Define file names
69+
// const char* FileName = "testfile_10.dlt";
70+
// const std::size_t FileSize = 10000;
71+
//
72+
// // Now test it reading the file
73+
// std::filebuf fbuf;
74+
// fbuf.open(FileName, std::ios_base::in | std::ios_base::binary);
75+
//
76+
// // Read it to memory
77+
// std::vector<char> vect(FileSize, 0);
78+
// fbuf.sgetn(&vect[0], std::streamsize(vect.size()));
79+
//
80+
// // Check that memory was initialized to 1
81+
// const char* mem = static_cast<char*>(&vect[0]);
82+
// for (std::size_t i = 0; i < FileSize; ++i)
83+
// if (*mem++ != 1)
84+
// std::cout << *mem;
85+
// }

qdlt/tests/testfile_10.dlt

1.76 KB
Binary file not shown.

scripts/linux/version.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ set(QT5_MIN_VERSION_REQ "5.5.1")
1717
set(QT6_MIN_VERSION_REQ "6.2.0")
1818

1919
# try to find QT6
20-
find_package(Qt6 "6" COMPONENTS Core Network PrintSupport SerialPort Widgets)
20+
find_package(Qt6 "6" COMPONENTS Core Network PrintSupport SerialPort Widgets Test)
2121
if(Qt6_FOUND)
2222
set(QT_PREFIX Qt6)
2323
message(STATUS "Found Qt6 version: ${Qt6Core_VERSION}")
@@ -26,7 +26,7 @@ if(Qt6_FOUND)
2626
message(FATAL_ERROR "Due to SerialPort QT6 minimum version required: ${QT6_MIN_VERSION_REQ}")
2727
endif()
2828
else()
29-
find_package(Qt5 "5" REQUIRED COMPONENTS Core Network PrintSupport SerialPort Widgets)
29+
find_package(Qt5 "5" REQUIRED COMPONENTS Core Network PrintSupport SerialPort Widgets Test)
3030
if(Qt5_FOUND)
3131
set(QT_PREFIX Qt5)
3232
message(STATUS "Found Qt5 version: ${Qt5Core_VERSION}")

src/benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ add_executable(bench_dltfileindexer bench_dltfileindexer.cpp)
44
target_link_libraries(bench_dltfileindexer PRIVATE benchmark::benchmark dlt_common qdlt)
55

66
file(COPY testfile.dlt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ )
7+
file(COPY test.dlt DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ )

src/benchmark/bench_dltfileindexer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
static void DoSetup(const benchmark::State& /*state*/) { std::filesystem::remove_all("index/"); }
99

10-
1110
static void BN_dltfileindexer_run(benchmark::State& state) {
1211
QString filename = "testfile.dlt";
12+
// QString filename = "test.dlt";
1313
for (auto _ : state) {
1414
QDltFile dltFile{};
1515
dltFile.open(filename);

0 commit comments

Comments
 (0)