summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schuetz2013-04-30 06:20:01 (EDT)
committer Thomas Schuetz2013-04-30 06:20:01 (EDT)
commit557eaf3819ee03755134775d16ce1a2951e74222 (patch)
tree51412ce0cdf159f18346e83a52a46cfc22394c1a
parentfe7515af364af304ab279f66225cc9567e157b10 (diff)
downloadorg.eclipse.etrice-557eaf3819ee03755134775d16ce1a2951e74222.zip
org.eclipse.etrice-557eaf3819ee03755134775d16ce1a2951e74222.tar.gz
org.eclipse.etrice-557eaf3819ee03755134775d16ce1a2951e74222.tar.bz2
[runtime.c.tests] added testcases for etTimeHelpers
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c47
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h45
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/RunCRuntimeTestcases.c2
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.c65
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.h19
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestCRuntime.etu11
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestEtUnitSpecial.etu4
7 files changed, 140 insertions, 53 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c
index 1aadc10..82ada31 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.c
@@ -1,25 +1,22 @@
-/*******************************************************************************
- * Copyright (c) 2013 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)
- *
- *******************************************************************************/
-
-#include "helpers/etTimeHelpers.h"
-
-void etTimeHelpers_subtract(etTime *first, etTime* second){
- /* TODO: implement */
-}
-
-void etTimeHelpers_add(etTime *first, etTime* second){
- /* TODO: implement */
-}
-
-etInt32 etTimeHelpers_convertToMSec(etTime *time){
- return time->sec * 1000 + time->nSec / 1000000;
-}
+/*******************************************************************************
+ * Copyright (c) 2013 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)
+ *
+ *******************************************************************************/
+
+#include "helpers/etTimeHelpers.h"
+
+etInt32 etTimeHelpers_convertToMSec(etTime *time){
+ return time->sec * 1000 + time->nSec / 1000000;
+}
+
+void etTimeHelpers_convertToEtTime(etTime *result, etInt32 milliSeconds){
+ result->sec = milliSeconds/1000;
+ result->nSec = milliSeconds%1000 * 1000000;
+}
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
index 71f20e4..c7aa1a4 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
@@ -1,23 +1,22 @@
-/*******************************************************************************
- * Copyright (c) 2013 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)
- *
- *******************************************************************************/
-
-#ifndef ETTIMEHELPERS_H_
-#define ETTIMEHELPERS_H_
-
-#include "osal/etTime.h"
-
-void etTime_subtract(etTime *self, etTime* subtractValue);
-void etTime_add(etTime *self, etTime* addValue);
-etInt32 etTimeHelpers_convertToMSec(etTime *time);
-
-
-#endif /* ETTIMEHELPERS_H_ */
+/*******************************************************************************
+ * Copyright (c) 2013 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)
+ *
+ *******************************************************************************/
+
+#ifndef _ETTIMEHELPERS_H_
+#define _ETTIMEHELPERS_H_
+
+#include "osal/etTime.h"
+
+etInt32 etTimeHelpers_convertToMSec(etTime *time);
+void etTimeHelpers_convertToEtTime(etTime *result, etInt32 milliSeconds);
+
+
+#endif /* _ETTIMEHELPERS_H_ */
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 1e6c72a..4ab86cb 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
@@ -29,6 +29,7 @@
#include "TestEtMemory.h"
#include "TestEtQueue.h"
#include "TestEtTimer.h"
+#include "helpers/TestEtTimeHelpers.h"
#include "etUnit/etUnit.h"
#include "debugging/etMSCLogger.h"
@@ -46,6 +47,7 @@ void RunCRuntimeTestcases(void){
// TestEtMessageService_runSuite();
TestEtUnit_runSuite();
TestEtTimer_runSuite();
+ TestEtTimeHelpers_runSuite();
etUnit_close();
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.c
new file mode 100644
index 0000000..1ff4425
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.c
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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)
+ *
+ *******************************************************************************/
+
+#include "TestEtTimeHelpers.h"
+#include "helpers/etTimeHelpers.h"
+
+#include "etUnit/etUnit.h"
+
+static void TestEtTimeHelpers_convertToMSec (etInt16 id) {
+ etInt32 result;
+ etTime time;
+
+ time.sec = 0;
+ time.nSec = 0;
+ result = etTimeHelpers_convertToMSec(&time);
+ EXPECT_EQUAL_INT32(id, "0 ms", 0, result);
+
+ time.sec = 1;
+ time.nSec = 1000000;
+ result = etTimeHelpers_convertToMSec(&time);
+ EXPECT_EQUAL_INT32(id, "1001 ms", 1001, result);
+
+ time.sec = 1111;
+ time.nSec = 55000000;
+ result = etTimeHelpers_convertToMSec(&time);
+ EXPECT_EQUAL_INT32(id, "111055 ms", 1111055, result);
+
+}
+
+static void TestEtTimeHelpers_convertToEtTime (etInt16 id) {
+ etInt32 ms_time;
+ etTime result;
+
+ ms_time=0;
+ etTimeHelpers_convertToEtTime(&result, ms_time);
+ EXPECT_EQUAL_INT32(id, "0 s", 0, result.sec);
+ EXPECT_EQUAL_INT32(id, "0 ns", 0, result.nSec);
+
+
+ ms_time=1234567;
+ etTimeHelpers_convertToEtTime(&result, ms_time);
+ EXPECT_EQUAL_INT32(id, "1234 s", 1234, result.sec);
+ EXPECT_EQUAL_INT32(id, "567000000 ns", 567000000, result.nSec);
+
+}
+
+
+
+void TestEtTimeHelpers_runSuite(void){
+ etUnit_openTestSuite("TestEtTimeHelpers");
+ ADD_TESTCASE(TestEtTimeHelpers_convertToMSec);
+ ADD_TESTCASE(TestEtTimeHelpers_convertToEtTime);
+ etUnit_closeTestSuite();
+}
+
+
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.h b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.h
new file mode 100644
index 0000000..8998883
--- /dev/null
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/helpers/TestEtTimeHelpers.h
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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)
+ *
+ *******************************************************************************/
+
+#ifndef _TESTETTIMEHELPERS_H_
+#define _TESTETTIMEHELPERS_H_
+
+void TestEtTimeHelpers_runSuite(void);
+
+
+#endif /* _TESTETTIMEHELPERS_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 4bdbf94..73347e1 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,10 +1,10 @@
etUnit report
ts start: TestQueue
tc start 1: TestEtQueue_test
-tc end 1: 0
+tc end 1: 15
ts start: TestMemory
tc start 2: TestEtMemory_testFixedSize
-tc end 2: 15
+tc end 2: 0
tc start 3: TestEtMemory_testFreeList
tc end 3: 0
ts start: TestMessage
@@ -14,7 +14,7 @@ ts start: TestEtMessageQueue
tc start 5: TestEtMessageQueue_testPushPop
tc end 5: 0
tc start 6: TestEtMessageQueue_testMassiveMessaging
-tc end 6: 0
+tc end 6: 16
ts start: TestEtUnit
tc start 7: TestEtUnit_Expect_Order
tc end 7: 0
@@ -25,3 +25,8 @@ tc start 9: TestEtTimer_lifecycle
tc end 9: 1513
tc start 10: TestEtTimer_multiTimer
tc end 10: 1014
+ts start: TestEtTimeHelpers
+tc start 11: TestEtTimeHelpers_convertToMSec
+tc end 11: 0
+tc start 12: TestEtTimeHelpers_convertToEtTime
+tc end 12: 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 78f14cc..71e5855 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 13: openAll and closeAll
+tc end 13: 0