1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 * of conditions and the following disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 * to endorse or promote products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _OSTEST_H 33 #define _OSTEST_H 34 35 #include <stdio.h> 36 #include <stdlib.h> 37 #include <string.h> 38 39 #include "iCunit.h" 40 41 #include "los_debug.h" 42 #include "los_config.h" 43 44 #include "los_interrupt.h" 45 #include "los_arch_interrupt.h" 46 #include "los_task.h" 47 #include "los_sem.h" 48 #include "los_event.h" 49 #include "los_memory.h" 50 #include "los_queue.h" 51 #if (LOSCFG_BASE_CORE_CPUP == 1) 52 #include "los_cpup.h" 53 #endif 54 #include "los_tick.h" 55 #include "los_swtmr.h" 56 #include "los_mux.h" 57 #include "securec.h" 58 #include "securectype.h" 59 60 #ifdef __cplusplus 61 #if __cplusplus 62 extern "C" { 63 #endif /* __cplusplus */ 64 #endif /* __cplusplus */ 65 66 #define PRINTF(fmt, args...) \ 67 do { \ 68 printf(fmt, ##args); \ 69 } while (0) 70 71 #define LITEOS_BASE_TEST 1 72 73 #ifndef LOS_KERNEL_TEST_FULL 74 #define LOS_KERNEL_TEST_FULL 0 75 #endif 76 #define LOS_KERNEL_ATOMIC_TEST 1 77 #define LOS_KERNEL_CORE_TASK_TEST 1 78 #define LOS_KERNEL_IPC_MUX_TEST 1 79 #define LOS_KERNEL_IPC_SEM_TEST 1 80 #define LOS_KERNEL_IPC_EVENT_TEST 1 81 #define LOS_KERNEL_IPC_QUEUE_TEST 1 82 #define LOS_KERNEL_CORE_SWTMR_TEST 1 83 #ifndef LOS_KERNEL_HWI_TEST 84 #define LOS_KERNEL_HWI_TEST 1 85 #endif 86 #define LOS_KERNEL_FS_TEST 0 87 #define LOS_KERNEL_MEM_TEST 1 88 #define LOS_KERNEL_DYNLINK_TEST 0 89 #define LOS_KERNEL_TICKLESS_TEST 0 90 #if (LOSCFG_KERNEL_PM == 1) 91 #define LOS_KERNEL_PM_TEST 1 92 #else 93 #define LOS_KERNEL_PM_TEST 0 94 #endif 95 #define LOS_KERNEL_LMS_TEST 0 96 #define LOS_KERNEL_LMK_TEST 0 97 #define LOS_KERNEL_SIGNAL_TEST 0 98 99 #define LOS_XTS_TEST 1 100 #define LOS_POSIX_TEST 1 101 #define LOS_CMSIS_TEST 1 102 #define LOS_CMSIS2_CORE_TASK_TEST 0 103 #define LOS_CMSIS2_IPC_MUX_TEST 0 104 #define LOS_CMSIS2_IPC_SEM_TEST 0 105 #define LOS_CMSIS2_IPC_EVENT_TEST 0 106 #define LOS_CMSIS2_IPC_MSG_TEST 0 107 #define LOS_CMSIS2_CORE_SWTMR_TEST 0 108 #define LOS_CMSIS2_HWI_TEST 0 109 110 #define LOSCFG_TEST_LLT 0 111 #define LOSCFG_TEST_MUCH_LOG 0 112 113 extern UINT32 volatile g_testCount; 114 extern UINT32 g_testTskHandle; 115 extern UINT32 g_testTaskID01; 116 extern UINT32 g_testTaskID02; 117 extern UINT32 g_testTaskID03; 118 extern UINT32 g_testTaskID04; 119 extern UINT32 g_hwiNum1; 120 extern UINT32 g_hwiNum2; 121 extern UINT32 g_usSemID; 122 extern UINT32 g_usSemID2; 123 extern UINT32 g_mutexTest; 124 125 extern UINT16 g_usSwTmrID; 126 extern UINT32 g_usSemID; 127 extern UINT32 g_testQueueID01; 128 extern UINT32 g_testQueueID02; 129 extern UINT32 g_testQueueID03; 130 extern UINT32 g_testTskHandle; 131 extern UINT32 g_leavingTaskNum; 132 extern UINT32 g_testTaskIdArray[LOSCFG_BASE_CORE_TSK_LIMIT]; 133 extern UINT16 g_index; 134 extern UINT32 g_usSemID3[]; 135 extern EVENT_CB_S g_exampleEvent; 136 137 #ifndef LOS_TASK_MIN_TEST_STACK_SIZE 138 #define LOS_TASK_MIN_TEST_STACK_SIZE LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE + 0x20 139 #endif 140 141 #ifndef TASK_TEST 142 #define TASK_TEST 143 #endif 144 145 #ifndef SWTMR_TEST 146 #define SWTMR_TEST 147 #endif 148 149 #ifndef QUEUE_TEST 150 #define QUEUE_TEST 151 #endif 152 153 #ifndef SEM_TEST 154 #define SEM_TEST 155 #endif 156 157 #ifndef EVENT_TEST 158 #define EVENT_TEST 159 #endif 160 161 #ifndef HWI_TEST 162 #define HWI_TEST 163 #endif 164 165 #ifndef TICK_TEST 166 #define TICK_TEST 167 #endif 168 169 #ifndef EXC_TEST 170 #define EXC_TEST 171 #endif 172 173 #ifndef MEMCHECK_TEST 174 #define MEMCHECK_TEST 175 #endif 176 177 #ifndef MACRO_BASE_FUNCTION_TEST 178 #define MACRO_BASE_FUNCTION_TEST 179 #endif 180 181 #ifndef MACRO_EXC_TEST 182 #define MACRO_EXC_TEST 183 #endif 184 185 #ifndef MACRO_PRESSURE_TEST 186 #define MACRO_PRESSURE_TEST 187 #endif 188 189 #ifdef MACRO_PREESSURE_TEST 190 #define DIVISOR 1 191 #else 192 #define DIVISOR 10 193 #endif 194 195 #ifndef TEST_CASE_RES_CHECK 196 #define TEST_CASE_RES_CHECK 197 #endif 198 199 #ifndef TST_IT 200 #define TST_IT 201 #endif 202 203 #define TEST_PT 1 204 205 #if (1 == OS_INCLUDE_DYNMEM) 206 #define TEST_BIG 1 207 #else 208 #define TEST_BIG 0 209 #endif 210 211 #define TASK_PRIO_TEST 25 212 #define TASK_PRIO_TEST_NORMAL 20 213 214 #define TASK_LOOP_NUM 0x100000 215 #define QUEUE_LOOP_NUM 100 216 #define HWI_LOOP_NUM 100 217 #define SWTMR_LOOP_NUM 1000 218 #define TASK_NAME_NUM 10 219 #define TEST_TASK_RUNTIME 0x100000 220 #define TEST_SWTMR_RUNTIME 0x1000000 221 #define TEST_HWI_RUNTIME 0x100000 222 #define TEST_TASK_PRIORITY_LOW osPriorityBelowNormal // tskIDLE_PRIORITY + 10 223 #define TEST_TASK_PRIORITY_NORMAL osPriorityNormal // tskIDLE_PRIORITY + 11 224 #define TEST_TASK_PRIORITY_HIGH osPriorityAboveNormal // tskIDLE_PRIORITY + 12 225 #define TEST_TASK_PRIORITY_MAX osPriorityAboveNormal5 226 227 #define LOS_TASK_STATUS_DETACHED 0x0100 228 229 #define LOS_SYS_MS_PER_SECOND 1000 // Number of ms in one second. 230 #define LOS_SYS_US_PER_SECOND 1000000 // Number of us in one second. 231 232 #define LOS_MS_PER_TICK (LOS_SYS_MS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND) 233 234 #ifdef __RISC_V__ 235 #define OS_TSK_TEST_STACK_SIZE 0x9000 236 #elif __XTENSA_LX6__ 237 #define OS_TSK_TEST_STACK_SIZE 0x800 238 #else 239 #define OS_TSK_TEST_STACK_SIZE 0x1000 240 #endif 241 #define TASK_STACK_SIZE_TEST OS_TSK_TEST_STACK_SIZE 242 #define TEST_TASK_STACK_SIZE OS_TSK_TEST_STACK_SIZE 243 #define TASK_CMSIS_STACK_SIZE_TEST 0x600 244 245 #define OS_EVENT_TIMEOUT_MAX_VAL 0xFFFFFFFF 246 247 extern UINT32 QueueUsedCountGet(VOID); 248 extern UINT32 TaskUsedCountGet(VOID); 249 #define TASK_EXISTED_NUM TaskUsedCountGet() 250 #define QUEUE_EXISTED_NUM QueueUsedCountGet() 251 252 #define HWI_NUM_INT_NEG (-4) 253 #define HWI_NUM_INT0 0 254 #define HWI_NUM_INT1 1 255 #define HWI_NUM_INT2 2 256 #define HWI_NUM_INT3 3 257 #define HWI_NUM_INT4 4 258 #define HWI_NUM_INT5 5 259 #define HWI_NUM_INT6 6 260 #define HWI_NUM_INT7 7 261 #define HWI_NUM_INT11 11 262 #define HWI_NUM_INT12 12 263 #define HWI_NUM_INT13 13 264 #define HWI_NUM_INT14 14 265 #define HWI_NUM_INT15 15 266 #define HWI_NUM_INT16 16 267 #define HWI_NUM_INT17 17 268 #define HWI_NUM_INT18 18 269 #define HWI_NUM_INT21 21 270 #define HWI_NUM_INT22 22 271 #define HWI_NUM_INT23 23 272 #define HWI_NUM_INT24 24 273 #define HWI_NUM_INT25 25 274 #define HWI_NUM_INT26 26 275 #define HWI_NUM_INT27 27 276 #define HWI_NUM_INT28 28 277 #define HWI_NUM_INT30 30 278 #define HWI_NUM_INT31 31 279 #define HWI_NUM_INT32 32 280 #define HWI_NUM_INT33 33 281 #define HWI_NUM_INT45 45 282 #define HWI_NUM_INT50 50 283 #define HWI_NUM_INT55 55 284 #define HWI_NUM_INT60 60 285 #define HWI_NUM_INT58 58 286 #define HWI_NUM_INT59 59 287 288 #define HWI_NUM_INT75 75 289 #define HWI_NUM_INT71 71 290 #define HWI_NUM_INT72 72 291 #define HWI_NUM_INT73 73 292 293 #ifdef __RISC_V__ 294 #define HWI_NUM_TEST 32 295 #define HWI_NUM_TEST0 33 296 #define HWI_NUM_TEST1 34 297 #define HWI_NUM_TEST2 35 298 #define HWI_NUM_TEST3 36 299 #define LOS_KERNEL_MULTI_HWI_TEST 1 // default enable multiple hwi number test case 300 #elif __CSKY_V2__ 301 #define HWI_NUM_TEST 31 // csky_v2 only support one software interrupt number 302 #define LOS_KERNEL_MULTI_HWI_TEST 0 // csky_v2 not support multiple hwi number test case 303 #elif __XTENSA_LX6__ 304 #define HWI_NUM_TEST 7 // xtensa_lx6 only support one software interrupt number 305 #define LOS_KERNEL_MULTI_HWI_TEST 0 // xtensa_lx6 not support multiple hwi number test case 306 #else 307 #define HWI_NUM_TEST HWI_NUM_INT7 308 #define HWI_NUM_TEST0 HWI_NUM_INT1 309 #define HWI_NUM_TEST1 HWI_NUM_INT11 310 #define HWI_NUM_TEST2 HWI_NUM_INT12 311 #define HWI_NUM_TEST3 HWI_NUM_INT14 312 #define LOS_KERNEL_MULTI_HWI_TEST 1 // default enable multiple hwi number test case 313 #endif 314 315 #define LOSCFG_BASE_IPC_QUEUE_CONFIG LOSCFG_BASE_IPC_QUEUE_LIMIT 316 #define LOSCFG_BASE_IPC_SEM_CONFIG LOSCFG_BASE_IPC_SEM_LIMIT 317 #define LOSCFG_BASE_CORE_SWTMR_CONFIG LOSCFG_BASE_CORE_SWTMR_LIMIT 318 #define LOSCFG_BASE_CORE_TSK_CONFIG LOSCFG_BASE_CORE_TSK_LIMIT 319 #define dprintf printf 320 #define IT_SEM_COUNT_MAX OS_SEM_COUNTING_MAX_COUNT 321 322 extern EVENT_CB_S g_pstEventCb01; 323 extern EVENT_CB_S g_pstEventCb02; 324 extern EVENT_CB_S g_pstEventCb03; 325 326 327 extern UINT32 TEST_TskDelete(UINT32 taskID); 328 extern UINT32 TestSemDelete(UINT32 semHandle); 329 extern UINT32 TestHwiDelete(UINT32 hwiNum); 330 extern VOID TEST_HwiDeleteAll(VOID); 331 extern VOID TestHwiTrigger(UINT32 hwiNum); 332 extern VOID TestHwiClear(UINT32 hwiNum); 333 #ifdef __RISC_V__ 334 extern UINT64 LosCpuCycleGet(VOID); 335 #else 336 typedef struct tagHwiHandleForm { 337 HWI_PROC_FUNC pfnHook; 338 UINT32 uwPrioMask; 339 } HWI_HANDLE_FORM_S; 340 #endif 341 #define TEST_HwiCreate(ID, prio, mode, Func, irqParam) LOS_HwiCreate(ID, prio, mode, Func, irqParam) 342 #define uart_printf_func printf 343 344 extern VOID ItSuiteLosAtomic(void); 345 extern VOID ItSuiteLosTask(void); 346 extern VOID ItSuiteLosQueue(void); 347 extern VOID ItSuiteLosMux(void); 348 extern VOID ItSuiteLosEvent(void); 349 extern VOID ItSuiteLosSem(void); 350 extern VOID ItSuiteLosSwtmr(void); 351 extern VOID ItSuiteLosHwi(void); 352 extern VOID ItSuiteLosMem(void); 353 extern VOID ItSuiteLosDynlink(void); 354 extern VOID ItSuite_Los_FatFs(void); 355 extern VOID ItSuiteLosPm(void); 356 extern VOID ItSuiteLosLmk(void); 357 extern VOID ItSuiteLosSignal(void); 358 359 extern int PthreadFuncTestSuite(void); 360 361 extern void CmsisFuncTestSuite(void); 362 363 extern VOID ItSuite_Cmsis_Lostask(void); 364 extern VOID ItSuite_Cmsis_Lostask_add(void); 365 extern VOID ItSuite_CMSIS_Losmsg(void); 366 extern VOID ItSuite_CMSIS_Losmsg_add(void); 367 extern VOID ItSuite_CMSIS_Signal(void); 368 extern VOID ItSuite_CMSIS_Signal_add(void); 369 extern VOID ItSuite_Cmsis_LosMemBox(void); 370 extern VOID ItSuite_Cmsis_LosMutex(void); 371 extern VOID ItSuite_Cmsis_LosMutex_add(void); 372 extern VOID ItSuite_Cmsis_LosRobin(void); 373 extern VOID ItSuite_Cmsis_LosRobin_add(void); 374 extern VOID ItSuite_CMSIS_Losmail(void); 375 extern VOID ItSuite_CMSIS_Losmail_add(void); 376 extern VOID ItSuite_Cmsis_LosSem(void); 377 extern VOID ItSuite_Cmsis_LosSem_add(void); 378 extern VOID ItSuite_CMSIS_Swtmr(void); 379 extern VOID ItSuite_CMSIS_Swtmr_add(void); 380 extern VOID ItSuite_Cmsis_Hwi_M3(VOID); 381 extern VOID ItSuite_Cmsis_Hwi_M3_add(void); 382 extern VOID ItSuite_CMSIS_Wait(void); 383 extern VOID ItSuite_CMSIS_Wait_add(VOID); 384 385 #define OS_MS_TO_TICK(ms) (((ms) * (UINT64)LOSCFG_BASE_CORE_TICK_PER_SECOND) / 1000) 386 387 extern UINT32 g_usSemID; 388 extern UINT32 g_auwTestTaskID[LOSCFG_BASE_CORE_TSK_LIMIT]; 389 390 extern LosQueueCB *g_pstAllQueue; 391 extern UINT32 g_taskMaxNum; 392 393 extern LITE_OS_SEC_BSS_INIT LOS_DL_LIST g_stUnusedSemList; 394 395 extern LosTask g_losTask; 396 extern VOID LOS_Schedule(VOID); 397 extern LosTaskCB *g_taskCBArray; 398 399 #ifdef __cplusplus 400 #if __cplusplus 401 } 402 #endif /* __cplusplus */ 403 #endif /* __cplusplus */ 404 405 #endif /* _OSTEST_H */ 406