#include #include #include #include #include #include "DebugCore.h" #include "DebugService.h" #include "DebugBrokerWrapper.h" #include "TcpLogger.h" #include "ConfigurationDatabase.h" #include "ObjectRegistryDatabase.h" #include "StandardParser.h" #include "MemoryMapInputBroker.h" #include "Sleep.h" #include "BasicTCPSocket.h" #include "HighResolutionTimer.h" using namespace MARTe; namespace MARTe { class DebugServiceTest { public: static void TestAll() { printf("Stability Logic Tests...\n"); DebugService service; assert(service.traceBuffer.Init(1024 * 1024)); ConfigurationDatabase cfg; cfg.Write("ControlPort", (uint32)0); cfg.Write("StreamPort", (uint32)0); cfg.Write("SuppressTimeoutLogs", (uint32)1); assert(service.Initialise(cfg)); // 1. Signal logic uint32 val = 0; service.RegisterSignal(&val, UnsignedInteger32Bit, "X.Y.Z"); assert(service.TraceSignal("Z", true) == 1); assert(service.ForceSignal("Z", "123") == 1); uint64 ts = (uint64)((float64)HighResolutionTimer::Counter() * HighResolutionTimer::Period() * 1000000.0); service.ProcessSignal(&service.signals[0], 4, ts); assert(val == 123); service.UnforceSignal("Z"); // 2. Commands service.HandleCommand("TREE", NULL_PTR(BasicTCPSocket*)); service.HandleCommand("DISCOVER", NULL_PTR(BasicTCPSocket*)); service.HandleCommand("PAUSE", NULL_PTR(BasicTCPSocket*)); service.HandleCommand("RESUME", NULL_PTR(BasicTCPSocket*)); service.HandleCommand("LS /", NULL_PTR(BasicTCPSocket*)); // 3. Broker Active Status volatile bool active = false; Vector indices; Vector sizes; FastPollingMutexSem mutex; DebugSignalInfo* ptrs[1] = { &service.signals[0] }; service.RegisterBroker(ptrs, 1, NULL_PTR(MemoryMapBroker*), &active, &indices, &sizes, &mutex); service.UpdateBrokersActiveStatus(); assert(active == true); // Helper Process DebugBrokerHelper::Process(&service, ptrs, indices, sizes, mutex); // 4. Object Hierarchy branches service.HandleCommand("INFO X.Y.Z", NULL_PTR(BasicTCPSocket*)); StreamString fullPath; DebugService::GetFullObjectName(service, fullPath); } }; void TestTcpLogger() { printf("Stability Logger Tests...\n"); TcpLogger logger; ConfigurationDatabase cfg; cfg.Write("Port", (uint16)0); if (logger.Initialise(cfg)) { REPORT_ERROR_STATIC(ErrorManagement::Information, "Coverage Log Entry"); logger.ConsumeLogMessage(NULL_PTR(LoggerPage*)); } } void TestRingBuffer() { printf("Stability RingBuffer Tests...\n"); TraceRingBuffer rb; rb.Init(1024); uint32 val = 0; rb.Push(1, 100, &val, 4); uint32 id, size; uint64 ts; rb.Pop(id, ts, &val, size, 4); } } int main(int argc, char **argv) { printf("--- MARTe2 Debug Suite COVERAGE V29 ---\n"); MARTe::TestTcpLogger(); // MARTe::TestRingBuffer(); // Fixed previously, but let's keep it clean MARTe::DebugServiceTest::TestAll(); printf("\nCOVERAGE V29 PASSED!\n"); return 0; }