Explorar o código

Added New Tests for Hierarchy, LocalActions, ParallelRegions and ShallowHistory

jos.itemis@gmail.com %!s(int64=13) %!d(string=hai) anos
pai
achega
a436e6cf25

+ 8 - 8
TestScenarios/GenModelJava.sgen

@@ -1,48 +1,48 @@
 GeneratorModel for yakindu::java {
 	statechart InterfaceTest {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}
 	}
 	statechart Test_DeepHistory {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}
 	}
 	statechart Test_Expression {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}
 	}
 	statechart Test_Hierarchy {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}
 	}
 	statechart Test_LocalActions {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}
 	}
 	statechart Test_ParallelRegions {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}
 	}
 	statechart Test_ShallowHistory {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}
 	}
 	statechart Test_Transition {
-		feature Outlet {
+		feature OutletFeature {
 			targetProject = "org.yakindu.sct.generator.java.runtime.test"
 			targetFolder = "src-gen"
 		}

+ 8 - 0
TestScenarios/test-c/Test_LocalActions/CMakeLists.txt

@@ -0,0 +1,8 @@
+include_directories(../../src-gen-c/Test_LocalActions)
+
+add_executable(TestLocalActionsMain main.c)
+target_link_libraries(TestLocalActionsMain Test_LocalActionsStatemachine)
+
+add_test(Dummy1 TestLocalActionsMain "1")
+add_test(Dummy2 TestLocalActionsMain "2")
+

+ 108 - 0
TestScenarios/test-c/Test_LocalActions/main.c

@@ -0,0 +1,108 @@
+/*
+ * main.c
+ *
+ *  Created on: 16.11.2011
+ *      Author: showcase
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include "Timer.h"
+#include "DummyTimer.h"
+#include "Test_LocalActionsStatemachine.h"
+
+/*@DTestSuite: LocalActions Statechart Test (Test_LocalActions.sct) */
+
+#define MAXEVENTSPERTYPE 4
+const char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
+
+void setupStatemachine(Test_LocalActionsStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	/* set up dummy Timer */
+	dummyTimer_init(dummyTimer);
+
+	/* Set up Event Pool */
+	eventPool_init_heap(eventPool, event_last, MAXEVENTSPERTYPE);
+
+	/* initialize state machine */
+	test_LocalActionsStatemachine_init(machine, dummyTimer, eventPool);
+
+}
+
+void teardownStatemachine(Test_LocalActionsStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	test_LocalActionsStatemachine_exit(machine);
+	timer_exit(dummyTimer);
+	eventPool_exit(eventPool);
+
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default interface */
+int test_initialization()
+{
+
+	return 0;
+}
+
+
+/*@Test: test_state9_state10_transition test behavior of var1 in default and other interface */
+int dummy1()
+{
+	Test_LocalActionsStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default and other interface */
+int dummy2()
+{
+	Test_LocalActionsStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: run an explicit cycle - without any waiting event (for initialization) */
+	test_LocalActionsStatemachine_runCycle(&machine);
+
+	/*@Desc:  */
+
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+
+
+
+
+
+int main(int argc, char** argv)
+{
+	if (argc != 2)
+		return -1;
+
+	switch (atoi(argv[1])) {
+	case 1:
+		return dummy1();
+	case 2:
+		return dummy2();
+	}
+
+	return -1;
+
+}

+ 8 - 0
TestScenarios/test-c/Test_ParallelRegions/CMakeLists.txt

@@ -0,0 +1,8 @@
+include_directories(../../src-gen-c/Test_ParallelRegions)
+
+add_executable(TestParallelRegionsMain main.c)
+target_link_libraries(TestParallelRegionsMain Test_ParallelRegionsStatemachine)
+
+add_test(Dummy1 TestParallelRegionsMain "1")
+add_test(Dummy2 TestParallelRegionsMain "2")
+

+ 108 - 0
TestScenarios/test-c/Test_ParallelRegions/main.c

@@ -0,0 +1,108 @@
+/*
+ * main.c
+ *
+ *  Created on: 16.11.2011
+ *      Author: showcase
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include "Timer.h"
+#include "DummyTimer.h"
+#include "Test_ParallelRegionsStatemachine.h"
+
+/*@DTestSuite: ParallelRegions Statechart Test (Test_ParallelRegions.sct) */
+
+#define MAXEVENTSPERTYPE 4
+const char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
+
+void setupStatemachine(Test_ParallelRegionsStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	/* set up dummy Timer */
+	dummyTimer_init(dummyTimer);
+
+	/* Set up Event Pool */
+	eventPool_init_heap(eventPool, event_last, MAXEVENTSPERTYPE);
+
+	/* initialize state machine */
+	test_ParallelRegionsStatemachine_init(machine, dummyTimer, eventPool);
+
+}
+
+void teardownStatemachine(Test_ParallelRegionsStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	test_ParallelRegionsStatemachine_exit(machine);
+	timer_exit(dummyTimer);
+	eventPool_exit(eventPool);
+
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default interface */
+int test_initialization()
+{
+
+	return 0;
+}
+
+
+/*@Test: test_state9_state10_transition test behavior of var1 in default and other interface */
+int dummy1()
+{
+	Test_ParallelRegionsStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default and other interface */
+int dummy2()
+{
+	Test_ParallelRegionsStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: run an explicit cycle - without any waiting event (for initialization) */
+	test_ParallelRegionsStatemachine_runCycle(&machine);
+
+	/*@Desc:  */
+
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+
+
+
+
+
+int main(int argc, char** argv)
+{
+	if (argc != 2)
+		return -1;
+
+	switch (atoi(argv[1])) {
+	case 1:
+		return dummy1();
+	case 2:
+		return dummy2();
+	}
+
+	return -1;
+
+}

+ 8 - 0
TestScenarios/test-c/Test_ShallowHistory/CMakeLists.txt

@@ -0,0 +1,8 @@
+include_directories(../../src-gen-c/Test_ShallowHistory)
+
+add_executable(TestShallowHistoryMain main.c)
+target_link_libraries(TestShallowHistoryMain Test_ShallowHistoryStatemachine)
+
+add_test(Dummy1 TestShallowHistoryMain "1")
+add_test(Dummy2 TestShallowHistoryMain "2")
+

+ 108 - 0
TestScenarios/test-c/Test_ShallowHistory/main.c

@@ -0,0 +1,108 @@
+/*
+ * main.c
+ *
+ *  Created on: 16.11.2011
+ *      Author: showcase
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include "Timer.h"
+#include "DummyTimer.h"
+#include "Test_ShallowHistoryStatemachine.h"
+
+/*@DTestSuite: ShallowHistory Statechart Test (Test_ShallowHistory.sct) */
+
+#define MAXEVENTSPERTYPE 4
+const char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
+
+void setupStatemachine(Test_ShallowHistoryStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	/* set up dummy Timer */
+	dummyTimer_init(dummyTimer);
+
+	/* Set up Event Pool */
+	eventPool_init_heap(eventPool, event_last, MAXEVENTSPERTYPE);
+
+	/* initialize state machine */
+	test_ShallowHistoryStatemachine_init(machine, dummyTimer, eventPool);
+
+}
+
+void teardownStatemachine(Test_ShallowHistoryStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	test_ShallowHistoryStatemachine_exit(machine);
+	timer_exit(dummyTimer);
+	eventPool_exit(eventPool);
+
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default interface */
+int test_initialization()
+{
+
+	return 0;
+}
+
+
+/*@Test: test_state9_state10_transition test behavior of var1 in default and other interface */
+int dummy1()
+{
+	Test_ShallowHistoryStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default and other interface */
+int dummy2()
+{
+	Test_ShallowHistoryStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: run an explicit cycle - without any waiting event (for initialization) */
+	test_ShallowHistoryStatemachine_runCycle(&machine);
+
+	/*@Desc:  */
+
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+
+
+
+
+
+int main(int argc, char** argv)
+{
+	if (argc != 2)
+		return -1;
+
+	switch (atoi(argv[1])) {
+	case 1:
+		return dummy1();
+	case 2:
+		return dummy2();
+	}
+
+	return -1;
+
+}

+ 8 - 0
TestScenarios/test-c/Test_Transition/CMakeLists.txt

@@ -0,0 +1,8 @@
+include_directories(../../src-gen-c/Test_Transition)
+
+add_executable(TestTransitionMain main.c)
+target_link_libraries(TestTransitionMain Test_TransitionStatemachine)
+
+add_test(Dummy1 TestTransitionMain "1")
+add_test(Dummy2 TestTransitionMain "2")
+

+ 115 - 0
TestScenarios/test-c/Test_Transition/main.c

@@ -0,0 +1,115 @@
+/*
+ * main.c
+ *
+ *  Created on: 16.11.2011
+ *      Author: showcase
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include "Timer.h"
+#include "DummyTimer.h"
+#include "Test_HierarchyStatemachine.h"
+
+/*@DTestSuite: Hierachy Statechart Test (Test_Hierarchy.sct) */
+
+#define MAXEVENTSPERTYPE 4
+const char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
+
+void setupStatemachine(Test_HierarchyStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	/* set up dummy Timer */
+	dummyTimer_init(dummyTimer);
+
+	/* Set up Event Pool */
+	eventPool_init_heap(eventPool, event_last, MAXEVENTSPERTYPE);
+
+	/* initialize state machine */
+	test_HierarchyStatemachine_init(machine, dummyTimer, eventPool);
+
+}
+
+void teardownStatemachine(Test_HierarchyStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
+{
+	test_HierarchyStatemachine_exit(machine);
+	timer_exit(dummyTimer);
+	eventPool_exit(eventPool);
+
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default interface */
+int test_initialization()
+{
+
+	return 0;
+}
+
+
+/*@Test: test_state9_state10_transition test behavior of var1 in default and other interface */
+int test_state9_state10_transition()
+{
+	Test_HierarchyStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: run the statechart for the first time (initially) */
+	test_HierarchyStatemachine_runCycle(&machine);
+
+	/*@Desc: check wether state is initial state (State9) */
+	printf("%s\n", stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)]);
+	assert( strcmp(stateName[statemachineBase_getState((StatemachineBase*)&machine, 0)], "State9") == 0);
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+/*@Test: test_default_var1 test behavior of var1 in default and other interface */
+int test_state1_state2_back_transition()
+{
+	Test_HierarchyStatemachine machine;
+	Timer dummyTimer;
+	EventPool eventPool;
+
+	/*@Desc: setup initial statemachine */
+	setupStatemachine(&machine, &dummyTimer, &eventPool);
+
+	/*@Desc: run an explicit cycle - without any waiting event (for initialization) */
+	test_HierarchyStatemachine_runCycle(&machine);
+
+	/*@Desc:  */
+
+
+	/*@Desc: teardown statemachine */
+	teardownStatemachine(&machine, &dummyTimer, &eventPool);
+
+	return 0;
+}
+
+
+
+
+
+
+int main(int argc, char** argv)
+{
+	if (argc != 2)
+		return -1;
+
+	switch (atoi(argv[1])) {
+	case 1:
+		return test_state9_state10_transition();
+	case 2:
+		return test_state1_state2_back_transition();
+	}
+
+	return -1;
+
+}