]> rtime.felk.cvut.cz Git - arc.git/blob - system/kernel/testsystem/test_sup_04.c
Again, loads of refactoring and removing and adding files.
[arc.git] / system / kernel / testsystem / test_sup_04.c
1 /* -------------------------------- Arctic Core ------------------------------\r
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com\r
3  *\r
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>\r
5  *\r
6  * This source code is free software; you can redistribute it and/or modify it\r
7  * under the terms of the GNU General Public License version 2 as published by the\r
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.\r
9  *\r
10  * This program is distributed in the hope that it will be useful, but\r
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\r
13  * for more details.\r
14  * -------------------------------- Arctic Core ------------------------------*/\r
15 \r
16 /*\r
17  * Tested: Resources\r
18  *\r
19  * Calls:  GetResource()\r
20  *         ReleaseResource()\r
21  *         Schedule()\r
22  *\r
23  */\r
24 \r
25 #include "Os.h"\r
26 #include "Trace.h"\r
27 //#include <stdio.h>\r
28 #include <assert.h>\r
29 #include "os_test.h"\r
30 #include "irq.h"\r
31 \r
32 #if 0\r
33 void isr_l(void ) {\r
34         switch(test_nr) {\r
35         case 2:\r
36                 TEST_OK();\r
37                 test_nr++;\r
38         case 5:\r
39                 test_nr++;\r
40                 /* Trigger higher prio interrupt */\r
41                 Irq_GenerateSoftInt(EXTI1_IRQn);\r
42                 TEST_ASSERT(test_nr==8);\r
43                 break;\r
44         default:\r
45                 assert(0);\r
46         }\r
47 }\r
48 \r
49 void isr_m(void ) {\r
50         switch(test_nr) {\r
51         case 3:\r
52                 TEST_OK();\r
53                 test_nr++;\r
54         case 6:\r
55                 test_nr++;\r
56                 /* Trigger higher prio interrupt */\r
57                 Irq_GenerateSoftInt(EXTI2_IRQn);\r
58                 TEST_ASSERT(test_nr==7);\r
59                 test_nr++;\r
60                 break;\r
61         default:\r
62                 assert(0);\r
63         }\r
64 \r
65 }\r
66 #endif\r
67 \r
68 \r
69 void etask_sup_l_04( void ) {\r
70         test_nr = 1;\r
71         TaskType isr1;\r
72         TaskType isr2;\r
73         TaskType isr3;\r
74 \r
75         for(;;) {\r
76                 switch(test_nr){\r
77                 case 1:\r
78                         // test 01 ===============================================\r
79                         // Test: Grab and release the one and only standard resource.\r
80                         GetResource(RES_SCHEDULER);\r
81                         ReleaseResource(RES_SCHEDULER);\r
82                         TEST_OK();\r
83                         test_nr++;\r
84                         break;\r
85 \r
86                 case 2:\r
87                         // test 02 ===============================================\r
88                         // Test: Grab resource twice. Should result in E_OS_ACCESS\r
89                         GetResource(RES_SCHEDULER);\r
90                         GetResource(RES_SCHEDULER);\r
91                         ReleaseResource(RES_SCHEDULER);\r
92                         // ??\r
93                         TEST_OK();\r
94                         test_nr++;\r
95 \r
96                         break;\r
97                 case 3:\r
98                         // test 03 ===============================================\r
99                         // Test: Check that the scheduler is locked when doing this.\r
100                         //       SetEvent() on higher prio process.\r
101                         GetResource(RES_SCHEDULER);\r
102                         // TODO:\r
103                         ReleaseResource(RES_SCHEDULER);\r
104                         TEST_OK();\r
105                         test_nr++;\r
106                         break;\r
107                 case 4:\r
108                         // test 04 ===============================================\r
109                         // Test: Check that priority inversion works.\r
110                         //       Allocate resource and check priority.\r
111                         GetResource(RES_ID_ext_prio_3);\r
112                         ReleaseResource(RES_ID_ext_prio_3);\r
113                         TEST_OK();\r
114                         test_nr++;\r
115                         break;\r
116                 case 5:\r
117                         // test 05 ===============================================\r
118                         // Test: Attempt to get a resource which the statically assigned\r
119                         //       priority of the calling task or interrupt routine is\r
120                         //       higher than the calculated ceiling priority, E_OS_ACCESS\r
121                         TEST_ASSERT(test_nr==5);\r
122                         break;\r
123                 case 6:\r
124                         // test 06 ===============================================\r
125                         // Test: Nest resources\r
126                         GetResource(RES_ID_ext_prio_3);\r
127                         GetResource(RES_ID_ext_prio_4);\r
128                         ReleaseResource(RES_ID_ext_prio_4);\r
129                         ReleaseResource(RES_ID_ext_prio_3);\r
130                         TEST_OK();\r
131                         test_nr++;\r
132                         break;\r
133                 case 100:\r
134                         TerminateTask();\r
135                 default:\r
136                         assert(0);\r
137                         while(1);\r
138                 }\r
139         }\r
140 }\r
141 \r
142 void etask_sup_m_04( void ) {\r
143         switch(test_nr){\r
144         case 1:\r
145                 TEST_OK();\r
146                 test_nr++;\r
147                 ChainTask(TASK_ID_etask_sup_l);\r
148                 break;\r
149         default:\r
150                 while(1);\r
151         }\r
152 \r
153 }\r