Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.etrice.runtime.c.tests')
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/.cproject6
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/.gitignore3
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c8
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c184
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.h21
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.c69
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.h21
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestCRuntime.etu44
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestEtUnitSpecial.etu4
9 files changed, 336 insertions, 24 deletions
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/.cproject b/tests/org.eclipse.etrice.runtime.c.tests/.cproject
index f5852fc5f..3588b07fc 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/.cproject
+++ b/tests/org.eclipse.etrice.runtime.c.tests/.cproject
@@ -20,7 +20,7 @@
<targetPlatform id="cdt.managedbuild.target.gnu.platform.mingw.exe.debug.1073090191" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.mingw.exe.debug"/>
<builder buildPath="${workspace_loc:/org.eclipse.etrice.runtime.c.tests/Debug}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.64789272" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
<tool id="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug.1179559506" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.exe.debug">
- <option id="gnu.both.asm.option.include.paths.216630259" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
+ <option id="gnu.both.asm.option.include.paths.216630259" name="Include paths (-I)" superClass="gnu.both.asm.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.c}&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.assembler.input.1410253936" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
@@ -35,6 +35,7 @@
<option id="gnu.c.compiler.mingw.exe.debug.option.debugging.level.395490525" name="Debug Level" superClass="gnu.c.compiler.mingw.exe.debug.option.debugging.level" value="gnu.c.debugging.level.max" valueType="enumerated"/>
<option id="gnu.c.compiler.option.include.paths.1357425285" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.c}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.c/src/config}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.c/src/common}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/org.eclipse.etrice.runtime.c/src/platforms/generic}&quot;"/>
</option>
@@ -62,7 +63,7 @@
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/org.eclipse.etrice.runtime.c"/>
<entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/org.eclipse.etrice.runtime.c/Debug"/>
- <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.runtime.c"/>
+ <entry flags="RESOLVED" kind="libraryFile" name="org.eclipse.etrice.runtime.c" srcPrefixMapping="" srcRootPath=""/>
</externalSetting>
</externalSettings>
</storageModule>
@@ -123,4 +124,5 @@
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="refreshScope"/>
+ <storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/.gitignore b/tests/org.eclipse.etrice.runtime.c.tests/.gitignore
index 68a1439f6..641b47de7 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/.gitignore
+++ b/tests/org.eclipse.etrice.runtime.c.tests/.gitignore
@@ -2,5 +2,4 @@ Debug
Release
src-gen/*
!src-gen/readme.txt
-
-
+tmp/testlog/*.seq
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c
index f4ec67e96..253368937 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c
@@ -26,14 +26,20 @@
#include "TestEtMessageQueue.h"
#include "TestEtMessageService.h"
#include "TestEtUnit.h"
+#include "TestEtMemory.h"
+#include "TestEtQueue.h"
#include "etUnit/etUnit.h"
+#include "debugging/etMSCLogger.h"
void RunCRuntimeTestcases(void){
etInt16 id;
+ etMSCLogger_open("tmp/testlog", "test.log");
etUnit_open("tmp/testlog","TestCRuntime");
+ TestEtQueue_runSuite();
+ TestEtMemory_runSuite();
TestEtMessage_runSuite();
TestEtMessageQueue_runSuite();
TestEtMessageService_runSuite();
@@ -46,5 +52,7 @@ void RunCRuntimeTestcases(void){
id = etUnit_openAll("tmp/testlog","TestEtUnitSpecial", "etUnit", "openAll and closeAll");
EXPECT_TRUE(id, "Open and Close", TRUE);
etUnit_closeAll(id);
+
+ etMSCLogger_close();
}
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c
new file mode 100644
index 000000000..da970c6fa
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.c
@@ -0,0 +1,184 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "TestEtMemory.h"
+
+#include <stddef.h>
+#include <string.h>
+#include "etUnit/etUnit.h"
+#include "base/etMemory_FixedSize.h"
+#include "base/etMemory_FreeList.h"
+
+#define BUF_SIZE (256*1024)
+#define BLOCK_SIZE 128
+#define TEST_BLOCKS 1024
+#define TEST_BLOCK_SIZE 64
+
+#define NOBJ 32
+#define NSLOTS 8
+#define SIZE0 64
+#define SIZE1 16
+#define SIZE2 32
+#define SIZE3 48
+#define SIZE4 (16*8)
+#define SIZE5 112
+#define SIZE6 96
+
+
+static void TestEtMemory_testFixedSize(etInt16 id) {
+ etUInt8 buffer[BUF_SIZE];
+ etUInt8* objects[TEST_BLOCKS];
+ int i;
+ etMemory* mem = etMemory_FixedSize_init(buffer, BUF_SIZE, BLOCK_SIZE);
+ EXPECT_TRUE(id, "mem!=NULL", mem!=NULL);
+
+ for (i=0; i<TEST_BLOCKS; ++i) {
+ objects[i] = mem->alloc(mem, TEST_BLOCK_SIZE);
+ if (objects[i]==NULL)
+ EXPECT_TRUE(id, "objects[i]==NULL", FALSE);
+
+ memset(objects[i], i%4, TEST_BLOCK_SIZE);
+ }
+ for (i=0; i<TEST_BLOCKS/2; ++i) {
+ mem->free(mem, objects[i*2], TEST_BLOCK_SIZE);
+ }
+ for (i=0; i<TEST_BLOCKS/2; ++i) {
+ objects[i*2] = mem->alloc(mem, TEST_BLOCK_SIZE);
+ if (objects[i*2]==NULL)
+ EXPECT_TRUE(id, "objects[i*2]==NULL", FALSE);
+ }
+}
+
+static void local_alloc(etInt16 id, etMemory* mem, etUInt8* objects[7][NOBJ], etUInt8 sizes[7]) {
+ int i;
+#define KIND 0
+ for (i=0; i<NOBJ; ++i) {
+ objects[KIND][i] = mem->alloc(mem, sizes[KIND]);
+ if (objects[KIND][i]==NULL)
+ EXPECT_TRUE(id, "objects[KIND][i]==NULL", FALSE);
+ }
+
+#undef KIND
+#define KIND 1
+ for (i=0; i<NOBJ; ++i) {
+ objects[KIND][i] = mem->alloc(mem, sizes[KIND]);
+ if (objects[KIND][i]==NULL)
+ EXPECT_TRUE(id, "objects[KIND][i]==NULL", FALSE);
+ }
+
+#undef KIND
+#define KIND 2
+ for (i=0; i<NOBJ; ++i) {
+ objects[KIND][i] = mem->alloc(mem, sizes[KIND]);
+ if (objects[KIND][i]==NULL)
+ EXPECT_TRUE(id, "objects[KIND][i]==NULL", FALSE);
+ }
+
+#undef KIND
+#define KIND 3
+ for (i=0; i<NOBJ; ++i) {
+ objects[KIND][i] = mem->alloc(mem, sizes[KIND]);
+ if (objects[KIND][i]==NULL)
+ EXPECT_TRUE(id, "objects[KIND][i]==NULL", FALSE);
+ }
+
+#undef KIND
+#define KIND 4
+ for (i=0; i<NOBJ; ++i) {
+ objects[KIND][i] = mem->alloc(mem, sizes[KIND]);
+ if (objects[KIND][i]==NULL)
+ EXPECT_TRUE(id, "objects[KIND][i]==NULL", FALSE);
+ }
+
+#undef KIND
+#define KIND 5
+ for (i=0; i<NOBJ; ++i) {
+ objects[KIND][i] = mem->alloc(mem, sizes[KIND]);
+ if (objects[KIND][i]==NULL)
+ EXPECT_TRUE(id, "objects[KIND][i]==NULL", FALSE);
+ }
+
+#undef KIND
+#define KIND 6
+ for (i=0; i<NOBJ; ++i) {
+ objects[KIND][i] = mem->alloc(mem, sizes[KIND]);
+ if (objects[KIND][i]==NULL)
+ EXPECT_TRUE(id, "objects[KIND][i]==NULL", FALSE);
+ }
+}
+
+
+static void local_free(etInt16 id, etMemory* mem, etUInt8* objects[7][NOBJ], etUInt8 sizes[7]) {
+ int i;
+#undef KIND
+#define KIND 0
+ for (i=0; i<NOBJ; ++i) {
+ mem->free(mem, objects[KIND][i], sizes[KIND]);
+ }
+
+#undef KIND
+#define KIND 1
+ for (i=0; i<NOBJ; ++i) {
+ mem->free(mem, objects[KIND][i], sizes[KIND]);
+ }
+
+#undef KIND
+#define KIND 2
+ for (i=0; i<NOBJ; ++i) {
+ mem->free(mem, objects[KIND][i], sizes[KIND]);
+ }
+
+#undef KIND
+#define KIND 3
+ for (i=0; i<NOBJ; ++i) {
+ mem->free(mem, objects[KIND][i], sizes[KIND]);
+ }
+
+#undef KIND
+#define KIND 4
+ for (i=0; i<NOBJ; ++i) {
+ mem->free(mem, objects[KIND][i], sizes[KIND]);
+ }
+
+#undef KIND
+#define KIND 5
+ for (i=0; i<NOBJ; ++i) {
+ mem->free(mem, objects[KIND][i], sizes[KIND]);
+ }
+
+#undef KIND
+#define KIND 6
+ for (i=0; i<NOBJ; ++i) {
+ mem->free(mem, objects[KIND][i], sizes[KIND]);
+ }
+}
+
+static void TestEtMemory_testFreeList(etInt16 id) {
+ static etUInt8 buffer[BUF_SIZE];
+ static etUInt8 sizes[7] = { SIZE0, SIZE1, SIZE2, SIZE3, SIZE4, SIZE5, SIZE6 };
+ etUInt8* objects[7][NOBJ];
+ etMemory* mem = etMemory_FreeList_init(buffer, BUF_SIZE, NSLOTS);
+ EXPECT_TRUE(id, "mem!=NULL", mem!=NULL);
+
+ local_alloc(id, mem, objects, sizes);
+ local_free(id, mem, objects, sizes);
+ local_alloc(id, mem, objects, sizes);
+ local_free(id, mem, objects, sizes);
+}
+
+void TestEtMemory_runSuite(void){
+ etUnit_openTestSuite("TestMemory");
+ ADD_TESTCASE(TestEtMemory_testFixedSize);
+ ADD_TESTCASE(TestEtMemory_testFreeList);
+ etUnit_closeTestSuite();
+}
+
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.h b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.h
new file mode 100644
index 000000000..107c6a504
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtMemory.h
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _TEST_MEMORY_H_
+#define _TEST_MEMORY_H_
+
+#include "base/etMemory.h"
+
+void TestEtMemory_runSuite(void);
+
+
+#endif /* _TEST_MEMORY_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.c
new file mode 100644
index 000000000..8479ac93f
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.c
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "TestEtQueue.h"
+
+#include <stddef.h>
+#include "etUnit/etUnit.h"
+#include "base/etQueue.h"
+
+#define MAX 1000
+
+typedef struct etTestObject {
+ etQueueObj base;
+ etInt16 a;
+ etInt16 b;
+} etTestObject;
+
+static void TestEtQueue_test(etInt16 id){
+ etTestObject objects[MAX];
+ int16 i;
+
+ etQueue queue;
+ etQueue_init(&queue);
+
+ for(i=0; i<MAX; i++){
+ objects[i].a = i;
+ objects[i].b = i*2;
+ }
+
+ int j;
+ for(j=0; j<3; j++){
+ for (i=0; i<MAX; i++){
+ etQueue_push(&queue, &(objects[i].base));
+ }
+ for (i=0; i<MAX; i++){
+ etTestObject* obj = (etTestObject*) etQueue_pop(&queue);
+ // EXPECTS are hidden to avoid too many testcases in log
+ if (obj == NULL){
+ EXPECT_FALSE(id, "obj == NULL", TRUE);
+ break;
+ }
+ if (2*obj->a != obj->b){
+ EXPECT_FALSE(id, "2*obj->a != obj->b", TRUE);
+ break;
+ }
+ if (obj->a != i){
+ EXPECT_FALSE(id, "obj->a != i", TRUE);
+ break;
+ }
+ }
+ EXPECT_EQUAL_INT32(id, "i==MAX", MAX, i);
+ }
+}
+
+void TestEtQueue_runSuite(void){
+ etUnit_openTestSuite("TestQueue");
+ ADD_TESTCASE(TestEtQueue_test);
+ etUnit_closeTestSuite();
+}
+
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.h b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.h
new file mode 100644
index 000000000..1a4f9e90e
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtQueue.h
@@ -0,0 +1,21 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _TEST_QUEUE_H_
+#define _TEST_QUEUE_H_
+
+#include "base/etQueue.h"
+
+void TestEtQueue_runSuite(void);
+
+
+#endif /* _TEST_QUEUE_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestCRuntime.etu b/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestCRuntime.etu
index 7cc551b44..7d9ae7f3f 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestCRuntime.etu
+++ b/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestCRuntime.etu
@@ -1,25 +1,33 @@
etUnit report
+ts start: TestQueue
+tc start 1: TestEtQueue_test
+tc end 1: 10
+ts start: TestMemory
+tc start 2: TestEtMemory_testFixedSize
+tc end 2: 20
+tc start 3: TestEtMemory_testFreeList
+tc end 3: 89830
ts start: TestMessage
-tc start 1: TestEtMessage_testBasicMessage
-tc end 1: 0
+tc start 4: TestEtMessage_testBasicMessage
+tc end 4: 0
ts start: TestEtMessageQueue
-tc start 2: TestEtMessageQueue_testPushPop
-tc end 2: 1
-tc start 3: TestEtMessageQueue_testMassiveMessaging
-tc end 3: 167
+tc start 5: TestEtMessageQueue_testPushPop
+tc end 5: 0
+tc start 6: TestEtMessageQueue_testMassiveMessaging
+tc end 6: 15
ts start: TestEtMessageService
-tc start 4: TestEtMessageService_init
-tc end 4: 0
-tc start 5: TestEtMessageService_GetPushPopReturn
-tc end 5: 1
-tc start 6: TestEtMessageService_GetReturn
-tc end 6: 1
-tc start 7: TestEtMessageService_execute
+tc start 7: TestEtMessageService_init
tc end 7: 0
-tc start 8: TestEtMessageService_getMessagePoolLowWaterMark
-tc end 8: 2
-ts start: TestEtUnit
-tc start 9: TestEtUnit_Expect_Order
+tc start 8: TestEtMessageService_GetPushPopReturn
+tc end 8: 0
+tc start 9: TestEtMessageService_GetReturn
tc end 9: 0
-tc start 10: TestEtUnit_Expect
+tc start 10: TestEtMessageService_execute
tc end 10: 0
+tc start 11: TestEtMessageService_getMessagePoolLowWaterMark
+tc end 11: 0
+ts start: TestEtUnit
+tc start 12: TestEtUnit_Expect_Order
+tc end 12: 0
+tc start 13: TestEtUnit_Expect
+tc end 13: 0
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestEtUnitSpecial.etu b/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestEtUnitSpecial.etu
index 78f14cc25..6f756645a 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestEtUnitSpecial.etu
+++ b/tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestEtUnitSpecial.etu
@@ -1,4 +1,4 @@
etUnit report
ts start: etUnit
-tc start 11: openAll and closeAll
-tc end 11: 0
+tc start 14: openAll and closeAll
+tc end 14: 0

Back to the top