MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / test_thread_control

Function test_thread_control

src/utest/thread_tc.c:321–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321static void test_thread_control(void)
322{
323 rt_err_t ret_control = -RT_ERROR;
324 rt_err_t rst_delete = -RT_ERROR;
325 rt_sched_lock_level_t slvl;
326
327 tid7 = rt_thread_create("thread7",
328 thread7_entry,
329 RT_NULL,
330 THREAD_STACK_SIZE,
331 UTEST_THR_PRIORITY + 1,
332 THREAD_TIMESLICE);
333 if (tid7 == RT_NULL)
334 {
335 LOG_E("rt_thread_create failed!");
336 uassert_false(tid7 == RT_NULL);
337 goto __exit;
338 }
339
340 ret_control = rt_thread_control(tid7, RT_THREAD_CTRL_STARTUP, RT_NULL);
341 if (ret_control != RT_EOK)
342 {
343 LOG_E("rt_thread_control failed!");
344 uassert_false(1);
345 goto __exit;
346 }
347 rt_thread_mdelay(200);
348 rt_thread_control(tid7, RT_THREAD_CTRL_CHANGE_PRIORITY, &change_priority);
349
350 rt_sched_lock(&slvl);
351 if (rt_sched_thread_get_curr_prio(tid7) != change_priority)
352 {
353 LOG_E("rt_thread_control failed!");
354 uassert_false(1);
355 rt_sched_unlock(slvl);
356 goto __exit;
357 }
358 rt_sched_unlock(slvl);
359
360 rst_delete = rt_thread_control(tid7, RT_THREAD_CTRL_CLOSE, RT_NULL);
361 if (rst_delete != RT_EOK)
362 {
363 LOG_E("rt_thread_control failed!");
364 uassert_false(rst_delete != RT_EOK);
365 goto __exit;
366 }
367
368 uassert_true(1);
369
370__exit:
371 if (tid7 != RT_NULL && rst_delete != RT_EOK)
372 {
373 rt_thread_delete(tid7);
374 }
375 return;
376}
377
378static void thread8_entry(void *parameter)

Callers

nothing calls this directly

Calls 7

rt_thread_createFunction · 0.85
rt_thread_controlFunction · 0.85
rt_thread_mdelayFunction · 0.85
rt_thread_deleteFunction · 0.85
rt_sched_lockFunction · 0.50
rt_sched_unlockFunction · 0.50

Tested by

no test coverage detected