Improved overall features
This commit is contained in:
@@ -7,8 +7,7 @@
|
||||
#include "BasicUDPSocket.h"
|
||||
#include "RealTimeApplication.h"
|
||||
#include "StandardParser.h"
|
||||
#include "StreamString.h"
|
||||
#include "GlobalObjectsDatabase.h"
|
||||
#include "TestCommon.h"
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace MARTe;
|
||||
@@ -31,6 +30,7 @@ void TestFullTracePipeline();
|
||||
void RunValidationTest();
|
||||
void TestConfigCommands();
|
||||
void TestGAMSignalTracing();
|
||||
void TestTreeCommand();
|
||||
|
||||
int main() {
|
||||
signal(SIGALRM, timeout_handler);
|
||||
@@ -83,9 +83,9 @@ int main() {
|
||||
// TestConfigCommands(); // Skipping for now
|
||||
Sleep::MSec(1000);
|
||||
|
||||
// printf("\n--- Test 6: GAM Signal Tracing ---\n");
|
||||
// TestGAMSignalTracing();
|
||||
// Sleep::MSec(1000);
|
||||
printf("\n--- Test 6: TREE Command Enhancement ---\n");
|
||||
TestTreeCommand();
|
||||
Sleep::MSec(1000);
|
||||
|
||||
printf("\nAll Integration Tests Finished.\n");
|
||||
|
||||
@@ -94,72 +94,6 @@ int main() {
|
||||
|
||||
// --- Test Implementation ---
|
||||
|
||||
const char8 * const debug_test_config =
|
||||
"DebugService = {"
|
||||
" Class = DebugService "
|
||||
" ControlPort = 8095 "
|
||||
" UdpPort = 8096 "
|
||||
" StreamIP = \"127.0.0.1\" "
|
||||
"}"
|
||||
"App = {"
|
||||
" Class = RealTimeApplication "
|
||||
" +Functions = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +GAM1 = {"
|
||||
" Class = IOGAM "
|
||||
" InputSignals = {"
|
||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
||||
" }"
|
||||
" OutputSignals = {"
|
||||
" Counter = { DataSource = DDB Type = uint32 }"
|
||||
" }"
|
||||
" }"
|
||||
" +GAM2 = {"
|
||||
" Class = IOGAM "
|
||||
" InputSignals = {"
|
||||
" Counter = { DataSource = TimerSlow Type = uint32 Frequency = 10 }"
|
||||
" }"
|
||||
" OutputSignals = {"
|
||||
" Counter = { DataSource = Logger Type = uint32 }"
|
||||
" }"
|
||||
" }"
|
||||
" }"
|
||||
" +Data = {"
|
||||
" Class = ReferenceContainer "
|
||||
" DefaultDataSource = DDB "
|
||||
" +Timer = { Class = LinuxTimer SleepTime = 1000 Signals = { Counter = { Type = uint32 } } }"
|
||||
" +TimerSlow = { Class = LinuxTimer SleepTime = 100000 Signals = { Counter = { Type = uint32 } } }"
|
||||
" +Logger = { Class = LoggerDataSource Signals = { Counter = { Type = uint32 } } }"
|
||||
" +DDB = { Class = GAMDataSource Signals = { Counter = { Type = uint32 } } }"
|
||||
" +DAMS = { Class = TimingDataSource }"
|
||||
" }"
|
||||
" +States = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +State1 = { Class = RealTimeState +Threads = { Class = ReferenceContainer +Thread1 = { Class = RealTimeThread Functions = {GAM1 GAM2} } } }"
|
||||
" }"
|
||||
" +Scheduler = { Class = GAMScheduler TimingDataSource = DAMS }"
|
||||
"}";
|
||||
|
||||
bool SendCommandGAM(uint16 port, const char8* cmd, StreamString &reply) {
|
||||
BasicTCPSocket client;
|
||||
if (!client.Open()) return false;
|
||||
if (!client.Connect("127.0.0.1", port)) return false;
|
||||
|
||||
uint32 s = StringHelper::Length(cmd);
|
||||
if (!client.Write(cmd, s)) return false;
|
||||
|
||||
char buffer[4096];
|
||||
uint32 size = 4096;
|
||||
TimeoutType timeout(2000);
|
||||
if (client.Read(buffer, size, timeout)) {
|
||||
reply.Write(buffer, size);
|
||||
client.Close();
|
||||
return true;
|
||||
}
|
||||
client.Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
void TestGAMSignalTracing() {
|
||||
printf("--- Test: GAM Signal Tracing Issue ---\n");
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
OBJSX = SchedulerTest.x TraceTest.x ValidationTest.x ConfigCommandTest.x
|
||||
OBJSX = SchedulerTest.x TraceTest.x ValidationTest.x ConfigCommandTest.x TreeCommandTest.x TestCommon.x
|
||||
|
||||
PACKAGE = Test/Integration
|
||||
|
||||
@@ -29,6 +29,8 @@ INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4LoggerService
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
|
||||
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
|
||||
INCLUDES += -I$(MARTe2_Components_DIR)/Source/Components/GAMs/IOGAM
|
||||
INCLUDES += -I$(MARTe2_Components_DIR)/Source/Components/DataSources/LinuxTimer
|
||||
|
||||
LIBRARIES += -L$(MARTe2_DIR)/Build/$(TARGET)/Core -lMARTe2
|
||||
LIBRARIES += -L$(MARTe2_Components_DIR)/Build/$(TARGET)/Components/DataSources/LinuxTimer -lLinuxTimer
|
||||
|
||||
74
Test/Integration/TestCommon.cpp
Normal file
74
Test/Integration/TestCommon.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
#include "TestCommon.h"
|
||||
#include "BasicTCPSocket.h"
|
||||
#include "StringHelper.h"
|
||||
#include "TimeoutType.h"
|
||||
|
||||
namespace MARTe {
|
||||
|
||||
const char8 * const debug_test_config =
|
||||
"DebugService = {"
|
||||
" Class = DebugService "
|
||||
" ControlPort = 8095 "
|
||||
" UdpPort = 8096 "
|
||||
" StreamIP = \"127.0.0.1\" "
|
||||
"}"
|
||||
"App = {"
|
||||
" Class = RealTimeApplication "
|
||||
" +Functions = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +GAM1 = {"
|
||||
" Class = IOGAM "
|
||||
" InputSignals = {"
|
||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
||||
" }"
|
||||
" OutputSignals = {"
|
||||
" Counter = { DataSource = DDB Type = uint32 }"
|
||||
" }"
|
||||
" }"
|
||||
" +GAM2 = {"
|
||||
" Class = IOGAM "
|
||||
" InputSignals = {"
|
||||
" Counter = { DataSource = TimerSlow Type = uint32 Frequency = 10 }"
|
||||
" }"
|
||||
" OutputSignals = {"
|
||||
" Counter = { DataSource = Logger Type = uint32 }"
|
||||
" }"
|
||||
" }"
|
||||
" }"
|
||||
" +Data = {"
|
||||
" Class = ReferenceContainer "
|
||||
" DefaultDataSource = DDB "
|
||||
" +Timer = { Class = LinuxTimer SleepTime = 1000 Signals = { Counter = { Type = uint32 } } }"
|
||||
" +TimerSlow = { Class = LinuxTimer SleepTime = 100000 Signals = { Counter = { Type = uint32 } } }"
|
||||
" +Logger = { Class = LoggerDataSource Signals = { Counter = { Type = uint32 } } }"
|
||||
" +DDB = { Class = GAMDataSource Signals = { Counter = { Type = uint32 } } }"
|
||||
" +DAMS = { Class = TimingDataSource }"
|
||||
" }"
|
||||
" +States = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +State1 = { Class = RealTimeState +Threads = { Class = ReferenceContainer +Thread1 = { Class = RealTimeThread Functions = {GAM1 GAM2} } } }"
|
||||
" }"
|
||||
" +Scheduler = { Class = GAMScheduler TimingDataSource = DAMS }"
|
||||
"}";
|
||||
|
||||
bool SendCommandGAM(uint16 port, const char8* cmd, StreamString &reply) {
|
||||
BasicTCPSocket client;
|
||||
if (!client.Open()) return false;
|
||||
if (!client.Connect("127.0.0.1", port)) return false;
|
||||
|
||||
uint32 s = StringHelper::Length(cmd);
|
||||
if (!client.Write(cmd, s)) return false;
|
||||
|
||||
char buffer[16384];
|
||||
uint32 size = 16384;
|
||||
TimeoutType timeout(5000);
|
||||
if (client.Read(buffer, size, timeout)) {
|
||||
reply.Write(buffer, size);
|
||||
client.Close();
|
||||
return true;
|
||||
}
|
||||
client.Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
12
Test/Integration/TestCommon.h
Normal file
12
Test/Integration/TestCommon.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef TESTCOMMON_H
|
||||
#define TESTCOMMON_H
|
||||
|
||||
#include "CompilerTypes.h"
|
||||
#include "StreamString.h"
|
||||
|
||||
namespace MARTe {
|
||||
extern const char8 * const debug_test_config;
|
||||
bool SendCommandGAM(uint16 port, const char8* cmd, StreamString &reply);
|
||||
}
|
||||
|
||||
#endif
|
||||
176
Test/Integration/TreeCommandTest.cpp
Normal file
176
Test/Integration/TreeCommandTest.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
#include "BasicTCPSocket.h"
|
||||
#include "ConfigurationDatabase.h"
|
||||
#include "DebugService.h"
|
||||
#include "GlobalObjectsDatabase.h"
|
||||
#include "ObjectRegistryDatabase.h"
|
||||
#include "RealTimeApplication.h"
|
||||
#include "StandardParser.h"
|
||||
#include "StreamString.h"
|
||||
#include "TestCommon.h"
|
||||
#include "IOGAM.h"
|
||||
#include "LinuxTimer.h"
|
||||
#include "GAMDataSource.h"
|
||||
#include "TimingDataSource.h"
|
||||
#include "GAMScheduler.h"
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace MARTe;
|
||||
|
||||
void TestTreeCommand() {
|
||||
printf("--- Test: TREE Command Enhancement ---\n");
|
||||
|
||||
ObjectRegistryDatabase::Instance()->Purge();
|
||||
Sleep::MSec(2000); // Wait for sockets from previous tests to clear
|
||||
|
||||
ConfigurationDatabase cdb;
|
||||
// Use unique ports to avoid conflict with other tests
|
||||
const char8 * const tree_test_config =
|
||||
"DebugService = {"
|
||||
" Class = DebugService "
|
||||
" ControlPort = 8110 "
|
||||
" UdpPort = 8111 "
|
||||
" StreamIP = \"127.0.0.1\" "
|
||||
"}"
|
||||
"App = {"
|
||||
" Class = RealTimeApplication "
|
||||
" +Functions = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +GAM1 = {"
|
||||
" Class = IOGAM "
|
||||
" InputSignals = {"
|
||||
" Counter = { DataSource = Timer Type = uint32 Frequency = 1000 }"
|
||||
" }"
|
||||
" OutputSignals = {"
|
||||
" Counter = { DataSource = DDB Type = uint32 }"
|
||||
" }"
|
||||
" }"
|
||||
" }"
|
||||
" +Data = {"
|
||||
" Class = ReferenceContainer "
|
||||
" DefaultDataSource = DDB "
|
||||
" +Timer = { Class = LinuxTimer SleepTime = 1000 Signals = { Counter = { Type = uint32 } } }"
|
||||
" +DDB = { Class = GAMDataSource Signals = { Counter = { Type = uint32 } } }"
|
||||
" +DAMS = { Class = TimingDataSource }"
|
||||
" }"
|
||||
" +States = {"
|
||||
" Class = ReferenceContainer "
|
||||
" +State1 = { Class = RealTimeState +Threads = { Class = ReferenceContainer +Thread1 = { Class = RealTimeThread Functions = {GAM1} } } }"
|
||||
" }"
|
||||
" +Scheduler = { Class = GAMScheduler TimingDataSource = DAMS }"
|
||||
"}";
|
||||
|
||||
StreamString ss = tree_test_config;
|
||||
ss.Seek(0);
|
||||
StandardParser parser(ss, cdb);
|
||||
if (!parser.Parse()) {
|
||||
printf("ERROR: Failed to parse config\n");
|
||||
return;
|
||||
}
|
||||
|
||||
cdb.MoveToRoot();
|
||||
uint32 n = cdb.GetNumberOfChildren();
|
||||
for (uint32 i = 0; i < n; i++) {
|
||||
const char8 *name = cdb.GetChildName(i);
|
||||
ConfigurationDatabase child;
|
||||
cdb.MoveRelative(name);
|
||||
cdb.Copy(child);
|
||||
cdb.MoveToAncestor(1u);
|
||||
|
||||
StreamString className;
|
||||
child.Read("Class", className);
|
||||
|
||||
Reference ref(className.Buffer(),
|
||||
GlobalObjectsDatabase::Instance()->GetStandardHeap());
|
||||
if (!ref.IsValid()) {
|
||||
printf("ERROR: Could not create object %s of class %s\n", name,
|
||||
className.Buffer());
|
||||
continue;
|
||||
}
|
||||
ref->SetName(name);
|
||||
if (!ref->Initialise(child)) {
|
||||
printf("ERROR: Failed to initialise object %s\n", name);
|
||||
continue;
|
||||
}
|
||||
ObjectRegistryDatabase::Instance()->Insert(ref);
|
||||
}
|
||||
|
||||
ReferenceT<DebugService> service =
|
||||
ObjectRegistryDatabase::Instance()->Find("DebugService");
|
||||
if (!service.IsValid()) {
|
||||
printf("ERROR: DebugService not found\n");
|
||||
return;
|
||||
}
|
||||
service->SetFullConfig(cdb);
|
||||
|
||||
ReferenceT<RealTimeApplication> app =
|
||||
ObjectRegistryDatabase::Instance()->Find("App");
|
||||
if (!app.IsValid()) {
|
||||
printf("ERROR: App not found\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!app->ConfigureApplication()) {
|
||||
printf("ERROR: ConfigureApplication failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (app->PrepareNextState("State1") != ErrorManagement::NoError) {
|
||||
printf("ERROR: PrepareNextState failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (app->StartNextStateExecution() != ErrorManagement::NoError) {
|
||||
printf("ERROR: StartNextStateExecution failed.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Application started.\n");
|
||||
Sleep::MSec(1000);
|
||||
|
||||
// Step 1: Request TREE
|
||||
StreamString reply;
|
||||
if (SendCommandGAM(8110, "TREE\n", reply)) {
|
||||
printf("TREE response received (len=%llu)\n", reply.Size());
|
||||
// ...
|
||||
}
|
||||
|
||||
// Step 2: SERVICE_INFO
|
||||
printf("\n--- Step 2: SERVICE_INFO ---\n");
|
||||
reply = "";
|
||||
if (SendCommandGAM(8110, "SERVICE_INFO\n", reply)) {
|
||||
printf("SERVICE_INFO response: %s", reply.Buffer());
|
||||
if (StringHelper::SearchString(reply.Buffer(), "TCP_CTRL:8110") != NULL_PTR(const char8 *) &&
|
||||
StringHelper::SearchString(reply.Buffer(), "UDP_STREAM:8111") != NULL_PTR(const char8 *)) {
|
||||
printf("SUCCESS: SERVICE_INFO returned correct ports.\n");
|
||||
} else {
|
||||
printf("FAILURE: SERVICE_INFO returned incorrect data.\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Step 3: MONITOR
|
||||
printf("\n--- Step 3: MONITOR SIGNAL ---\n");
|
||||
reply = "";
|
||||
if (SendCommandGAM(8110, "MONITOR SIGNAL App.Data.Timer.Counter 10\n", reply)) {
|
||||
printf("MONITOR response: %s", reply.Buffer());
|
||||
if (StringHelper::SearchString(reply.Buffer(), "OK MONITOR 1") != NULL_PTR(const char8 *)) {
|
||||
printf("SUCCESS: Signal monitored.\n");
|
||||
} else {
|
||||
printf("FAILURE: Could not monitor signal.\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: UNMONITOR
|
||||
printf("\n--- Step 4: UNMONITOR SIGNAL ---\n");
|
||||
reply = "";
|
||||
if (SendCommandGAM(8110, "UNMONITOR SIGNAL App.Data.Timer.Counter\n", reply)) {
|
||||
printf("UNMONITOR response: %s", reply.Buffer());
|
||||
if (StringHelper::SearchString(reply.Buffer(), "OK UNMONITOR 1") != NULL_PTR(const char8 *)) {
|
||||
printf("SUCCESS: Signal unmonitored.\n");
|
||||
} else {
|
||||
printf("FAILURE: Could not unmonitor signal.\n");
|
||||
}
|
||||
}
|
||||
|
||||
app->StopCurrentStateExecution();
|
||||
ObjectRegistryDatabase::Instance()->Purge();
|
||||
}
|
||||
Reference in New Issue
Block a user