From 034ab6dd8619d13b58040dd565aca52a7b7a719c Mon Sep 17 00:00:00 2001 From: chuaizhzh Date: Wed, 14 Apr 2021 21:39:41 +0800 Subject: [PATCH] testOsThreadNew005 Change-Id: I3120cb2673b61bdda1d82f9d1522d9e9cd2b64c0 --- .../src/cmsis_task_func_test.c | 31 +++++++++++++++++-- kernel_lite/kernelcmsis_hal/src/kernel_test.h | 2 ++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/kernel_lite/kernelcmsis_hal/src/cmsis_task_func_test.c b/kernel_lite/kernelcmsis_hal/src/cmsis_task_func_test.c index 847d6ad77..78b139482 100755 --- a/kernel_lite/kernelcmsis_hal/src/cmsis_task_func_test.c +++ b/kernel_lite/kernelcmsis_hal/src/cmsis_task_func_test.c @@ -127,13 +127,37 @@ static void CmsisThreadCreat004Func001(void const *argument) osThreadExit(); } +static void KeepRunByTick(UINT32 tick) +{ + UINT32 tickA = osKernelGetTickCount(); + UINT32 runned = 0; + UINT32 loop = 0; + UINT32 tickB = 0; + while (runned < tick) { + loop++; + tickB = osKernelGetTickCount(); + if (tickB >= tickA) { + runned = tickB - tickA; + } else { + runned = tickB + (MAX_UINT32 - tickA); + } + if (loop % ALIVE_INFO_DIS == 0) { + printf("runned:%u, tickB:%u, tickA:%u, loop:%u\t\n", + runned, tickB, tickA, loop); + } + } + printf("return runned:%u, tickB:%u, tickA:%u\t\n", + runned, tickB, tickA); + return; +} + static void CmsisThreadCreat005Func001(void const *argument) { (void)argument; UINT32 uwIndex; TEST_ASSERT_EQUAL_INT(TESTCOUNT_NUM_1, g_cmsisTestTaskCount); - for (uwIndex = 0; uwIndex < TEST_TIME; uwIndex++) { - printf("test the thread running delay:%d \t\n", uwIndex); + while (g_cmsisTestTaskCount < TESTCOUNT_NUM_2) { + KeepRunByTick(DELAY_TICKS_10); } g_cmsisTestTaskCount++; TEST_ASSERT_EQUAL_INT(TESTCOUNT_NUM_3, g_cmsisTestTaskCount); @@ -504,6 +528,9 @@ LITE_TEST_CASE(CmsisTaskFuncTestSuite, testOsThreadNew005, Function | MediumTest g_cmsisTestTaskCount++; TEST_ASSERT_EQUAL_INT(TESTCOUNT_NUM_2, g_cmsisTestTaskCount); osDelay(DELAY_TICKS_5); + while (g_cmsisTestTaskCount != TESTCOUNT_NUM_3) { + KeepRunByTick(DELAY_TICKS_10); + } }; /** diff --git a/kernel_lite/kernelcmsis_hal/src/kernel_test.h b/kernel_lite/kernelcmsis_hal/src/kernel_test.h index 664150f7f..dce25f022 100755 --- a/kernel_lite/kernelcmsis_hal/src/kernel_test.h +++ b/kernel_lite/kernelcmsis_hal/src/kernel_test.h @@ -33,6 +33,8 @@ #define THREAD_COUNT_MIN 3 #define THREAD_COUNT_MAX 30 #define THREAD_STACK_SPACE_MAX 4096 +#define MAX_UINT32 0xFFFFFFFF +#define ALIVE_INFO_DIS 10000 #ifdef __cplusplus #if __cplusplus -- GitLab