8
8
#include <kernel.h>
9
9
#include <cmsis_os2.h>
10
10
11
- #define STACKSZ 512
11
+ #define STACKSZ 512
12
12
13
13
/* This is used to check the thread yield functionality between 2 threads */
14
14
static int thread_yield_check ;
15
15
16
16
static K_THREAD_STACK_DEFINE (test_stack1 , STACKSZ ) ;
17
17
static osThreadAttr_t thread1_attr = {
18
- .name = "Thread1" ,
19
- .stack_mem = & test_stack1 ,
18
+ .name = "Thread1" ,
19
+ .stack_mem = & test_stack1 ,
20
20
.stack_size = STACKSZ ,
21
- .priority = osPriorityHigh ,
21
+ .priority = osPriorityHigh ,
22
22
};
23
23
24
24
static K_THREAD_STACK_DEFINE (test_stack2 , STACKSZ ) ;
25
25
static osThreadAttr_t thread2_attr = {
26
- .name = "Thread2" ,
27
- .stack_mem = & test_stack2 ,
26
+ .name = "Thread2" ,
27
+ .stack_mem = & test_stack2 ,
28
28
.stack_size = STACKSZ ,
29
- .priority = osPriorityHigh ,
29
+ .priority = osPriorityHigh ,
30
30
};
31
31
32
32
static void thread1 (void * argument )
@@ -40,7 +40,7 @@ static void thread1(void *argument)
40
40
41
41
name = osThreadGetName (thread_id );
42
42
zassert_true (strcmp (thread1_attr .name , name ) == 0 ,
43
- "Failed getting Thread name" );
43
+ "Failed getting Thread name" );
44
44
45
45
/* This thread starts off at a high priority (same as thread2) */
46
46
thread_yield_check ++ ;
@@ -72,7 +72,7 @@ static void thread2(void *argument)
72
72
thread_array = k_calloc (max_num_threads , sizeof (osThreadId_t ));
73
73
num_threads = osThreadEnumerate (thread_array , max_num_threads );
74
74
zassert_equal (num_threads , 2 ,
75
- "Incorrect number of cmsis rtos v2 threads" );
75
+ "Incorrect number of cmsis rtos v2 threads" );
76
76
77
77
for (i = 0 ; i < num_threads ; i ++ ) {
78
78
zassert_true (
@@ -85,17 +85,17 @@ static void thread2(void *argument)
85
85
}
86
86
87
87
zassert_equal (osThreadGetState (thread_array [1 ]), osThreadReady ,
88
- "Thread not in ready state" );
88
+ "Thread not in ready state" );
89
89
zassert_equal (osThreadGetState (thread_array [0 ]), osThreadRunning ,
90
- "Thread not in running state" );
90
+ "Thread not in running state" );
91
91
92
92
zassert_equal (osThreadSuspend (thread_array [1 ]), osOK , "" );
93
93
zassert_equal (osThreadGetState (thread_array [1 ]), osThreadBlocked ,
94
- "Thread not in blocked state" );
94
+ "Thread not in blocked state" );
95
95
96
96
zassert_equal (osThreadResume (thread_array [1 ]), osOK , "" );
97
97
zassert_equal (osThreadGetState (thread_array [1 ]), osThreadReady ,
98
- "Thread not in ready state" );
98
+ "Thread not in ready state" );
99
99
100
100
k_free (thread_array );
101
101
@@ -115,7 +115,7 @@ void test_thread_apis(void)
115
115
zassert_true (id2 != NULL , "Failed creating thread2" );
116
116
117
117
zassert_equal (osThreadGetCount (), 2 ,
118
- "Incorrect number of cmsis rtos v2 threads" );
118
+ "Incorrect number of cmsis rtos v2 threads" );
119
119
120
120
do {
121
121
osDelay (100 );
@@ -129,10 +129,10 @@ static int thread3_state;
129
129
130
130
static K_THREAD_STACK_DEFINE (test_stack3 , STACKSZ ) ;
131
131
static osThreadAttr_t thread3_attr = {
132
- .name = "Thread3" ,
133
- .stack_mem = & test_stack3 ,
132
+ .name = "Thread3" ,
133
+ .stack_mem = & test_stack3 ,
134
134
.stack_size = STACKSZ ,
135
- .priority = osPriorityNormal ,
135
+ .priority = osPriorityNormal ,
136
136
};
137
137
138
138
static void thread3 (void * argument )
@@ -146,27 +146,27 @@ static void thread3(void *argument)
146
146
osThreadSetPriority (id , osPriorityBelowNormal );
147
147
rv = osThreadGetPriority (id );
148
148
zassert_equal (rv , osPriorityBelowNormal ,
149
- "Expected priority to be changed to %d, not %d" ,
150
- (int )osPriorityBelowNormal , (int )rv );
149
+ "Expected priority to be changed to %d, not %d" ,
150
+ (int )osPriorityBelowNormal , (int )rv );
151
151
152
152
/* Increase the priority of the current thread */
153
153
osThreadSetPriority (id , osPriorityAboveNormal );
154
154
rv = osThreadGetPriority (id );
155
155
zassert_equal (rv , osPriorityAboveNormal ,
156
- "Expected priority to be changed to %d, not %d" ,
157
- (int )osPriorityAboveNormal , (int )rv );
156
+ "Expected priority to be changed to %d, not %d" ,
157
+ (int )osPriorityAboveNormal , (int )rv );
158
158
159
159
/* Restore the priority of the current thread */
160
160
osThreadSetPriority (id , prio );
161
161
rv = osThreadGetPriority (id );
162
162
zassert_equal (rv , prio ,
163
- "Expected priority to be changed to %d, not %d" ,
164
- (int )prio , (int )rv );
163
+ "Expected priority to be changed to %d, not %d" ,
164
+ (int )prio , (int )rv );
165
165
166
166
/* Try to set unsupported priority and assert failure */
167
167
status = osThreadSetPriority (id , OsPriorityInvalid );
168
168
zassert_true (status == osErrorParameter ,
169
- "Something's wrong with osThreadSetPriority!" );
169
+ "Something's wrong with osThreadSetPriority!" );
170
170
171
171
/* Indication that thread3 is done with its processing */
172
172
thread3_state = 1 ;
@@ -198,12 +198,12 @@ void test_thread_prio(void)
198
198
/* Try to set priority to inactive thread and assert failure */
199
199
status = osThreadSetPriority (id3 , osPriorityNormal );
200
200
zassert_true (status == osErrorResource ,
201
- "Something's wrong with osThreadSetPriority!" );
201
+ "Something's wrong with osThreadSetPriority!" );
202
202
203
203
/* Try to terminate inactive thread and assert failure */
204
204
status = osThreadTerminate (id3 );
205
205
zassert_true (status == osErrorResource ,
206
- "Something's wrong with osThreadTerminate!" );
206
+ "Something's wrong with osThreadTerminate!" );
207
207
208
208
thread3_state = 0 ;
209
209
}
0 commit comments