Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2012-02-19 12:59:31 +0000
committerThomas Schuetz2012-02-19 12:59:31 +0000
commitee42f0a62cd3443d25aab12f7a8703ae7d58e3b6 (patch)
treec17ab2284a5f73dfd6758f017a4c153276952a26 /tests/org.eclipse.etrice.generator.c.tests
parente30f9cc595fb5d8ccbb4006b486dbbed7567085c (diff)
downloadorg.eclipse.etrice-ee42f0a62cd3443d25aab12f7a8703ae7d58e3b6.tar.gz
org.eclipse.etrice-ee42f0a62cd3443d25aab12f7a8703ae7d58e3b6.tar.xz
org.eclipse.etrice-ee42f0a62cd3443d25aab12f7a8703ae7d58e3b6.zip
[runtime] added LowWaterMark for Message Service
Diffstat (limited to 'tests/org.eclipse.etrice.generator.c.tests')
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c69
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq126
-rw-r--r--tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml3
3 files changed, 194 insertions, 4 deletions
diff --git a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c
index c8b7fbf70..769612f84 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c
+++ b/tests/org.eclipse.etrice.generator.c.tests/src/test/runtime/TestEtMessageService.c
@@ -44,9 +44,6 @@ void DummyMessageDispatcher(const etMessage* msg){
}
}
-
-
-
void TestEtMessageService_init(void){
etMessageService msgService;
@@ -168,11 +165,77 @@ void TestEtMessageService_execute(void){
EXPECT_EQUAL_INT16("deliverAllMessages receivedEventIDCounter", 2, receivedEventIDCounter);
}
+void TestEtMessageService_getMessagePoolLowWaterMark(void){
+ etMessageService msgService;
+ uint16 max = 6;
+ uint16 blockSize = 32;
+ uint8 msgBuffer[max*blockSize];
+
+ etMessageService_init(&msgService, msgBuffer, max, blockSize, DummyMessageDispatcher);
+
+ EXPECT_EQUAL_INT16("inital low water mark", max, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ // get messages from pool
+ etMessage* msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessage* msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+
+ // define content
+ msg1->address = 11;
+ msg1->evtID = 111;
+ msg2->address = 22;
+ msg2->evtID = 222;
+
+ // push messages to queue
+ etMessageService_pushMessage(&msgService, msg2);
+ etMessageService_pushMessage(&msgService, msg1);
+
+ EXPECT_EQUAL_INT16("low water mark 1", max-2, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ // pop messages from queue
+ etMessage* rcvMsg1 = etMessageService_popMessage(&msgService);
+ etMessage* rcvMsg2 = etMessageService_popMessage(&msgService);
+
+ etMessageService_returnMessageBuffer(&msgService, rcvMsg1);
+ etMessageService_returnMessageBuffer(&msgService, rcvMsg2);
+
+ EXPECT_EQUAL_INT16("low water mark 2", max-2, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ msg2 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ etMessageService_pushMessage(&msgService, msg1);
+
+ /*still the same*/
+ EXPECT_EQUAL_INT16("low water mark 3", max-2, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ etMessageService_pushMessage(&msgService, msg2);
+
+ /* no message left */
+ EXPECT_EQUAL_INT16("low water mark 4", 0, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+ msg1 = etMessageService_getMessageBuffer(&msgService, sizeof(etMessage));
+ EXPECT_EQUAL_PTR("check message for NULL", NULL, msg1);
+
+ /* still no message left */
+ EXPECT_EQUAL_INT16("low water mark 6", 0, etMessageService_getMessagePoolLowWaterMark(&msgService));
+
+
+}
+
+
void TestEtMessageService_runSuite(void){
etUnit_openTestSuite("TestEtMessageService");
ADD_TESTCASE(TestEtMessageService_init);
ADD_TESTCASE(TestEtMessageService_GetPushPopReturn);
ADD_TESTCASE(TestEtMessageService_GetReturn);
ADD_TESTCASE(TestEtMessageService_execute);
+ ADD_TESTCASE(TestEtMessageService_getMessagePoolLowWaterMark)
etUnit_closeTestSuite();
}
diff --git a/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq b/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq
index 617db491a..d4cec0ba3 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq
+++ b/tests/org.eclipse.etrice.generator.c.tests/tmp/msc.seq
@@ -12179,4 +12179,130 @@ etMessageService ==> etMessageQueue isNotEmpty
etMessageService <== etMessageQueue
etMessageService <== etMessageService
RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService init
+etMessageService ==> etMessageQueue init
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue init
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageService initMessagePool
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+etMessageService <== etMessageService
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService popMessage
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService popMessage
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService returnMessageBuffer
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService returnMessageBuffer
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+etMessageService ==> etMessageQueue pop
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService pushMessage
+etMessageService ==> etMessageQueue push
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessageBuffer
+RunAllTestcases <== etMessageService
+RunAllTestcases ==> etMessageService getMessagePoolLowWaterMark
+etMessageService ==> etMessageQueue getHightWaterMark
+etMessageService <== etMessageQueue
+RunAllTestcases <== etMessageService
RunAllTestcases <== RunAllTestcases
diff --git a/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml b/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml
index 5d2e44978..b32d29723 100644
--- a/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml
+++ b/tests/org.eclipse.etrice.generator.c.tests/tmp/testlog/TestCRuntime.xml
@@ -4,13 +4,14 @@
</testsuite>
<testsuite name="TestEtMessageQueue" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtMessageQueue_testPushPop" time="0"/>
- <testcase name="TestEtMessageQueue_testMassiveMessaging" time="9"/>
+ <testcase name="TestEtMessageQueue_testMassiveMessaging" time="0"/>
</testsuite>
<testsuite name="TestEtMessageService" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtMessageService_init" time="0"/>
<testcase name="TestEtMessageService_GetPushPopReturn" time="0"/>
<testcase name="TestEtMessageService_GetReturn" time="0"/>
<testcase name="TestEtMessageService_execute" time="0"/>
+ <testcase name="TestEtMessageService_getMessagePoolLowWaterMark" time="0"/>
</testsuite>
<testsuite name="TestEtUnit" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtUnit_Expect_Order" time="0"/>

Back to the top