Implemented full e2e testing
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "StandardParser.h"
|
||||
#include "StreamString.h"
|
||||
#include "HighResolutionTimer.h"
|
||||
#include "TestCommon.h"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -31,14 +32,19 @@ void TestFullTracePipeline() {
|
||||
assert(sig != NULL_PTR(DebugSignalInfo*));
|
||||
printf("Signal registered with ID: %u\n", sig->internalID);
|
||||
|
||||
// 3. Enable Trace manually
|
||||
sig->isTracing = true;
|
||||
sig->decimationFactor = 1;
|
||||
// 3. Enable Trace via the real API (DebugService::TraceSignal), not by
|
||||
// poking isTracing directly — DebugService's override also flags
|
||||
// udpsConfigPending so the streamer thread rebuilds its UDPS slot table
|
||||
// and CONFIG packet. Without that, the streamer's anyData/slot-match
|
||||
// logic (DebugService.cpp Streamer()) never finds a slot for this
|
||||
// signal's samples and silently never sends any DATA packet at all.
|
||||
assert(service.TraceSignal("TraceTest.Signal", true, 1) == 1u);
|
||||
|
||||
// 4. Setup a local UDP listener
|
||||
BasicUDPSocket listener;
|
||||
assert(listener.Open());
|
||||
assert(listener.Listen(8083));
|
||||
GrowUDPRecvBuffer(listener);
|
||||
|
||||
// 5. Simulate cycles
|
||||
printf("Simulating cycles...\n");
|
||||
@@ -49,29 +55,10 @@ void TestFullTracePipeline() {
|
||||
Sleep::MSec(10);
|
||||
}
|
||||
|
||||
// 6. Try to read from UDP
|
||||
char buffer[2048];
|
||||
uint32 size = 2048;
|
||||
TimeoutType timeout(1000); // 1s
|
||||
if (listener.Read(buffer, size, timeout)) {
|
||||
printf("SUCCESS: Received %u bytes over UDP!\n", size);
|
||||
|
||||
TraceHeader *h = (TraceHeader*)buffer;
|
||||
printf("Header: Magic=0x%X, Count=%u, Seq=%u\n", h->magic, h->count, h->seq);
|
||||
|
||||
uint32 offset = sizeof(TraceHeader);
|
||||
if (size >= offset + 16) {
|
||||
uint32 recId = *(uint32*)(&buffer[offset]);
|
||||
uint64 recTs = *(uint64*)(&buffer[offset + 4]);
|
||||
uint32 recSize = *(uint32*)(&buffer[offset + 12]);
|
||||
printf("Data: ID=%u, TS=%llu, Size=%u\n", recId, (unsigned long long)recTs, recSize);
|
||||
if (size >= offset + 16 + recSize) {
|
||||
if (recSize == 4) {
|
||||
uint32 recVal = *(uint32*)(&buffer[offset + 16]);
|
||||
printf("Value=%u\n", recVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 6. Try to read a real UDPS DATA packet from UDP
|
||||
uint32 val = 0;
|
||||
if (ReadUDPSTraceScalar(listener, 2000, val)) {
|
||||
printf("SUCCESS: Received UDPS DATA packet! Value=%u\n", val);
|
||||
} else {
|
||||
printf("FAILURE: No UDP packets received.\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user