Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/.cproject11
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtTimer.c62
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestCRuntime.etu12
-rw-r--r--tests/org.eclipse.etrice.runtime.c.tests/tmp/testlog/TestEtUnitSpecial.etu4
4 files changed, 67 insertions, 22 deletions
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/.cproject b/tests/org.eclipse.etrice.runtime.c.tests/.cproject
index e456f50a9..5f4951153 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/.cproject
+++ b/tests/org.eclipse.etrice.runtime.c.tests/.cproject
@@ -18,7 +18,7 @@
<folderInfo id="cdt.managedbuild.config.gnu.mingw.exe.debug.1638834921." name="/" resourcePath="">
<toolChain id="cdt.managedbuild.toolchain.gnu.mingw.exe.debug.26197628" name="MinGW GCC" superClass="cdt.managedbuild.toolchain.gnu.mingw.exe.debug">
<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"/>
+ <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" parallelBuildOn="false" 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" 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;"/>
@@ -123,6 +123,13 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
</scannerConfigBuildInfo>
</storageModule>
- <storageModule moduleId="refreshScope"/>
+ <storageModule moduleId="refreshScope" versionNumber="2">
+ <configuration configurationName="Release">
+ <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.runtime.c.tests"/>
+ </configuration>
+ <configuration configurationName="Debug">
+ <resource resourceType="PROJECT" workspacePath="/org.eclipse.etrice.runtime.c.tests"/>
+ </configuration>
+ </storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
</cproject>
diff --git a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtTimer.c b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtTimer.c
index 328d1318b..1a54fd3e6 100644
--- a/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtTimer.c
+++ b/tests/org.eclipse.etrice.runtime.c.tests/src/runtime/TestEtTimer.c
@@ -17,18 +17,20 @@
#include "etDatatypes.h"
#include "osal/etTimer.h"
+#include "osal/etThread.h"
#include "osal/etSema.h"
#include "helpers/etTimeHelpers.h"
etSema GlobalSema;
+etInt32 counter;
+etTimerFunction_RETURN_VALUE TestEtTimer_TimerCallback1(etTimerFunction_ARGUMENT_LIST){
+ etSema_wakeup(&GlobalSema);
+}
-VOID CALLBACK TestEtTimer_TimerCallback(HWND arg1, UINT arg2, UINT arg3, DWORD arg4){
-//etTimerFunction_RETURN_VALUE TestEtTimer_TimerCallback(etTimerFunction_ARGUMENT_LIST){
- //etSema_wakeup(&GlobalSema);
- int i=5;
- printf("\nTestEtTimer_TimerCallback: tick: %d", i);
+etTimerFunction_RETURN_VALUE TestEtTimer_TimerCallback2(etTimerFunction_ARGUMENT_LIST){
+ counter++;
}
static void TestEtTimer_lifecycle (etInt16 id) {
@@ -40,29 +42,63 @@ static void TestEtTimer_lifecycle (etInt16 id) {
/* create semaphore */
etSema_construct(&GlobalSema);
/* create and start timer */
- interval.sec = 0; /* = 1000 milliseconds */
+ interval.sec = 1; /* = 1000 milliseconds */
interval.nSec = 500000000; /* = 50 milliseconds */
- etTimer_construct(&timer1, &interval, TestEtTimer_TimerCallback);
- etTimer_start(&timer1);
-
+ etTimer_construct(&timer1, &interval, TestEtTimer_TimerCallback1);
getTimeFromTarget(&startTime);
- etThread_sleep(5000);
- //etSema_waitForWakeup(&GlobalSema); /* wait until callback function releases timer */
+ etTimer_start(&timer1);
+ etSema_waitForWakeup(&GlobalSema); /* wait until callback function releases timer the first time (fires immediately) */
+ etSema_waitForWakeup(&GlobalSema); /* wait until callback function releases timer the second time (fires after first interval)*/
etTimer_stop(&timer1);
getTimeFromTarget(&endTime);
-
- printf("\nelapsed time: %ld\n", etTimeHelpers_convertToMSec(&endTime) - etTimeHelpers_convertToMSec(&startTime));
+ etInt32 elapsed = etTimeHelpers_convertToMSec(&endTime) - etTimeHelpers_convertToMSec(&startTime);
+ EXPECT_TRUE(id, "elapsed time wrong", (elapsed > 1400) && (elapsed < 1600));
/* release resources */
etTimer_destruct(&timer1);
etSema_destruct(&GlobalSema);
}
+static void TestEtTimer_multiTimer (etInt16 id) {
+ etTimer timer1;
+ etTimer timer2;
+ etTime interval;
+ counter = 0;
+
+
+ /* create semaphore */
+ etSema_construct(&GlobalSema);
+
+ interval.sec = 1; /* = 1000 milliseconds */
+ interval.nSec = 0; /* = 0 milliseconds */
+ etTimer_construct(&timer1, &interval, TestEtTimer_TimerCallback1);
+ interval.sec = 0; /* = 1000 milliseconds */
+ interval.nSec = 1000000; /* = 1 millisecond */
+ etTimer_construct(&timer2, &interval, TestEtTimer_TimerCallback2);
+
+ etTimer_start(&timer1);
+ etTimer_start(&timer2);
+
+ etSema_waitForWakeup(&GlobalSema); /* wait until callback function releases timer the first time (fires immediately) */
+ etSema_waitForWakeup(&GlobalSema); /* wait until callback function releases timer the second time (fires after first interval)*/
+
+
+ etTimer_stop(&timer2);
+ etTimer_stop(&timer1);
+
+ EXPECT_TRUE(id, "counter wrong", (counter > 950) && (counter < 1050));
+ etTimer_destruct(&timer2);
+ etTimer_destruct(&timer1);
+
+ etSema_destruct(&GlobalSema);
+
+}
void TestEtTimer_runSuite(void){
etUnit_openTestSuite("TestEtTimer");
ADD_TESTCASE(TestEtTimer_lifecycle);
+ ADD_TESTCASE(TestEtTimer_multiTimer);
etUnit_closeTestSuite();
}
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 86fa46b51..4bdbf94a6 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,12 +1,12 @@
etUnit report
ts start: TestQueue
tc start 1: TestEtQueue_test
-tc end 1: 19
+tc end 1: 0
ts start: TestMemory
tc start 2: TestEtMemory_testFixedSize
-tc end 2: 9
+tc end 2: 15
tc start 3: TestEtMemory_testFreeList
-tc end 3: 2
+tc end 3: 0
ts start: TestMessage
tc start 4: TestEtMessage_testBasicMessage
tc end 4: 0
@@ -14,7 +14,7 @@ ts start: TestEtMessageQueue
tc start 5: TestEtMessageQueue_testPushPop
tc end 5: 0
tc start 6: TestEtMessageQueue_testMassiveMessaging
-tc end 6: 9
+tc end 6: 0
ts start: TestEtUnit
tc start 7: TestEtUnit_Expect_Order
tc end 7: 0
@@ -22,4 +22,6 @@ tc start 8: TestEtUnit_Expect
tc end 8: 0
ts start: TestEtTimer
tc start 9: TestEtTimer_lifecycle
-tc end 9: 11142
+tc end 9: 1513
+tc start 10: TestEtTimer_multiTimer
+tc end 10: 1014
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 e8abf2c61..78f14cc25 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 10: openAll and closeAll
-tc end 10: 0
+tc start 11: openAll and closeAll
+tc end 11: 0

Back to the top