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
|
/*******************************************************************************
* Copyright (c) 2016 protos software gmbh (http://www.protos.de).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* CONTRIBUTORS:
* Jan Belle (initial contribution)
*
*******************************************************************************/
#include "debugging/DebuggingServiceTest.h"
#include "common/debugging/DebuggingService.h"
#include "common/messaging/MessageService.h"
#include "common/messaging/RTServices.h"
#include "common/messaging/StaticMessageMemory.h"
#include "etUnit/etUnit.h"
#include <iostream>
using namespace etRuntime;
void DebuggingServiceTest::testLogging() {
MessageService msgSvc(NULL, IMessageService::BLOCKED, 0, 0,
"TestMessageService", new StaticMessageMemory(NULL, "TestMemory", 64, 100));
RTServices::getInstance().getMsgSvcCtrl().addMsgSvc(msgSvc);
RTServices::getInstance().getMsgSvcCtrl().start();
SubSystemClass subSystem(NULL, "TestSubSystem");
ActorClass actor1(&subSystem, "TestActor1");
ActorClass actor2(&subSystem, "TestActor2");
Port port1(&actor1, "TestPort1");
Port port2(&actor2, "TestPort2");
DebuggingService& dbgSvc = DebuggingService::getInstance();
dbgSvc.getAsyncLogger().setMSC("DebuggingServiceTest", "log/testlog/");
dbgSvc.getAsyncLogger().open();
InterfaceItemBase::connect(&subSystem, port1.getInstancePath(),
port2.getInstancePath());
dbgSvc.addPortInstance(port1);
dbgSvc.addPortInstance(port2);
dbgSvc.addMessageActorCreate(subSystem, "TestActor1");
dbgSvc.addMessageActorCreate(subSystem, "TestActor2");
dbgSvc.addMessageActorCreate(actor1, "SubActor");
dbgSvc.addMessageAsyncOut(port1.getAddress(), port2.getAddress(),
"MessageAsync");
dbgSvc.addMessageAsyncIn(port1.getAddress(), port2.getAddress(),
"MessageAsync");
dbgSvc.addMessageSyncCall(port1.getAddress(), port2.getAddress(),
"MessageSyncCall");
dbgSvc.addMessageSyncReturn(port1.getAddress(), port2.getAddress(),
"MessageSyncReturn");
dbgSvc.addActorState(actor1, "TestState");
dbgSvc.addMessageActorDestroy(actor1);
dbgSvc.addVisibleComment("This is a comment");
dbgSvc.removePortInstance(port1);
dbgSvc.removePortInstance(port2);
dbgSvc.getAsyncLogger().close();
RTServices::getInstance().getMsgSvcCtrl().stop();
const char* failMsg = "DebuggingServiceTest failed";
Vector<String>& result = dbgSvc.getAsyncLogger().getCommandList();
typedef Vector<String> CmdList;
for (CmdList::iterator it=result.begin(); it!=result.end(); ++it) {
std::cout << (*it).c_str() << std::endl;
}
Vector<String>::iterator it = result.begin();
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem (!) /TestSubSystem/TestActor1 "));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem (!) /TestSubSystem/TestActor2 "));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem/TestActor1 (!) /TestSubSystem/TestActor1/SubActor "));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem/TestActor1 >-- /TestSubSystem/TestActor2 MessageAsync"));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem/TestActor1 --> /TestSubSystem/TestActor2 MessageAsync"));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem/TestActor1 ==> /TestSubSystem/TestActor2 MessageSyncCall"));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem/TestActor1 <== /TestSubSystem/TestActor2 MessageSyncReturn"));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem/TestActor1 >>> TestState"));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare(
"\t/TestSubSystem (X) /TestSubSystem/TestActor1 "));
++it;
EXPECT_TRUE(m_caseId, failMsg,
0==(*it).compare("# This is a comment"));
++it;
}
void DebuggingServiceTest::runAllTestCases() {
ADD_TESTCASE_CPP(testLogging)
}
|