-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
616 lines (515 loc) · 28.2 KB
/
main.cpp
File metadata and controls
616 lines (515 loc) · 28.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
/**
* VSS Signal End-to-End Test Suite (Main Executable)
*
* This is the main test executable that tests all VSS signals
* with full write-read-verify cycle.
*
* Handles unavailable signals gracefully by attempting to write,
* then reading back to verify. If read fails, signal is marked as unavailable.
*
* Usage: ./KuksaDatabrokerClient [databroker_uri]
* Example: ./KuksaDatabrokerClient 127.0.0.1:55555
*/
#include "KuksaClient.hpp"
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <thread>
#include <chrono>
#include <atomic>
#include <mutex>
#include <fstream>
#include <sstream>
#include <cmath>
using namespace std::chrono_literals;
// ANSI color codes for terminal output
#define COLOR_RESET "\033[0m"
#define COLOR_GREEN "\033[32m"
#define COLOR_RED "\033[31m"
#define COLOR_YELLOW "\033[33m"
#define COLOR_BLUE "\033[34m"
#define COLOR_CYAN "\033[36m"
#define COLOR_BOLD "\033[1m"
// Test result tracking
struct TestResult {
std::string testName;
std::string signalPath;
bool passed;
std::string message;
double duration_ms;
};
class VSSSignalTester {
private:
KuksaClient::KuksaClient& client;
std::vector<TestResult> results;
std::mutex results_mutex;
std::atomic<int> totalTests{0};
std::atomic<int> passedTests{0};
std::atomic<int> failedTests{0};
std::atomic<int> skippedTests{0};
void addResult(const std::string& testName, const std::string& signalPath,
bool passed, const std::string& message, double duration_ms = 0.0) {
std::lock_guard<std::mutex> lock(results_mutex);
results.push_back({testName, signalPath, passed, message, duration_ms});
totalTests++;
if (passed) {
passedTests++;
} else if (message.find("SKIPPED") != std::string::npos ||
message.find("NOT AVAILABLE") != std::string::npos) {
skippedTests++;
} else {
failedTests++;
}
}
std::string formatDuration(double ms) const {
std::ostringstream oss;
oss << std::fixed << std::setprecision(2) << ms << "ms";
return oss.str();
}
public:
VSSSignalTester(KuksaClient::KuksaClient& c) : client(c) {}
// ==================== END-TO-END TESTS (WRITE-READ-VERIFY) ====================
// Test sensors using current value API
template<typename T>
void testE2E(const std::string& path, const std::vector<T>& testValues,
const std::string& description, const std::string& testType) {
std::cout << COLOR_CYAN << "\n → Testing Sensor: " << COLOR_RESET << path << " (" << description << ")\n";
bool signalAvailable = false;
for (size_t i = 0; i < testValues.size(); i++) {
T testValue = testValues[i];
// Step 1: Write value (setCurrentValue returns void, silently fails if not connected)
auto writeStart = std::chrono::high_resolution_clock::now();
client.setCurrentValue(path, testValue);
auto writeEnd = std::chrono::high_resolution_clock::now();
double writeDuration = std::chrono::duration<double, std::milli>(writeEnd - writeStart).count();
// Step 2: Wait for value to propagate
std::this_thread::sleep_for(50ms);
// Step 3: Read back to verify (getCurrentValue returns bool)
auto readStart = std::chrono::high_resolution_clock::now();
T readValue{};
bool readSuccess = client.getCurrentValue(path, readValue);
auto readEnd = std::chrono::high_resolution_clock::now();
double readDuration = std::chrono::duration<double, std::milli>(readEnd - readStart).count();
double totalDuration = writeDuration + readDuration;
if (!readSuccess) {
// Signal doesn't exist or we're not connected
if (i == 0) { // Only report once per signal
addResult(testType + "_E2E", path, false,
"SIGNAL NOT AVAILABLE - Cannot read after write", totalDuration);
std::cout << COLOR_YELLOW << " ⊗ " << COLOR_RESET
<< "Signal not available or read-only\n";
}
break; // Skip remaining test values for this signal
}
signalAvailable = true;
// Verify the value matches
bool match = false;
if constexpr (std::is_floating_point_v<T>) {
match = std::abs(readValue - testValue) < 0.01;
} else {
match = (readValue == testValue);
}
if (match) {
std::string valueStr = formatValue(testValue);
std::string readStr = formatValue(readValue);
addResult(testType + "_E2E", path, true,
"Write: " + valueStr + ", Read: " + readStr + " ✓", totalDuration);
std::cout << COLOR_GREEN << " ✓ " << COLOR_RESET
<< "Write " << valueStr << " → Read " << readStr
<< " (" << formatDuration(totalDuration) << ")\n";
} else {
std::string valueStr = formatValue(testValue);
std::string readStr = formatValue(readValue);
addResult(testType + "_E2E", path, false,
"MISMATCH - Write: " + valueStr + ", Read: " + readStr, totalDuration);
std::cout << COLOR_RED << " ✗ " << COLOR_RESET
<< "MISMATCH - Wrote " << valueStr << " but read " << readStr << "\n";
}
}
}
// Test actuators using TARGET value API
template<typename T>
void testE2EActuator(const std::string& path, const std::vector<T>& testValues,
const std::string& description, const std::string& testType) {
std::cout << COLOR_CYAN << "\n → Testing Actuator: " << COLOR_RESET << path << " (" << description << ")\n";
bool signalAvailable = false;
for (size_t i = 0; i < testValues.size(); i++) {
T testValue = testValues[i];
// Step 1: Write TARGET value
auto writeStart = std::chrono::high_resolution_clock::now();
client.setTargetValue(path, testValue);
auto writeEnd = std::chrono::high_resolution_clock::now();
double writeDuration = std::chrono::duration<double, std::milli>(writeEnd - writeStart).count();
// Step 2: Wait for value to propagate
std::this_thread::sleep_for(50ms);
// Step 3: Read back TARGET value to verify
auto readStart = std::chrono::high_resolution_clock::now();
T readValue{};
bool readSuccess = client.getTargetValue(path, readValue);
auto readEnd = std::chrono::high_resolution_clock::now();
double readDuration = std::chrono::duration<double, std::milli>(readEnd - readStart).count();
double totalDuration = writeDuration + readDuration;
if (!readSuccess) {
// Signal doesn't exist or we're not connected
if (i == 0) { // Only report once per signal
addResult(testType + "_ACTUATOR", path, false,
"SIGNAL NOT AVAILABLE - Cannot read target after write", totalDuration);
std::cout << COLOR_YELLOW << " ⊗ " << COLOR_RESET
<< "Signal not available\n";
}
break; // Skip remaining test values for this signal
}
signalAvailable = true;
// Verify the value matches
bool match = false;
if constexpr (std::is_floating_point_v<T>) {
match = std::abs(readValue - testValue) < 0.01;
} else {
match = (readValue == testValue);
}
if (match) {
std::string valueStr = formatValue(testValue);
std::string readStr = formatValue(readValue);
addResult(testType + "_ACTUATOR", path, true,
"WriteTarget: " + valueStr + ", ReadTarget: " + readStr + " ✓", totalDuration);
std::cout << COLOR_GREEN << " ✓ " << COLOR_RESET
<< "WriteTarget " << valueStr << " → ReadTarget " << readStr
<< " (" << formatDuration(totalDuration) << ")\n";
} else {
std::string valueStr = formatValue(testValue);
std::string readStr = formatValue(readValue);
addResult(testType + "_ACTUATOR", path, false,
"MISMATCH - WriteTarget: " + valueStr + ", ReadTarget: " + readStr, totalDuration);
std::cout << COLOR_RED << " ✗ " << COLOR_RESET
<< "MISMATCH - Wrote target " << valueStr << " but read " << readStr << "\n";
}
}
}
// Helper to format values for output
template<typename T>
std::string formatValue(const T& value) {
if constexpr (std::is_same_v<T, bool>) {
return value ? "true" : "false";
} else if constexpr (std::is_same_v<T, std::string>) {
return "\"" + value + "\"";
} else if constexpr (std::is_same_v<T, int8_t> || std::is_same_v<T, uint8_t>) {
return std::to_string(static_cast<int>(value));
} else {
return std::to_string(value);
}
}
// ==================== SUBSCRIPTION TESTS ====================
void testSubscription(const std::string& path, const std::string& description,
int durationSeconds = 5) {
std::cout << COLOR_CYAN << "\n → Testing subscription: " << COLOR_RESET
<< path << " (" << description << ")\n";
std::atomic<int> updateCount{0};
std::string lastValue;
std::mutex valueMutex;
std::atomic<bool> callbackInvoked{false};
auto start = std::chrono::high_resolution_clock::now();
// subscribeCurrentValue returns void
try {
client.subscribeCurrentValue(path,
[&updateCount, &lastValue, &valueMutex, &callbackInvoked, path]
(const std::string& signalPath, const std::string& value, int field) {
callbackInvoked = true;
updateCount++;
{
std::lock_guard<std::mutex> lock(valueMutex);
lastValue = value;
}
std::cout << COLOR_BLUE << " ↻ " << COLOR_RESET
<< signalPath << " = " << value << " (update #" << updateCount << ")\n";
}
);
// Wait for updates
std::this_thread::sleep_for(std::chrono::seconds(durationSeconds));
auto end = std::chrono::high_resolution_clock::now();
double duration = std::chrono::duration<double, std::milli>(end - start).count();
if (updateCount > 0) {
addResult("SUBSCRIPTION", path, true,
"Received " + std::to_string(updateCount.load()) + " updates", duration);
std::cout << COLOR_GREEN << " ✓ " << COLOR_RESET
<< "Subscription successful (" << updateCount
<< " updates in " << durationSeconds << "s)\n";
} else if (callbackInvoked) {
// Subscription worked but no updates (static signal)
addResult("SUBSCRIPTION", path, true,
"Subscribed successfully (no updates - static signal)", duration);
std::cout << COLOR_YELLOW << " ⚠ " << COLOR_RESET
<< "Subscribed but no updates (static signal)\n";
} else {
// Subscription may have failed silently or signal doesn't exist
addResult("SUBSCRIPTION", path, false,
"No callback invoked - signal may not be available", duration);
std::cout << COLOR_YELLOW << " ⊗ " << COLOR_RESET
<< "No updates received (signal not available?)\n";
}
} catch (const std::exception& e) {
addResult("SUBSCRIPTION", path, false,
"Exception: " + std::string(e.what()), 0.0);
std::cout << COLOR_RED << " ✗ " << COLOR_RESET
<< "Exception: " << e.what() << "\n";
}
}
// ==================== STRESS TESTS ====================
void stressTestConcurrentWrites(const std::string& path, float baseValue, int iterations = 100) {
std::cout << COLOR_CYAN << "\n → Stress test: " << iterations
<< " concurrent writes to " << path << COLOR_RESET << "\n";
auto start = std::chrono::high_resolution_clock::now();
int verifiedCount = 0;
for (int i = 0; i < iterations; i++) {
float value = baseValue + (i % 10) * 0.1f;
client.setCurrentValue(path, value);
// Periodically verify (every 10 writes)
if (i % 10 == 0) {
std::this_thread::sleep_for(10ms);
float readValue;
if (client.getCurrentValue(path, readValue)) {
verifiedCount++;
}
}
}
auto end = std::chrono::high_resolution_clock::now();
double duration = std::chrono::duration<double, std::milli>(end - start).count();
double avgLatency = duration / iterations;
if (verifiedCount > 0) {
addResult("STRESS_WRITE", path, true,
std::to_string(iterations) + " writes completed, " +
std::to_string(verifiedCount) + " verified, avg " + formatDuration(avgLatency), duration);
std::cout << COLOR_GREEN << " ✓ " << COLOR_RESET
<< iterations << " writes completed, " << verifiedCount << " verified"
<< " (avg: " << formatDuration(avgLatency) << "/write, total: "
<< formatDuration(duration) << ")\n";
} else {
addResult("STRESS_WRITE", path, false,
"Signal not available for verification", duration);
std::cout << COLOR_YELLOW << " ⊗ " << COLOR_RESET
<< "Could not verify writes (signal not available)\n";
}
}
void stressTestConcurrentWritesActuator(const std::string& path, float baseValue, int iterations = 100) {
std::cout << COLOR_CYAN << "\n → Stress test (Actuator): " << iterations
<< " concurrent target value writes to " << path << COLOR_RESET << "\n";
auto start = std::chrono::high_resolution_clock::now();
int verifiedCount = 0;
for (int i = 0; i < iterations; i++) {
float value = baseValue + (i % 10) * 0.1f;
client.setTargetValue(path, value);
// Periodically verify (every 10 writes)
if (i % 10 == 0) {
std::this_thread::sleep_for(10ms);
float readValue;
if (client.getTargetValue(path, readValue)) {
verifiedCount++;
}
}
}
auto end = std::chrono::high_resolution_clock::now();
double duration = std::chrono::duration<double, std::milli>(end - start).count();
double avgLatency = duration / iterations;
if (verifiedCount > 0) {
addResult("STRESS_WRITE_ACTUATOR", path, true,
std::to_string(iterations) + " target writes completed, " +
std::to_string(verifiedCount) + " verified, avg " + formatDuration(avgLatency), duration);
std::cout << COLOR_GREEN << " ✓ " << COLOR_RESET
<< iterations << " target writes completed, " << verifiedCount << " verified"
<< " (avg: " << formatDuration(avgLatency) << "/write, total: "
<< formatDuration(duration) << ")\n";
} else {
addResult("STRESS_WRITE_ACTUATOR", path, false,
"Signal not available for verification", duration);
std::cout << COLOR_YELLOW << " ⊗ " << COLOR_RESET
<< "Could not verify target writes (signal not available)\n";
}
}
void stressTestConcurrentReads(const std::string& path, int iterations = 100) {
std::cout << COLOR_CYAN << "\n → Stress test: " << iterations
<< " concurrent reads from " << path << COLOR_RESET << "\n";
auto start = std::chrono::high_resolution_clock::now();
int successCount = 0;
float lastValue = 0.0f;
for (int i = 0; i < iterations; i++) {
float value;
if (client.getCurrentValue(path, value)) {
successCount++;
lastValue = value;
}
}
auto end = std::chrono::high_resolution_clock::now();
double duration = std::chrono::duration<double, std::milli>(end - start).count();
double avgLatency = duration / iterations;
if (successCount > 0) {
addResult("STRESS_READ", path, true,
std::to_string(successCount) + "/" + std::to_string(iterations) +
" reads succeeded, avg " + formatDuration(avgLatency), duration);
std::cout << COLOR_GREEN << " ✓ " << COLOR_RESET
<< successCount << "/" << iterations << " reads succeeded"
<< " (avg: " << formatDuration(avgLatency) << "/read, total: "
<< formatDuration(duration) << ")\n";
} else {
addResult("STRESS_READ", path, false,
"All reads failed - signal not available", duration);
std::cout << COLOR_YELLOW << " ⊗ " << COLOR_RESET
<< "All reads failed (signal not available)\n";
}
}
// ==================== REPORT GENERATION ====================
void printSummary() const {
std::cout << "\n" << COLOR_BOLD << "========================================\n";
std::cout << " TEST SUMMARY REPORT\n";
std::cout << "========================================" << COLOR_RESET << "\n\n";
std::cout << "Total Tests: " << totalTests << "\n";
std::cout << COLOR_GREEN << "Passed: " << passedTests << COLOR_RESET << "\n";
std::cout << COLOR_RED << "Failed: " << failedTests << COLOR_RESET << "\n";
std::cout << COLOR_YELLOW << "Skipped: " << skippedTests
<< " (unavailable signals)" << COLOR_RESET << "\n\n";
int availableTests = totalTests - skippedTests;
double successRate = availableTests > 0 ?
(double)(passedTests) / availableTests * 100.0 : 0.0;
std::cout << "Success Rate: " << std::fixed << std::setprecision(1)
<< successRate << "% (excluding skipped)\n\n";
// Group results by test type
std::map<std::string, int> testTypeCounts;
std::map<std::string, int> testTypeSuccess;
for (const auto& result : results) {
testTypeCounts[result.testName]++;
if (result.passed) {
testTypeSuccess[result.testName]++;
}
}
std::cout << COLOR_BOLD << "Results by Test Type:" << COLOR_RESET << "\n";
for (const auto& [testType, count] : testTypeCounts) {
int success = testTypeSuccess[testType];
std::cout << " " << std::setw(20) << std::left << testType << ": "
<< success << "/" << count << "\n";
}
std::cout << "\n" << COLOR_BOLD << "========================================"
<< COLOR_RESET << "\n\n";
}
void saveReport(const std::string& filename) const {
std::ofstream file(filename);
if (!file.is_open()) {
std::cerr << COLOR_RED << "Failed to open report file: " << filename << COLOR_RESET << "\n";
return;
}
auto now = std::chrono::system_clock::now();
auto time = std::chrono::system_clock::to_time_t(now);
file << "VSS Signal End-to-End Test Report\n";
file << "Generated: " << std::ctime(&time) << "\n";
file << "Total Tests: " << totalTests << "\n";
file << "Passed: " << passedTests << "\n";
file << "Failed: " << failedTests << "\n";
file << "Skipped: " << skippedTests << "\n\n";
file << "Detailed Results:\n";
file << std::string(100, '=') << "\n";
for (const auto& result : results) {
file << "[" << (result.passed ? "PASS" : "FAIL") << "] ";
file << std::setw(25) << result.testName << " | ";
file << std::setw(50) << result.signalPath << " | ";
file << result.message;
if (result.duration_ms > 0) {
file << " (" << std::fixed << std::setprecision(2)
<< result.duration_ms << "ms)";
}
file << "\n";
}
file.close();
std::cout << COLOR_GREEN << "Report saved to: " << filename << COLOR_RESET << "\n";
}
};
// ==================== MAIN TEST RUNNER ====================
int main(int argc, char* argv[]) {
std::cout << COLOR_BOLD << "\n╔════════════════════════════════════════╗\n";
std::cout << "║ VSS Signal End-to-End Test Suite ║\n";
std::cout << "║ (KUKSA Databroker Client Library) ║\n";
std::cout << "╚════════════════════════════════════════╝\n" << COLOR_RESET << "\n";
// Setup Kuksa client - use custom URI if provided, otherwise default
std::string serverURI = (argc > 1) ? argv[1] : "127.0.0.1:55555";
std::cout << "Test Configuration:\n";
std::cout << " Databroker URI: " << serverURI << "\n";
std::cout << " Test Signals: 11 (8 sensors + 3 actuators)\n";
std::cout << " Test Values: ~60 individual write-read cycles\n";
std::cout << " Stress Tests: 200 operations (100 reads + 100 writes)\n\n";
KuksaClient::Config clientConfig;
clientConfig.serverURI = serverURI;
clientConfig.debug = false;
KuksaClient::KuksaClient client(clientConfig);
std::cout << "Connecting to KUKSA Databroker at " << clientConfig.serverURI << "...\n";
try {
client.connect(); // connect() returns void, throws on error
std::cout << COLOR_GREEN << "✓ Connected successfully!\n\n" << COLOR_RESET;
} catch (const std::exception& e) {
std::cerr << COLOR_RED << "Failed to connect to databroker!" << COLOR_RESET << "\n";
std::cerr << "Error: " << e.what() << "\n";
std::cerr << "\nMake sure KUKSA Databroker is running at " << clientConfig.serverURI << "\n";
std::cerr << "Example: docker run -it --rm -p 55555:55555 ghcr.io/eclipse/kuksa.val/databroker:master\n\n";
return 1;
}
VSSSignalTester tester(client);
// ==================== TEST SENSOR SIGNALS (E2E) ====================
std::cout << COLOR_BOLD << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
std::cout << " SENSOR SIGNALS (End-to-End Testing)\n";
std::cout << " Write → Read → Verify\n";
std::cout << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" << COLOR_RESET << "\n";
tester.testE2E<float>("Vehicle.Speed",
{0.0f, 60.5f, 120.0f, 80.5f, 50.0f},
"Vehicle speed (km/h)", "FLOAT");
tester.testE2E<uint32_t>("Vehicle.Powertrain.FuelSystem.Range",
{500, 350, 200, 100, 50},
"Fuel range (km)", "UINT32");
tester.testE2E<int8_t>("Vehicle.Powertrain.Transmission.CurrentGear",
{-1, 0, 1, 2, 3, 4, 5, 6},
"Current gear", "INT8");
tester.testE2E<uint16_t>("Vehicle.Powertrain.CombustionEngine.Speed",
{800, 1500, 3000, 4500, 6000, 1200},
"Engine RPM", "UINT16");
tester.testE2E<uint16_t>("Vehicle.Powertrain.CombustionEngine.Power",
{0, 50, 100, 200, 300, 150, 0},
"Engine power (kW)", "UINT16");
tester.testE2E<bool>("Vehicle.Powertrain.IsIgnitionOn",
{true, false, true},
"Ignition status", "BOOL");
tester.testE2E<float>("Vehicle.Chassis.Accelerator.PedalPosition",
{0.0f, 25.0f, 50.0f, 75.0f, 100.0f, 50.0f, 0.0f},
"Accelerator pedal (%)", "FLOAT");
tester.testE2E<float>("Vehicle.Chassis.Brake.PedalPosition",
{0.0f, 30.0f, 60.0f, 100.0f, 0.0f},
"Brake pedal (%)", "FLOAT");
// ==================== TEST ACTUATOR SIGNALS (E2E) ====================
std::cout << "\n" << COLOR_BOLD << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
std::cout << " ACTUATOR SIGNALS (End-to-End Testing)\n";
std::cout << " Write → Read → Verify\n";
std::cout << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" << COLOR_RESET << "\n";
tester.testE2EActuator<std::string>("Vehicle.Body.DriveMode",
{"ECO", "NORMAL", "SPORT", "U_SPORTINESS", "NORMAL"},
"Drive mode", "STRING");
tester.testE2EActuator<float>("Vehicle.Chassis.Sportiness.Target",
{0.0f, 25.0f, 50.0f, 75.0f, 100.0f, 50.0f},
"Sportiness target (%)", "FLOAT");
tester.testE2EActuator<uint8_t>("Vehicle.Chassis.Sportiness.Mode",
{0, 2, 5, 8, 10, 5},
"Sportiness mode level", "UINT8");
// ==================== SUBSCRIPTION TESTS ====================
std::cout << "\n" << COLOR_BOLD << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
std::cout << " SUBSCRIPTION TESTS\n";
std::cout << " (Will monitor for 3 seconds each)\n";
std::cout << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" << COLOR_RESET << "\n";
tester.testSubscription("Vehicle.Speed", "Speed monitoring", 3);
tester.testSubscription("Vehicle.Chassis.Accelerator.PedalPosition", "Accelerator monitoring", 3);
// ==================== STRESS TESTS ====================
std::cout << "\n" << COLOR_BOLD << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n";
std::cout << " STRESS TESTS\n";
std::cout << "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" << COLOR_RESET << "\n";
tester.stressTestConcurrentWritesActuator("Vehicle.Chassis.Sportiness.Target", 50.0f, 100);
tester.stressTestConcurrentReads("Vehicle.Speed", 100);
// ==================== FINAL REPORT ====================
tester.printSummary();
tester.saveReport("/tmp/test_results.txt");
std::cout << COLOR_GREEN << "\n✓ All tests completed!\n" << COLOR_RESET;
std::cout << "\nTest report saved to: /tmp/test_results.txt\n";
std::cout << "View inside container: cat /tmp/test_results.txt\n\n";
return 0;
}