Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2015-07-21 15:33:52 +0000
committerJuergen Haug2015-07-31 10:02:07 +0000
commit33c71f0684c7483aa25428d765ebfb089a954a67 (patch)
tree103aa43a654afbe3fee105de51dff0ca19067c38 /tests/org.eclipse.etrice.runtime.c.tests
parenta988c716e9c73a44fc1db44a0ec1d779a60c2599 (diff)
downloadorg.eclipse.etrice-33c71f0684c7483aa25428d765ebfb089a954a67.tar.gz
org.eclipse.etrice-33c71f0684c7483aa25428d765ebfb089a954a67.tar.xz
org.eclipse.etrice-33c71f0684c7483aa25428d765ebfb089a954a67.zip
Bug 472908 - refactor etDatatypes.h
Diffstat (limited to 'tests/org.eclipse.etrice.runtime.c.tests')
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/make.xml27
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c10
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.c94
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.h20
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtUnit.c2
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/util/TestUtil.c11
6 files changed, 146 insertions, 18 deletions
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/make.xml b/tests/org.eclipse.etrice.runtime.c.tests/make.xml
index c31c499a0..7fe1b251c 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/make.xml
+++ b/tests/org.eclipse.etrice.runtime.c.tests/make.xml
@@ -15,7 +15,7 @@
<property name="runtime.path" value="../../runtime/org.eclipse.etrice.runtime.c"/>
<property name="bin.path" value="./bin"/>
- <property name="xml.output" value="./tmp"/>
+ <property name="xml.output" value="log"/>
<property name="output" value="./output"/>
<property environment="env"/>
@@ -31,43 +31,43 @@
set_tp: get the target.platform property from the environment var ETRICE_TARGET_PLATFORM if not set already
-->
<target name="set_tp" unless="target.platform">
- <echo>using local target platform</echo>
<property name="target.platform" value="${env.ETRICE_TARGET_PLATFORM}"/>
+ <echo>using local target platform (${target.platform})</echo>
</target>
<!--
set_tr: sets the test.result property if not set already
-->
<target name="set_tr" unless="test.results">
- <echo>using local test result folder</echo>
<property name="test.results" value="./results"/>
+ <echo>using local test result folder (${test.results})</echo>
</target>
<!--
set_platform: sets the runtime.platform property if not set already
-->
<target name="set_platform" unless="runtime.platform">
- <echo>using MinGW runtime platform</echo>
<!--
<property name="runtime.platform" value="MT_WIN_MinGW"/>
-->
<property name="runtime.platform" value="MT_POSIX_GENERIC_GCC"/>
+ <echo>using runtime platform ${runtime.platform}</echo>
</target>
<!--
set_rp: sets the runtime.path from the ETRICE_C_RUNTIME environment variable property if not set already
-->
<target name="set_rp" unless="c-runtime.path">
- <echo>using local runtime folder</echo>
<property name="c-runtime.path" value="${env.ETRICE_C_RUNTIME}"/>
+ <echo>using local runtime folder (${c-runtime.path})</echo>
</target>
<!--
set_gcc_path: sets the gcc.path property from the ETRICE_GCC_PATH environment variable property if not set already
-->
<target name="set_gcc_path" unless="gcc.path">
- <echo>using gcc from path</echo>
<property name="gcc.path" value="${env.ETRICE_GCC_PATH}"/>
+ <echo>using gcc from path (${gcc.path})</echo>
</target>
<!--
@@ -78,7 +78,7 @@
<delete dir="${c-runtime.path}/bin"/>
<delete dir="${output}"/>
<delete dir="src-gen"/>
- <delete dir="tmp"/>
+ <delete dir="log"/>
</target>
<!--
@@ -173,6 +173,7 @@
<arg value="../../src/runtime/TestEtMessageService.c"/>
<arg value="../../src/runtime/TestEtQueue.c"/>
<arg value="../../src/runtime/TestEtTimer.c"/>
+ <arg value="../../src/runtime/TestEtDatatypes.c"/>
<arg value="../../src/runtime/TestEtUnit.c"/>
<arg value="../../src/runtime/helpers/TestEtTimeHelpers.c"/>
<arg value="../../src/runtime/util/TestUtil.c"/>
@@ -188,6 +189,7 @@
<arg value="TestEtMessageService.o"/>
<arg value="TestEtQueue.o"/>
<arg value="TestEtTimer.o"/>
+ <arg value="TestEtDatatypes.o"/>
<arg value="TestEtUnit.o"/>
<arg value="TestEtTimeHelpers.o"/>
<arg value="TestUtil.o"/>
@@ -203,7 +205,8 @@
run: runs all executables
-->
<target name="run" depends="build">
- <mkdir dir="tmp/testlog"/>
+ <mkdir dir="log"/>
+ <mkdir dir="log/testlog"/>
<echo>start RuntimeTest</echo>
<exec dir="./" resolveexecutable="true" executable="./bin/test/RuntimeTest.exe" output="${output}/run.txt" />
<echo>end RuntimeTest</echo>
@@ -226,14 +229,14 @@
<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
<arg value="-suite"/>
<arg value="org.eclipse.etrice.runtime.c.tests.TestEtUnitSpecial"/>
- <arg value="./tmp/testlog/TestEtUnitSpecial.etu"/>
+ <arg value="./log/testlog/TestEtUnitSpecial.etu"/>
<classpath refid="clspath"/>
</java>
<java output="${output}/convert.txt" append="true" classname="org.eclipse.etrice.etunit.converter.EtUnitReportConverter" fork="true" failonerror="true">
<arg value="-suite"/>
<arg value="org.eclipse.etrice.runtime.c.tests.TestCRuntime"/>
- <arg value="./tmp/testlog/TestCRuntime.etu"/>
+ <arg value="./log/testlog/TestCRuntime.etu"/>
<classpath refid="clspath"/>
</java>
</target>
@@ -242,9 +245,9 @@
copy_results: copies the *.xml results to their final destination
-->
<target name="copy_results" depends="set_tr">
- <move file="./tmp/testlog/TestEtUnitSpecial.xml" tofile="./tmp/testlog/CTestEtUnitSpecial.xml"/>
+ <move file="./log/testlog/TestEtUnitSpecial.xml" tofile="./log/testlog/CTestEtUnitSpecial.xml"/>
<copy todir="${test.results}" >
- <fileset dir="./tmp/testlog">
+ <fileset dir="./log/testlog">
<include name="*.xml"/>
</fileset>
</copy>
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 87b09c3f5..0a932fb44 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
@@ -28,6 +28,7 @@
#include "TestEtMemory.h"
#include "TestEtQueue.h"
#include "TestEtTimer.h"
+#include "TestEtDatatypes.h"
#include "helpers/TestEtTimeHelpers.h"
#include "util/TestUtil.h"
@@ -37,9 +38,9 @@
void RunCRuntimeTestcases(void){
etInt16 id;
- etMSCLogger_open("tmp/testlog", "test.log");
- etUnit_open("tmp/testlog","TestCRuntime");
-
+ etMSCLogger_open("log/testlog", "test.log");
+ etUnit_open("log/testlog","TestCRuntime");
+
TestEtQueue_runSuite();
TestEtMemory_runSuite();
TestEtMessage_runSuite();
@@ -47,6 +48,7 @@ void RunCRuntimeTestcases(void){
TestEtMessageService_runSuite();
TestEtUnit_runSuite();
TestEtTimer_runSuite();
+ TestEtDatatypes_runSuite();
TestEtTimeHelpers_runSuite();
TestUtil_runSuite();
@@ -54,7 +56,7 @@ void RunCRuntimeTestcases(void){
/* special situation for testing openAll and closeAll of etUnit
* this has to be done outside of etUnit_open and etUnit_close */
- id = etUnit_openAll("tmp/testlog","TestEtUnitSpecial", "etUnit", "openAll and closeAll");
+ id = etUnit_openAll("log/testlog","TestEtUnitSpecial", "etUnit", "openAll and closeAll");
EXPECT_TRUE(id, "Open and Close", ET_TRUE);
etUnit_closeAll(id);
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.c
new file mode 100644
index 000000000..84cbb0ff9
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.c
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+#include "TestEtDatatypes.h"
+#include "etUnit/etUnit.h"
+
+void TestEtDatatypes_IntegerSize(etInt16 id) {
+ EXPECT_EQUAL_INT32(id, "", 1, sizeof(int8));
+ EXPECT_EQUAL_INT32(id, "", 1, sizeof(uint8));
+ EXPECT_EQUAL_INT32(id, "", 2, sizeof(int16));
+ EXPECT_EQUAL_INT32(id, "", 2, sizeof(uint16));
+ EXPECT_EQUAL_INT32(id, "", 4, sizeof(int32));
+ EXPECT_EQUAL_INT32(id, "", 4, sizeof(uint32));
+
+#ifdef ET_INT64
+ EXPECT_EQUAL_INT32(id, "", 8, sizeof(int64));
+ EXPECT_EQUAL_INT32(id, "", 8, sizeof(uint64));
+#endif
+
+ EXPECT_EQUAL_INT32(id, "", 1, sizeof(etInt8));
+ EXPECT_EQUAL_INT32(id, "", 1, sizeof(etUInt8));
+ EXPECT_EQUAL_INT32(id, "", 2, sizeof(etInt16));
+ EXPECT_EQUAL_INT32(id, "", 2, sizeof(etUInt16));
+ EXPECT_EQUAL_INT32(id, "", 4, sizeof(etInt32));
+ EXPECT_EQUAL_INT32(id, "", 4, sizeof(etUInt32));
+
+#ifdef ET_INT64
+ EXPECT_EQUAL_INT32(id, "", 8, sizeof(etInt64));
+ EXPECT_EQUAL_INT32(id, "", 8, sizeof(etUInt64));
+#endif
+}
+
+void TestEtDatatypes_IntegerSign(etInt16 id) {
+ EXPECT_TRUE(id, "", ((int8 )-1) < 0);
+ EXPECT_TRUE(id, "", ((uint8 )-1) >= 0);
+ EXPECT_TRUE(id, "", ((int16 )-1) < 0);
+ EXPECT_TRUE(id, "", ((uint16 )-1) >= 0);
+ EXPECT_TRUE(id, "", ((int32 )-1) < 0);
+ EXPECT_TRUE(id, "", ((uint32 )-1) >= 0);
+
+#ifdef ET_INT64
+ EXPECT_TRUE(id, "", ((int64 )-1) < 0);
+ EXPECT_TRUE(id, "", ((uint64 )-1) >= 0);
+#endif
+
+ EXPECT_TRUE(id, "", ((etInt8 )-1) < 0);
+ EXPECT_TRUE(id, "", ((etUInt8 )-1) >= 0);
+ EXPECT_TRUE(id, "", ((etInt16 )-1) < 0);
+ EXPECT_TRUE(id, "", ((etUInt16 )-1) >= 0);
+ EXPECT_TRUE(id, "", ((etInt32 )-1) < 0);
+ EXPECT_TRUE(id, "", ((etUInt32 )-1) >= 0);
+
+#ifdef ET_INT64
+ EXPECT_TRUE(id, "", ((etInt64 )-1) < 0);
+ EXPECT_TRUE(id, "", ((etUInt64 )-1) >= 0);
+#endif
+}
+
+void TestEtDatatypes_Boolean(etInt16 id) {
+ EXPECT_TRUE(id, "", (bool)1);
+ EXPECT_FALSE(id, "", (bool)0);
+
+ EXPECT_TRUE(id, "", (etBool )1);
+ EXPECT_FALSE(id, "", (etBool )0);
+}
+
+void TestEtDatatypes_FLOAT(etInt16 id) {
+#ifdef ET_FLOAT32
+ EXPECT_EQUAL_INT32(id, "", 4, sizeof(float32));
+ EXPECT_EQUAL_INT32(id, "", 4, sizeof(etFloat32));
+#endif
+#ifdef ET_FLOAT64
+ EXPECT_EQUAL_INT32(id, "", 8, sizeof(float64));
+ EXPECT_EQUAL_INT32(id, "", 8, sizeof(etFloat64));
+#endif
+}
+
+void TestEtDatatypes_runSuite(void) {
+ etUnit_openTestSuite("TestDatatypes");
+ ADD_TESTCASE(TestEtDatatypes_IntegerSize);
+ ADD_TESTCASE(TestEtDatatypes_IntegerSign);
+ ADD_TESTCASE(TestEtDatatypes_Boolean);
+ ADD_TESTCASE(TestEtDatatypes_FLOAT);
+ etUnit_closeTestSuite();
+}
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.h b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.h
new file mode 100644
index 000000000..abe06201a
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtDatatypes.h
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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:
+ * Juergen Haug (initial contribution)
+ *
+ *******************************************************************************/
+
+#ifndef _TESTETDATATYPES_H_
+#define _TESTETDATATYPES_H_
+
+#include "etDatatypes.h"
+
+void TestEtDatatypes_runSuite(void);
+
+#endif /* _TESTETDATATYPES_H_ */
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtUnit.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtUnit.c
index 34366ee5e..4bf2c137e 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtUnit.c
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtUnit.c
@@ -36,8 +36,10 @@ void TestEtUnit_Expect(etInt16 id){
EXPECT_EQUAL_UINT32(id, "EXPECT_EQUAL_INT32", 1234567, 1234567);
/* float values */
+#ifdef ET_FLOAT32
EXPECT_EQUAL_FLOAT32(id, "EXPECT_EQUAL_FLOAT32", (etFloat32) 123.456, (etFloat32) 123.456, (etFloat32) 0.0001);
EXPECT_EQUAL_FLOAT32(id, "EXPECT_EQUAL_FLOAT32", (etFloat32) 123.456, (etFloat32) 123.456, (etFloat32) 0.0001);
+#endif
/* Pointers */
etUInt16 value;
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/util/TestUtil.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/util/TestUtil.c
index 13d3fa251..da583e1de 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/util/TestUtil.c
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/util/TestUtil.c
@@ -16,6 +16,8 @@
#include "RandomGenerator.h"
+#ifdef ET_FLOAT64
+
static void TestRandomGenerator (etInt16 id) {
RandomGenerator rand;
int i;
@@ -28,7 +30,7 @@ static void TestRandomGenerator (etInt16 id) {
EXPECT_RANGE_FLOAT64(id, "random [-1,+1]", -1., +1., result); /* check for range */
sum += result;
}
- average = sum / (float64)i;
+ average = sum / (etFloat64)i;
EXPECT_RANGE_FLOAT64(id, "average [-1,+1]", -0.1, 0.1, average); /* check for quality */
sum = average = 0;
@@ -38,16 +40,21 @@ static void TestRandomGenerator (etInt16 id) {
EXPECT_RANGE_FLOAT64(id, "random [-500,+1000]", -500., +1000., result); /* check for range */
sum += result;
}
- average = sum / (float64)i;
+ average = sum / (etFloat64)i;
EXPECT_RANGE_FLOAT64(id, "average [-500,+1000]", 230., 270., average); /* check for quality */
}
+#endif
void TestUtil_runSuite(void){
etUnit_openTestSuite("TestUtil");
+
+#ifdef ET_FLOAT64
ADD_TESTCASE(TestRandomGenerator);
+#endif
+
etUnit_closeTestSuite();
}

Back to the top