Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c6
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.c16
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.h13
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.c13
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.h13
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.c28
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.h13
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c10
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.c67
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.h26
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestCGenerator.xml6
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestCRuntime.xml (renamed from examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestMessageService.xml)12
-rw-r--r--examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestEtUnitSpecial.xml5
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.abin61590 -> 91062 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/Release/liborg.eclipse.etrice.runtime.c.abin11248 -> 0 bytes
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h8
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etLogger.c82
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etLogger.h48
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etUnit.c121
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/etUnit.h15
20 files changed, 449 insertions, 53 deletions
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c b/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c
index 3408a0434..c21cc4074 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/RunAllTestcases.c
@@ -12,8 +12,6 @@
#include <stdio.h>
-#include "etUnit.h"
-
#include "test/generator/RunCGeneratorTestcases.h"
#include "test/runtime/RunCRuntimeTestcases.h"
@@ -26,11 +24,7 @@ int main(void){
void runTestCases(void){
- etUnit_open("tmp/testlog","TestMessageService");
-
RunCGeneratorTestcases();
RunCRuntimeTestcases();
-
- etUnit_close();
}
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.c
index db8176609..cf2d11e9c 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.c
@@ -1,3 +1,15 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
/*
* RunCGeneratorTestcases.c
*
@@ -8,7 +20,11 @@
#include "RunCGeneratorTestcases.h"
#include "TestDataClass.h"
+#include "etUnit.h"
+
void RunCGeneratorTestcases(void){
+ etUnit_open("tmp/testlog","TestCGenerator");
TestDataClass_runSuite();
+ etUnit_close();
}
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.h b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.h
index 01472caa9..03d5c4276 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.h
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/RunCGeneratorTestcases.h
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
/*
* RunCGeneratorTestcases.h
*
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.c
index 5c481fd4f..e3c521dd3 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.c
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
/*
* TestDataClass.c
*
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.h b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.h
index a3c9b4078..3cbce4bc1 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.h
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/generator/TestDataClass.h
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
/*
* TestEmDataClass.h
*
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.c
index 7180c67b9..a9a502f3b 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.c
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
/*
* RunRuntimeTestcases.c
*
@@ -12,10 +25,25 @@
#include "TestEtMessage.h"
#include "TestEtMessageQueue.h"
#include "TestEtMessageService.h"
+#include "TestEtUnit.h"
+
+#include "etUnit.h"
+
void RunCRuntimeTestcases(void){
+ etUnit_open("tmp/testlog","TestCRuntime");
+
TestEtMessage_runSuite();
TestEtMessageQueue_runSuite();
TestEtMessageService_runSuite();
+ TestEtUnit_runSuite();
+
+ etUnit_close();
+
+ /* special situation for testing openAll and closeAll of etUnit
+ * this has to be done outside of etUnit_open and etUnit_close */
+ etUnit_openAll("tmp/testlog","TestEtUnitSpecial", "etUnit", "openAll and closeAll");
+ EXPECT_TRUE("Open and Close", TRUE);
+ etUnit_closeAll();
}
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.h b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.h
index 604dc0a3e..5d17f7ddb 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.h
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/RunCRuntimeTestcases.h
@@ -1,3 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
/*
* RunRuntimeTestcases.h
*
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c
index 34efb3b31..3a453962c 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtMessageQueue.c
@@ -25,14 +25,14 @@ void TestEtMessageQueue_testPushPop(void){
etMessageQueue_push(&queue1, &msg1);
etMessageQueue_push(&queue1, &msg2);
- EXPECT_EQUAL_INT16("etMessageQueue.size before", 2,queue1.size);
+ EXPECT_EQUAL_INT16("etMessageQueue.size before", 2, queue1.size);
EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark before", 2, queue1.highWaterMark);
etMessage* rcvMsg1 = etMessageQueue_pop(&queue1);
etMessage* rcvMsg2 = etMessageQueue_pop(&queue1);
- EXPECT_EQUAL_INT16("etMessageQueue.size after", 0,(int32)queue1.size);
- EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark after", 2,queue1.highWaterMark);
+ EXPECT_EQUAL_INT16("etMessageQueue.size after", 0, queue1.size);
+ EXPECT_EQUAL_INT16("etMessageQueue.highWaterMark after", 2, queue1.highWaterMark);
EXPECT_EQUAL_INT16("rcvMsg1->address", 123, rcvMsg1->address);
EXPECT_EQUAL_INT16("rcvMsg1->evtID", 456, rcvMsg1->evtID);
@@ -55,8 +55,6 @@ void TestEtMessageQueue_testPushPop(void){
void TestEtMessageQueue_testMassiveMessaging(void){
etMessage msgArray[MAX];
- printf("sizeof(etMessage):%d\n", sizeof(etMessage));
- printf("size(msgArray):%d\n", sizeof(msgArray));
etMessageQueue queue1;
etMessageQueue_init(&queue1);
@@ -94,7 +92,7 @@ void TestEtMessageQueue_testMassiveMessaging(void){
}
void TestEtMessageQueue_runSuite(void){
- etUnit_openTestSuite("TestetMessageQueue");
+ etUnit_openTestSuite("TestEtMessageQueue");
ADD_TESTCASE(TestEtMessageQueue_testPushPop);
ADD_TESTCASE(TestEtMessageQueue_testMassiveMessaging);
etUnit_closeTestSuite();
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.c b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.c
new file mode 100644
index 000000000..3f01d0587
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.c
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+/*
+ * TestEtUnit.c
+ *
+ * Created on: 16.01.2012
+ * Author: tschuetz
+ */
+
+#include "TestEtUnit.h"
+#include "etUnit.h"
+
+void TestEtUnit_Expect(void){
+ EXPECT_TRUE("EXPECT_TRUE", TRUE);
+ EXPECT_FALSE("EXPECT_FALSE", FALSE);
+
+ /* signed integer values */
+ EXPECT_EQUAL_INT8("EXPECT_EQUAL_INT8", -123, -123);
+ EXPECT_EQUAL_INT16("EXPECT_EQUAL_INT16", -12345, -12345);
+ EXPECT_EQUAL_INT32("EXPECT_EQUAL_INT32", -1234567, -1234567);
+
+ /* unsigned integer values */
+ EXPECT_EQUAL_UINT8("EXPECT_EQUAL_INT8", 123, 123);
+ EXPECT_EQUAL_UINT16("EXPECT_EQUAL_INT16", 12345, 12345);
+ EXPECT_EQUAL_UINT32("EXPECT_EQUAL_INT32", 1234567, 1234567);
+
+ /* float values */
+ EXPECT_EQUAL_FLOAT32("EXPECT_EQUAL_FLOAT32", (etFloat32) 123.456, (etFloat32) 123.456, (etFloat32) 0.0001);
+ EXPECT_EQUAL_FLOAT64("EXPECT_EQUAL_FLOAT64", (etFloat64) 123.456, (etFloat64) 123.456, (etFloat64) 0.0001);
+
+ /* Pointers */
+ etUInt16 value;
+ etUInt16* valuePtr = &value;
+
+ EXPECT_EQUAL_PTR("EXPECT_EQUAL_PTR", &value, valuePtr) \
+
+}
+
+
+void TestEtUnit_Expect_Order(void){
+ etInt16 list[] = {1,2,3,4};
+ EXPECT_ORDER_START(list, 4);
+ EXPECT_ORDER("id=1", 1);
+ EXPECT_ORDER("id=2", 2);
+ EXPECT_ORDER("id=3", 3);
+ EXPECT_ORDER_END("id=4", 4);
+}
+
+void TestEtUnit_runSuite(void){
+ etUnit_openTestSuite("TestEtUnit");
+ ADD_TESTCASE(TestEtUnit_Expect_Order);
+ ADD_TESTCASE(TestEtUnit_Expect);
+ etUnit_closeTestSuite();
+}
+
+
diff --git a/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.h b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.h
new file mode 100644
index 000000000..e591d27ef
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/src/test/runtime/TestEtUnit.h
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+
+/*
+ * TestEtUnit.h
+ *
+ * Created on: 16.01.2012
+ * Author: tschuetz
+ */
+
+#ifndef _TESTETUNIT_H_
+#define _TESTETUNIT_H_
+
+void TestEtUnit_runSuite(void);
+
+#endif /* _TESTETUNIT_H_ */
diff --git a/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestCGenerator.xml b/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestCGenerator.xml
new file mode 100644
index 000000000..160ccd2bf
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestCGenerator.xml
@@ -0,0 +1,6 @@
+<testsuites name="TestCGenerator" tests="0" failures="0" errors="0" time="0">
+ <testsuite name="TestDataClass" tests="0" failures="0" errors="0" time="0">
+ <testcase name="TestDataClass_Operations" time="0"/>
+ <testcase name="TestDataClass_testDataClassDeepCopy" time="0"/>
+ </testsuite>
+</testsuites>
diff --git a/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestMessageService.xml b/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestCRuntime.xml
index 0a2578004..a5a4ad3d9 100644
--- a/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestMessageService.xml
+++ b/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestCRuntime.xml
@@ -1,12 +1,8 @@
-<testsuites name="TestMessageService" tests="0" failures="0" errors="0" time="0">
- <testsuite name="TestDataClass" tests="0" failures="0" errors="0" time="0">
- <testcase name="TestDataClass_Operations" time="0"/>
- <testcase name="TestDataClass_testDataClassDeepCopy" time="0"/>
- </testsuite>
+<testsuites name="TestCRuntime" tests="0" failures="0" errors="0" time="0">
<testsuite name="TestMessage" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtMessage_testBasicMessage" time="0"/>
</testsuite>
- <testsuite name="TestetMessageQueue" tests="0" failures="0" errors="0" time="0">
+ <testsuite name="TestEtMessageQueue" tests="0" failures="0" errors="0" time="0">
<testcase name="TestEtMessageQueue_testPushPop" time="0"/>
<testcase name="TestEtMessageQueue_testMassiveMessaging" time="0"/>
</testsuite>
@@ -15,4 +11,8 @@
<testcase name="TestEtMessageService_GetPushPopReturn" time="0"/>
<testcase name="TestEtMessageService_GetReturn" time="0"/>
</testsuite>
+ <testsuite name="TestEtUnit" tests="0" failures="0" errors="0" time="0">
+ <testcase name="TestEtUnit_Expect_Order" time="0"/>
+ <testcase name="TestEtUnit_Expect" time="0"/>
+ </testsuite>
</testsuites>
diff --git a/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestEtUnitSpecial.xml b/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestEtUnitSpecial.xml
new file mode 100644
index 000000000..f319d0648
--- /dev/null
+++ b/examples/org.eclipse.etrice.generator.c.reference/tmp/testlog/TestEtUnitSpecial.xml
@@ -0,0 +1,5 @@
+<testsuites name="TestEtUnitSpecial" tests="0" failures="0" errors="0" time="0">
+ <testsuite name="etUnit" tests="0" failures="0" errors="0" time="0">
+ <testcase name="openAll and closeAll" time="0"/>
+ </testsuite>
+</testsuites>
diff --git a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
index 6d43fcbb1..2def3aaec 100644
--- a/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
+++ b/runtime/org.eclipse.etrice.runtime.c/Debug/liborg.eclipse.etrice.runtime.c.a
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.c/Release/liborg.eclipse.etrice.runtime.c.a b/runtime/org.eclipse.etrice.runtime.c/Release/liborg.eclipse.etrice.runtime.c.a
deleted file mode 100644
index 89c30a148..000000000
--- a/runtime/org.eclipse.etrice.runtime.c/Release/liborg.eclipse.etrice.runtime.c.a
+++ /dev/null
Binary files differ
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
index e2622cbdf..f1edfa670 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etDatatypes.h
@@ -18,6 +18,8 @@
*
* */
+#include <stdio.h>
+
/* unsigned integer datatypes */
typedef unsigned char uint8;
typedef unsigned short int uint16;
@@ -45,11 +47,11 @@ typedef char boolean; /* TODO: bool, Bool, Boolean, and boolean are already def
#endif
/*
- * typedefs for Runtime and Testing
+ * typedefs for eTrice Runtime and Testing
*
* */
-typedef uint8 etInt8;
+typedef int8 etInt8;
typedef int16 etInt16;
typedef int32 etInt32;
@@ -62,4 +64,6 @@ typedef boolean etBool;
typedef float32 etFloat32;
typedef float64 etFloat64;
+typedef FILE* etFileHandle;
+
#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etLogger.c b/runtime/org.eclipse.etrice.runtime.c/src/etLogger.c
new file mode 100644
index 000000000..bbba4a628
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etLogger.c
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+/*
+ * etLogger.c
+ *
+ * Created on: 16.01.2012
+ * Author: tschuetz
+ */
+
+
+#include "etLogger.h"
+
+#include <stdarg.h>
+
+
+void etLogger_logError(const char* message){
+ printf("ERROR: %s", message);
+ printf("\n");
+}
+
+void etLogger_logWarning(const char* message){
+ printf("WARNING: %s", message);
+ printf("\n");
+}
+
+void etLogger_logInfo(const char* message){
+ printf("INFO: %s", message);
+ printf("\n");
+}
+
+void etLogger_logErrorF(const char* format, ... ){
+ printf("ERROR: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+}
+
+void etLogger_logWarningF(const char* format, ... ){
+ printf("WARNING: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+}
+
+void etLogger_logInfoF(const char* format, ... ){
+ printf("INFO: ");
+ va_list arglist;
+ va_start( arglist, format );
+ vprintf( format, arglist );
+ va_end( arglist );
+ printf("\n");
+}
+
+etFileHandle etLogger_fopen(const char* filename, const char* mode){
+ return( fopen(filename, mode) );
+}
+
+int etLogger_fclose(etFileHandle file){
+ return( fclose(file) );
+}
+
+void etLogger_fprintf(etFileHandle file, const char* format, ... ){
+ va_list arglist;
+ va_start( arglist, format );
+ vfprintf(file, format, arglist );
+ va_end( arglist );
+
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/etLogger.h
new file mode 100644
index 000000000..b353e6f1a
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etLogger.h
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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:
+ * Thomas Schuetz (initial contribution)
+ *
+ *******************************************************************************/
+
+/*
+ * etLogger.h
+ *
+ * Created on: 16.01.2012
+ * Author: tschuetz
+ */
+
+#ifndef _ETLOGGER_H_
+#define _ETLOGGER_H_
+
+#include <stdio.h>
+#include "etDatatypes.h"
+/* logging */
+
+void etLogger_logError(const char* message);
+
+void etLogger_logWarning(const char* message);
+
+void etLogger_logInfo(const char* message);
+
+void etLogger_logErrorF(const char* format, ... );
+
+void etLogger_logWarningF(const char* format, ... );
+
+void etLogger_logInfoF(const char* format, ... );
+
+
+/* File handling */
+
+etFileHandle etLogger_fopen(const char* filename, const char* mode);
+
+int etLogger_fclose(etFileHandle file);
+
+void etLogger_fprintf(etFileHandle file, const char* format, ... );
+
+#endif /* _ETLOGGER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.c b/runtime/org.eclipse.etrice.runtime.c/src/etUnit.c
index 3fc5e70b6..30460e278 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etUnit.c
@@ -12,6 +12,9 @@
#include "etUnit.h"
#include <string.h>
+#include <time.h>
+#include "etLogger.h"
+
/*** member variables */
@@ -28,6 +31,8 @@ static char* etUnit_TestCaseName = NULL;
/* counters */
static etInt32 etUnit_passCount = 0;
static etInt32 etUnit_failCount = 0;
+static etInt32 etUnit_passCountTotal = 0;
+static etInt32 etUnit_failCountTotal = 0;
static etBool etUnit_testcaseSuccess = TRUE;
@@ -39,12 +44,10 @@ static char etUnit_failureText[ETUNIT_FAILURE_TEXT_LEN];
static clock_t etUnit_startTime = 0;
static clock_t etUnit_currentTime = 0;
-/* */
-
/* forward declarations of private functions */
void expect_equal_int(const char* message, etInt32 expected, etInt32 actual);
void expect_equal_uint(const char* message, etUInt32 expected, etUInt32 actual);
-void expect_equal_float(const char* message, float64 expected, float64 actual, float64 precision);
+void expect_equal_float(const char* message, etFloat64 expected, etFloat64 actual, etFloat64 precision);
void etUnit_writeTestLog(const char *testcase, etBool result, const char *resulttext);
void etUnit_handleExpect(etBool result, const char *resulttext);
@@ -58,44 +61,49 @@ void etUnit_open(char* testResultPath, char* testFileName) {
etUnit_TestFileName = testFileName;
etUnit_TestResultPath = testResultPath;
- printf("************* TEST START (%s) **************\n", etUnit_TestFileName);
+ etLogger_logInfoF("************* TEST START (%s) **************", etUnit_TestFileName);
char filename[ETUNIT_FAILURE_TEXT_LEN];
sprintf(filename, "%s/%s.xml", etUnit_TestResultPath, etUnit_TestFileName);
if (etUnit_reportfile == NULL) {
- etUnit_reportfile = fopen(filename, "w+");
+ etUnit_reportfile = etLogger_fopen(filename, "w+");
if (etUnit_reportfile != NULL) {
- fprintf(etUnit_reportfile, "<testsuites name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n",
- etUnit_TestFileName);
+ etLogger_fprintf(etUnit_reportfile, "<testsuites name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n", etUnit_TestFileName);
} else {
- printf("Unable to open file %s/%s.xml\n", etUnit_TestResultPath, etUnit_TestFileName);
+ etLogger_logErrorF("Unable to open file %s/%s.xml", etUnit_TestResultPath, etUnit_TestFileName);
}
}
// prepare time measurement
etUnit_startTime = clock();
etUnit_currentTime = clock();
- printf("Start Time: %ld\n", etUnit_startTime);
+ etLogger_logInfoF("Start Time: %ld", etUnit_startTime);
}
void etUnit_close(void) {
- printf("\n");
+ etLogger_logInfoF("");
if (etUnit_failCount > 0) {
- printf("************* TEST FAILED *************\n");
+ etLogger_logInfoF("************* TEST FAILED *************");
+ } else {
+ etLogger_logInfoF("************* TEST PASSED *************");
+ }
+ etLogger_logInfoF("Number of Tests: %ld", etUnit_failCount + etUnit_passCount);
+ etLogger_logInfoF("Failed: %ld", etUnit_failCount);
+ etLogger_logInfoF("Passed: %ld", etUnit_passCount);
+ etLogger_logInfoF("Time: %ld", clock() - etUnit_startTime);
+ etLogger_logInfoF("End Time: %ld[ms]", (clock() / 1000) * CLOCKS_PER_SEC );
+ etLogger_logInfoF("***************************************");
+ if (etUnit_failCountTotal > 0) {
+ etLogger_logInfoF(" ******* %d TEST(S) FAILED *****", etUnit_failCountTotal);
} else {
- printf("************* TEST PASSED *************\n");
+ etLogger_logInfoF(" ******* ALL TESTS PASSED ******");
}
- printf("Number of Tests: %ld\n", etUnit_failCount + etUnit_passCount);
- printf("Failed: %ld\n", etUnit_failCount);
- printf("Passed: %ld\n", etUnit_passCount);
- printf("Total Time: %ld\n", clock() - etUnit_startTime);
- printf("End Time: %ld, CLOCKS_PER_SEC: %ld\n", clock(), CLOCKS_PER_SEC);
- printf("***************************************\n");
+ etLogger_logInfoF("***************************************");
if (etUnit_reportfile != NULL) {
- fprintf(etUnit_reportfile, "</testsuites>\n");
- fclose(etUnit_reportfile);
+ etLogger_fprintf(etUnit_reportfile, "</testsuites>\n");
+ etLogger_fclose(etUnit_reportfile);
etUnit_reportfile = NULL;
}
}
@@ -103,14 +111,14 @@ void etUnit_close(void) {
void etUnit_openTestSuite(char* testSuiteName) {
etUnit_TestSuiteName = testSuiteName;
if (etUnit_reportfile != NULL) {
- fprintf(etUnit_reportfile, "\t<testsuite name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n",
+ etLogger_fprintf(etUnit_reportfile, "\t<testsuite name=\"%s\" tests=\"0\" failures=\"0\" errors=\"0\" time=\"0\">\n",
etUnit_TestSuiteName);
}
}
void etUnit_closeTestSuite(void) {
if (etUnit_reportfile != NULL) {
- fprintf(etUnit_reportfile, "\t</testsuite>\n");
+ etLogger_fprintf(etUnit_reportfile, "\t</testsuite>\n");
}
}
@@ -126,6 +134,18 @@ void etUnit_closeTestCase(void) {
}
}
+void etUnit_openAll(char* testResultPath, char* testFileName, char* testSuiteName, char* testCaseName){
+ etUnit_open(testResultPath, testFileName);
+ etUnit_openTestSuite(testSuiteName);
+ etUnit_openTestCase(testCaseName);
+}
+
+void etUnit_closeAll(void){
+ etUnit_closeTestCase();
+ etUnit_closeTestSuite();
+ etUnit_close();
+}
+
void EXPECT_TRUE(const char* message, etBool condition) {
if (condition == FALSE) {
char testresult[ETUNIT_FAILURE_TEXT_LEN];
@@ -171,14 +191,53 @@ void EXPECT_EQUAL_UINT32(const char* message, etUInt32 expected, etUInt32 actual
}
-void EXPECT_EQUAL_FLOAT32(const char* message, float32 expected, float32 actual, float32 precision) {
- expect_equal_float(message, (float64) expected, (float64) actual, (float64) precision);
+void EXPECT_EQUAL_FLOAT32(const char* message, etFloat32 expected, etFloat32 actual, etFloat32 precision) {
+ expect_equal_float(message, (etFloat64) expected, (etFloat64) actual, (etFloat64) precision);
+}
+
+void EXPECT_EQUAL_FLOAT64(const char* message, etFloat64 expected, etFloat64 actual, etFloat64 precision) {
+ expect_equal_float(message, (etFloat64) expected, (etFloat64) actual, (etFloat64) precision);
+}
+
+/* order */
+static etInt16 etUnit_orderCurrentIndex = 0;
+static etInt16 etUnit_orderSize = 0;
+static etInt16* etUnit_orderList = NULL;
+
+void EXPECT_ORDER_START(etInt16* list, etInt16 size){
+ etUnit_orderCurrentIndex = 0;
+ etUnit_orderSize = size;
+ etUnit_orderList = list;
}
-void EXPECT_EQUAL_FLOAT64(const char* message, float64 expected, float64 actual, float64 precision) {
- expect_equal_float(message, (float64) expected, (float64) actual, (float64) precision);
+void EXPECT_ORDER(const char* message, etInt16 identifier){
+ if (etUnit_orderCurrentIndex < etUnit_orderSize) {
+ if (etUnit_orderList[etUnit_orderCurrentIndex] != identifier){
+ char testresult[ETUNIT_FAILURE_TEXT_LEN];
+ sprintf(testresult, "EXPECT_ORDER %s: index=%d, expected=%d, actual=%d", message, etUnit_orderCurrentIndex, identifier, etUnit_orderList[etUnit_orderCurrentIndex]);
+ etUnit_handleExpect(FALSE, testresult);
+ }
+ else {
+ etUnit_handleExpect(TRUE, "");
+ etUnit_orderCurrentIndex++;
+ }
+ }
+ else {
+ char testresult[ETUNIT_FAILURE_TEXT_LEN];
+ sprintf(testresult, "EXPECT_ORDER: index(%d) is too big in %s", etUnit_orderCurrentIndex, message);
+ etUnit_handleExpect(FALSE, testresult);
+ etLogger_logInfoF("EXPECT_ORDER: index too big in %s", message);
+ }
}
+void EXPECT_ORDER_END(const char* message, etInt16 identifier){
+ EXPECT_ORDER(message, identifier);
+ if (etUnit_orderCurrentIndex != etUnit_orderSize){
+ char testresult[ETUNIT_FAILURE_TEXT_LEN];
+ sprintf(testresult, "EXPECT_ORDER_END %s: wrong index at the end: expected=%d, actual=%d", message, etUnit_orderSize, etUnit_orderCurrentIndex);
+ etUnit_handleExpect(FALSE, testresult);
+ }
+}
/* private functions */
@@ -203,7 +262,7 @@ void expect_equal_uint(const char* message, etUInt32 expected, etUInt32 actual)
}
-void expect_equal_float(const char* message, float64 expected, float64 actual, float64 precision) {
+void expect_equal_float(const char* message, etFloat64 expected, etFloat64 actual, etFloat64 precision) {
if (expected - actual < -precision || expected - actual > precision) {
char testresult[ETUNIT_FAILURE_TEXT_LEN];
sprintf(testresult, "%s: expected=%lf, actual=%lf", message, expected, actual);
@@ -259,10 +318,12 @@ void etUnit_writeTestLog(const char *testcase, etBool result, const char *result
// counting
if (result == TRUE) {
etUnit_passCount++;
- printf("PASS: %s: %s\n", testcase, resulttext);
+ etUnit_passCountTotal++;
+ etLogger_logInfoF("PASS: %s %s", testcase, resulttext);
} else {
etUnit_failCount++;
- printf("FAIL: %s: %s\n", testcase, resulttext);
+ etUnit_failCountTotal++;
+ etLogger_logInfoF("FAIL: %s : %s", testcase, resulttext);
}
clock_t time = clock() - etUnit_currentTime;
@@ -271,7 +332,7 @@ void etUnit_writeTestLog(const char *testcase, etBool result, const char *result
// writing to file
if (etUnit_reportfile != NULL) {
etUnit_buildTestLogXML(writeBuffer, testcase, result, resulttext, time);
- fprintf(etUnit_reportfile, writeBuffer);
+ etLogger_fprintf(etUnit_reportfile, writeBuffer);
}
}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.h b/runtime/org.eclipse.etrice.runtime.c/src/etUnit.h
index e98615c5c..dcaa28306 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/etUnit.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/etUnit.h
@@ -14,11 +14,9 @@
#define _ETUNIT_H_
#include "etDatatypes.h"
-#include <stdio.h>
-#include <time.h>
-// open / close
+/* open / close */
void etUnit_open(char* testResultPath, char* testFileName);
void etUnit_close(void);
void etUnit_openTestSuite(char* testSuiteName);
@@ -26,6 +24,11 @@ void etUnit_closeTestSuite(void);
void etUnit_openTestCase(char* testCaseName);
void etUnit_closeTestCase(void);
+/* functions for more convenience for model and generator tests */
+
+void etUnit_openAll(char* testResultPath, char* testFileName, char* testSuiteName, char* testCaseName);
+void etUnit_closeAll(void);
+
/* boolean values */
void EXPECT_TRUE(const char* testcase, etBool condition);
void EXPECT_FALSE(const char* testcase, etBool condition);
@@ -50,6 +53,12 @@ void EXPECT_EQUAL_FLOAT64(const char* testcase, etFloat64 expected, etFloat64 ac
void expect_equal_void_ptr(const char* testcase, const void* expected, const void* actual);
+/* more specialized functions */
+void EXPECT_ORDER_START(etInt16* list, etInt16 size);
+void EXPECT_ORDER(const char* message, etInt16 identifier);
+void EXPECT_ORDER_END(const char* message, etInt16 identifier);
+
+
/* Helpers for adding testcases */
#define ADD_TESTCASE(testcase) \

Back to the top