main.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * main.c
  3. *
  4. * Created on: 16.11.2011
  5. * Author: showcase
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <assert.h>
  10. #include <string.h>
  11. #include "Timer.h"
  12. #include "DummyTimer.h"
  13. #include "Test_ParallelRegionsStatemachine.h"
  14. /*@DTestSuite: ParallelRegions Statechart Test (Test_ParallelRegions.sct) */
  15. #define MAXEVENTSPERTYPE 4
  16. const char* stateName[6] = {"State1", "State2", "State3", "State4", "State5", "State6"};
  17. void setupStatemachine(Test_ParallelRegionsStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
  18. {
  19. /* set up dummy Timer */
  20. dummyTimer_init(dummyTimer);
  21. /* Set up Event Pool */
  22. test_ParallelRegions_eventPool_init_heap(eventPool, MAXEVENTSPERTYPE);
  23. /* initialize state machine */
  24. test_ParallelRegionsStatemachine_init(machine, dummyTimer, eventPool);
  25. }
  26. void teardownStatemachine(Test_ParallelRegionsStatemachine* machine, Timer* dummyTimer, EventPool* eventPool)
  27. {
  28. test_ParallelRegionsStatemachine_exit(machine);
  29. timer_exit(dummyTimer);
  30. eventPool_exit(eventPool);
  31. }
  32. /*@Test: test_default_var1 test behavior of var1 in default interface */
  33. int test_initialization()
  34. {
  35. return 0;
  36. }
  37. /*@Test: test_state9_state10_transition test behavior of var1 in default and other interface */
  38. int dummy1()
  39. {
  40. Test_ParallelRegionsStatemachine machine;
  41. Timer dummyTimer;
  42. EventPool eventPool;
  43. /*@Desc: setup initial statemachine */
  44. setupStatemachine(&machine, &dummyTimer, &eventPool);
  45. /*@Desc: teardown statemachine */
  46. teardownStatemachine(&machine, &dummyTimer, &eventPool);
  47. return 0;
  48. }
  49. /*@Test: test_default_var1 test behavior of var1 in default and other interface */
  50. int dummy2()
  51. {
  52. Test_ParallelRegionsStatemachine machine;
  53. Timer dummyTimer;
  54. EventPool eventPool;
  55. /*@Desc: setup initial statemachine */
  56. setupStatemachine(&machine, &dummyTimer, &eventPool);
  57. /*@Desc: run an explicit cycle - without any waiting event (for initialization) */
  58. test_ParallelRegionsStatemachine_runCycle(&machine);
  59. /*@Desc: */
  60. /*@Desc: teardown statemachine */
  61. teardownStatemachine(&machine, &dummyTimer, &eventPool);
  62. return 0;
  63. }
  64. int main(int argc, char** argv)
  65. {
  66. if (argc != 2)
  67. return -1;
  68. switch (atoi(argv[1])) {
  69. case 1:
  70. return dummy1();
  71. case 2:
  72. return dummy2();
  73. }
  74. return -1;
  75. }