10d163575Sopenharmony_ci/* 20d163575Sopenharmony_ci * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 30d163575Sopenharmony_ci * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 40d163575Sopenharmony_ci * 50d163575Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 60d163575Sopenharmony_ci * are permitted provided that the following conditions are met: 70d163575Sopenharmony_ci * 80d163575Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 90d163575Sopenharmony_ci * conditions and the following disclaimer. 100d163575Sopenharmony_ci * 110d163575Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 120d163575Sopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 130d163575Sopenharmony_ci * provided with the distribution. 140d163575Sopenharmony_ci * 150d163575Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 160d163575Sopenharmony_ci * to endorse or promote products derived from this software without specific prior written 170d163575Sopenharmony_ci * permission. 180d163575Sopenharmony_ci * 190d163575Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 200d163575Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 210d163575Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 220d163575Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 230d163575Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 240d163575Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 250d163575Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 260d163575Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 270d163575Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 280d163575Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 290d163575Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 300d163575Sopenharmony_ci */ 310d163575Sopenharmony_ci 320d163575Sopenharmony_ci#ifndef _OSTEST_H 330d163575Sopenharmony_ci#define _OSTEST_H 340d163575Sopenharmony_ci 350d163575Sopenharmony_ci#ifndef SWTMR_TEST 360d163575Sopenharmony_ci#define SWTMR_TEST 370d163575Sopenharmony_ci#endif 380d163575Sopenharmony_ci#include "iCunit.h" 390d163575Sopenharmony_ci#include <sched.h> 400d163575Sopenharmony_ci#include <pthread.h> 410d163575Sopenharmony_ci#include <stdio.h> 420d163575Sopenharmony_ci#include <stdlib.h> 430d163575Sopenharmony_ci#include <limits.h> 440d163575Sopenharmony_ci#include <string.h> 450d163575Sopenharmony_ci#include <unistd.h> 460d163575Sopenharmony_ci#include <sys/mman.h> 470d163575Sopenharmony_ci#include <errno.h> 480d163575Sopenharmony_ci#include <stdint.h> 490d163575Sopenharmony_ci#include <stdarg.h> 500d163575Sopenharmony_ci#include <sys/prctl.h> 510d163575Sopenharmony_ci#include <time.h> 520d163575Sopenharmony_ci#include <search.h> 530d163575Sopenharmony_ci#include <sys/mount.h> 540d163575Sopenharmony_ci#include "los_typedef.h" 550d163575Sopenharmony_ci#include "sys/wait.h" 560d163575Sopenharmony_ci#include "glob.h" 570d163575Sopenharmony_ci#include "mntent.h" 580d163575Sopenharmony_ci#include "securectype.h" 590d163575Sopenharmony_ci#include "securec.h" 600d163575Sopenharmony_ci#include <wchar.h> 610d163575Sopenharmony_ci#include <fcntl.h> 620d163575Sopenharmony_ci#include <sys/stat.h> 630d163575Sopenharmony_ci#include <dirent.h> 640d163575Sopenharmony_ci#include <semaphore.h> 650d163575Sopenharmony_ci 660d163575Sopenharmony_ci#ifndef OK 670d163575Sopenharmony_ci#define OK 0 680d163575Sopenharmony_ci#endif 690d163575Sopenharmony_ci 700d163575Sopenharmony_ci#define dprintf printf 710d163575Sopenharmony_ci#define ENOERR OK 720d163575Sopenharmony_ci#define LOSCFG_BASE_CORE_TSK_CONFIG 1024 730d163575Sopenharmony_ci 740d163575Sopenharmony_ci#define USER_PROCESS_PRIORITY_HIGHEST 10 750d163575Sopenharmony_ci#define USER_PROCESS_PRIORITY_LOWEST 31 760d163575Sopenharmony_ci#define TEST_TASK_PARAM_INIT(stTestTask, task_name, entry, prio) \ 770d163575Sopenharmony_ci do { \ 780d163575Sopenharmony_ci (void)memset_s(&stTestTask, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); \ 790d163575Sopenharmony_ci stTestTask.pfnTaskEntry = (TSK_ENTRY_FUNC)entry; \ 800d163575Sopenharmony_ci stTestTask.uwStackSize = LOS_TASK_MIN_STACK_SIZE; \ 810d163575Sopenharmony_ci stTestTask.pcName = task_name; \ 820d163575Sopenharmony_ci stTestTask.usTaskPrio = prio; \ 830d163575Sopenharmony_ci stTestTask.uwResved = LOS_TASK_STATUS_DETACHED; \ 840d163575Sopenharmony_ci } while (0) 850d163575Sopenharmony_ci 860d163575Sopenharmony_ci#ifdef LOSCFG_KERNEL_SMP 870d163575Sopenharmony_ci#define TEST_TASK_PARAM_INIT_AFFI(stTestTask, task_name, entry, prio, affi) \ 880d163575Sopenharmony_ci TEST_TASK_PARAM_INIT(stTestTask, task_name, entry, prio) \ 890d163575Sopenharmony_ci stTestTask.usCpuAffiMask = affi; 900d163575Sopenharmony_ci#else 910d163575Sopenharmony_ci#define TEST_TASK_PARAM_INIT_AFFI(stTestTask, task_name, entry, prio, affi) \ 920d163575Sopenharmony_ci TEST_TASK_PARAM_INIT(stTestTask, task_name, entry, prio) 930d163575Sopenharmony_ci#endif 940d163575Sopenharmony_ci#define JFFS_BASE_MTD_ADDR 0x100000 950d163575Sopenharmony_ci#define JFFS_BASE_MTD_LEN 0x600000 960d163575Sopenharmony_ci 970d163575Sopenharmony_ci#define LOS_TASK_MIN_STACK_SIZE 2048 980d163575Sopenharmony_ci#define TASK_PRIO_TEST 20 990d163575Sopenharmony_ci#ifdef LOSCFG_AARCH64 1000d163575Sopenharmony_ci#define TASK_STACK_SIZE_TEST (LOS_TASK_MIN_STACK_SIZE * 3) 1010d163575Sopenharmony_ci#else 1020d163575Sopenharmony_ci#define TASK_STACK_SIZE_TEST LOS_TASK_MIN_STACK_SIZE 1030d163575Sopenharmony_ci#endif 1040d163575Sopenharmony_ci#define LOS_MS_PER_TICK (OS_SYS_MS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND) 1050d163575Sopenharmony_ci 1060d163575Sopenharmony_ci#define HWI_NUM_INTVALID OS_HWI_MAX_NUM 1070d163575Sopenharmony_ci#define writel(value, address) WRITE_UINT32(value, address) 1080d163575Sopenharmony_ci 1090d163575Sopenharmony_ciextern UINT32 PrepareFileEnv(CHAR *pathList[], CHAR *streamList[], INT32 streamLen[], INT32 listCnt); 1100d163575Sopenharmony_ciextern UINT32 RecoveryFileEnv(CHAR *pathList[], INT32 listCnt); 1110d163575Sopenharmony_ciextern UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri); 1120d163575Sopenharmony_ciextern UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread); 1130d163575Sopenharmony_ci 1140d163575Sopenharmony_ciextern VOID TaskHold(UINT64 sec); 1150d163575Sopenharmony_ci 1160d163575Sopenharmony_ciextern UINT32 TaskCountGetTest(VOID); 1170d163575Sopenharmony_ciextern UINT32 Sem_Count_Get_Test(VOID); 1180d163575Sopenharmony_ciextern UINT32 QueueCountGetTest(VOID); 1190d163575Sopenharmony_ciextern UINT32 Swtmr_Count_Get_Test(VOID); 1200d163575Sopenharmony_ciextern void hal_interrupt_set_affinity(uint32_t irq, uint32_t cpuMask); 1210d163575Sopenharmony_ci 1220d163575Sopenharmony_ci#define TASK_EXISTED_NUM (TaskCountGetTest()) 1230d163575Sopenharmony_ci#define QUEUE_EXISTED_NUM (QueueCountGetTest()) 1240d163575Sopenharmony_ci#define SWTMR_EXISTED_NUM (Swtmr_Count_Get_Test()) 1250d163575Sopenharmony_ci#define SEM_EXISTED_NUM (Sem_Count_Get_Test()) 1260d163575Sopenharmony_ci 1270d163575Sopenharmony_ciextern void TEST_TEST_HwiDelete(unsigned int irq, void *dev_id); 1280d163575Sopenharmony_ciextern void TEST_HwiTrigger(unsigned int irq); 1290d163575Sopenharmony_ciextern void TestExtraTaskDelay(UINT32 tick); 1300d163575Sopenharmony_ciextern UINT64 TestTickCountGet(void); 1310d163575Sopenharmony_ciextern UINT64 TestTickCountByCurrCpuid(void); 1320d163575Sopenharmony_ciextern void TestBusyTaskDelay(UINT32 tick); 1330d163575Sopenharmony_ciextern void *malloc(size_t size); 1340d163575Sopenharmony_ciextern void TEST_DumpCpuid(void); 1350d163575Sopenharmony_ciextern u_long T_random(void); 1360d163575Sopenharmony_ciextern VOID TestAssertWaitDelay(UINT32 *testCount, UINT32 flag); 1370d163575Sopenharmony_ci 1380d163575Sopenharmony_ciUINT32 LosTaskDelay(UINT32 tick); 1390d163575Sopenharmony_ci#define TEST_HwiDelete(ID) TEST_TEST_HwiDelete(ID, NULL) 1400d163575Sopenharmony_ci#define TEST_HwiClear(ID) HalIrqMask(ID) 1410d163575Sopenharmony_ci#define TEST_HwiTriggerDelay LosTaskDelay(200 * LOSCFG_BASE_CORE_TICK_PER_SECOND / 1000) 1420d163575Sopenharmony_ci#define TEST_HwiCreate(ID, prio, mode, Func, arg) LOS_HwiCreate(ID, prio, mode, Func, arg) 1430d163575Sopenharmony_ci 1440d163575Sopenharmony_ci#if HUAWEI_ENV_NFS 1450d163575Sopenharmony_ci#define NFS_MOUNT_DIR "/nfs" 1460d163575Sopenharmony_ci#define NFS_MAIN_DIR NFS_MOUNT_DIR 1470d163575Sopenharmony_ci#define NFS_PATH_NAME "/nfs/test" 1480d163575Sopenharmony_ci#else 1490d163575Sopenharmony_ci#define NFS_MOUNT_DIR "/nfs" 1500d163575Sopenharmony_ci#define NFS_MAIN_DIR NFS_MOUNT_DIR 1510d163575Sopenharmony_ci#define NFS_PATH_NAME "/nfs/test" 1520d163575Sopenharmony_ci#endif 1530d163575Sopenharmony_ci 1540d163575Sopenharmony_ci#define WIN_MOUNT_PATH "/nfs" 1550d163575Sopenharmony_ci#define WIN_NFS_MOUNT_DIR WIN_MOUNT_PATH 1560d163575Sopenharmony_ci#define WIN_NFS_MAIN_DIR WIN_NFS_MOUNT_DIR 1570d163575Sopenharmony_ci#define WIN_NFS_PATH_NAME "/nfs/test" 1580d163575Sopenharmony_ci 1590d163575Sopenharmony_ci#define HWI_NUM_INT0 0 1600d163575Sopenharmony_ci#define HWI_NUM_INT1 1 1610d163575Sopenharmony_ci#define HWI_NUM_INT2 2 1620d163575Sopenharmony_ci#define HWI_NUM_INT3 3 1630d163575Sopenharmony_ci#define HWI_NUM_INT4 4 1640d163575Sopenharmony_ci#define HWI_NUM_INT5 5 1650d163575Sopenharmony_ci#define HWI_NUM_INT6 6 1660d163575Sopenharmony_ci#define HWI_NUM_INT7 7 1670d163575Sopenharmony_ci#define HWI_NUM_INT11 11 1680d163575Sopenharmony_ci#define HWI_NUM_INT12 12 1690d163575Sopenharmony_ci#define HWI_NUM_INT13 13 1700d163575Sopenharmony_ci#define HWI_NUM_INT14 14 1710d163575Sopenharmony_ci#define HWI_NUM_INT15 15 1720d163575Sopenharmony_ci#define HWI_NUM_INT16 16 1730d163575Sopenharmony_ci#define HWI_NUM_INT17 17 1740d163575Sopenharmony_ci#define HWI_NUM_INT18 18 1750d163575Sopenharmony_ci#define HWI_NUM_INT19 19 1760d163575Sopenharmony_ci#define HWI_NUM_INT21 21 1770d163575Sopenharmony_ci#define HWI_NUM_INT22 22 1780d163575Sopenharmony_ci#define HWI_NUM_INT23 23 1790d163575Sopenharmony_ci#define HWI_NUM_INT24 24 1800d163575Sopenharmony_ci#define HWI_NUM_INT25 25 1810d163575Sopenharmony_ci#define HWI_NUM_INT26 26 1820d163575Sopenharmony_ci#define HWI_NUM_INT27 27 1830d163575Sopenharmony_ci#define HWI_NUM_INT28 28 1840d163575Sopenharmony_ci#define HWI_NUM_INT30 30 1850d163575Sopenharmony_ci#define HWI_NUM_INT31 31 1860d163575Sopenharmony_ci#define HWI_NUM_INT32 32 1870d163575Sopenharmony_ci#define HWI_NUM_INT33 33 1880d163575Sopenharmony_ci#define HWI_NUM_INT34 34 1890d163575Sopenharmony_ci#define HWI_NUM_INT35 35 1900d163575Sopenharmony_ci#define HWI_NUM_INT42 42 1910d163575Sopenharmony_ci#define HWI_NUM_INT45 45 1920d163575Sopenharmony_ci#define HWI_NUM_INT46 46 1930d163575Sopenharmony_ci#define HWI_NUM_INT50 50 1940d163575Sopenharmony_ci#define HWI_NUM_INT55 55 1950d163575Sopenharmony_ci#define HWI_NUM_INT56 56 1960d163575Sopenharmony_ci#define HWI_NUM_INT57 57 1970d163575Sopenharmony_ci#define HWI_NUM_INT58 58 1980d163575Sopenharmony_ci#define HWI_NUM_INT59 59 1990d163575Sopenharmony_ci#define HWI_NUM_INT60 60 2000d163575Sopenharmony_ci#define HWI_NUM_INT61 61 2010d163575Sopenharmony_ci#define HWI_NUM_INT63 63 2020d163575Sopenharmony_ci#define HWI_NUM_INT62 62 2030d163575Sopenharmony_ci#define HWI_NUM_INT68 68 2040d163575Sopenharmony_ci#define HWI_NUM_INT69 69 2050d163575Sopenharmony_ci 2060d163575Sopenharmony_ci#define HWI_NUM_INT95 95 2070d163575Sopenharmony_ci#define HWI_NUM_INT114 114 2080d163575Sopenharmony_ci#define HWI_NUM_INT169 169 2090d163575Sopenharmony_ci 2100d163575Sopenharmony_ci#if defined TESTPBXA9 2110d163575Sopenharmony_ci#define HWI_NUM_TEST HWI_NUM_INT56 2120d163575Sopenharmony_ci#define HWI_NUM_TEST1 HWI_NUM_INT57 2130d163575Sopenharmony_ci#define HWI_NUM_TEST0 HWI_NUM_INT58 2140d163575Sopenharmony_ci#define HWI_NUM_TEST2 HWI_NUM_INT59 2150d163575Sopenharmony_ci#define HWI_NUM_TEST3 HWI_NUM_INT60 2160d163575Sopenharmony_ci#elif defined TEST3518EV300 2170d163575Sopenharmony_ci#define HWI_NUM_TEST0 HWI_NUM_INT58 2180d163575Sopenharmony_ci#define HWI_NUM_TEST HWI_NUM_INT59 2190d163575Sopenharmony_ci#define HWI_NUM_TEST1 HWI_NUM_INT60 2200d163575Sopenharmony_ci#define HWI_NUM_TEST2 HWI_NUM_INT61 2210d163575Sopenharmony_ci#define HWI_NUM_TEST3 HWI_NUM_INT68 2220d163575Sopenharmony_ci#elif defined TEST3516DV300 2230d163575Sopenharmony_ci#define HWI_NUM_TEST HWI_NUM_INT56 2240d163575Sopenharmony_ci#define HWI_NUM_TEST1 HWI_NUM_INT57 2250d163575Sopenharmony_ci#define HWI_NUM_TEST0 HWI_NUM_INT58 2260d163575Sopenharmony_ci#define HWI_NUM_TEST2 HWI_NUM_INT59 2270d163575Sopenharmony_ci#define HWI_NUM_TEST3 HWI_NUM_INT60 2280d163575Sopenharmony_ci#endif 2290d163575Sopenharmony_ci 2300d163575Sopenharmony_ci#define TEST_TASKDELAY_1TICK 1 2310d163575Sopenharmony_ci#define TEST_TASKDELAY_2TICK 2 2320d163575Sopenharmony_ci#define TEST_TASKDELAY_4TICK 4 2330d163575Sopenharmony_ci#define TEST_TASKDELAY_10TICK 10 2340d163575Sopenharmony_ci#define TEST_TASKDELAY_20TICK 20 2350d163575Sopenharmony_ci#define TEST_TASKDELAY_50TICK 50 2360d163575Sopenharmony_ci 2370d163575Sopenharmony_ci#define uart_printf_func printf 2380d163575Sopenharmony_ci 2390d163575Sopenharmony_ci#ifndef VFS_STAT_PRINTF 2400d163575Sopenharmony_ci#define VFS_STAT_PRINTF 0 2410d163575Sopenharmony_ci#endif 2420d163575Sopenharmony_ci 2430d163575Sopenharmony_ci#ifndef VFS_STATFS_PRINTF 2440d163575Sopenharmony_ci#define VFS_STATFS_PRINTF 0 2450d163575Sopenharmony_ci#endif 2460d163575Sopenharmony_ci 2470d163575Sopenharmony_ci#define OPEN_FILE_MAX 20 2480d163575Sopenharmony_ci 2490d163575Sopenharmony_ci#define HUAWEI_ENV_NFS 0 2500d163575Sopenharmony_ci 2510d163575Sopenharmony_ci#ifndef TEST_RESOURCELEAK_CHECK 2520d163575Sopenharmony_ci#define TEST_RESOURCELEAK_CHECK 1 2530d163575Sopenharmony_ci#endif 2540d163575Sopenharmony_ci 2550d163575Sopenharmony_ci#ifndef TEST_MODULE_CHECK 2560d163575Sopenharmony_ci#define TEST_MODULE_CHECK 1 2570d163575Sopenharmony_ci#endif 2580d163575Sopenharmony_ci 2590d163575Sopenharmony_ciextern UINT32 g_shellTestQueueID; 2600d163575Sopenharmony_ciextern UINT32 g_testCount; 2610d163575Sopenharmony_ciextern UINT32 g_testCount1; 2620d163575Sopenharmony_ciextern UINT32 g_testCount2; 2630d163575Sopenharmony_ciextern UINT32 g_testCount3; 2640d163575Sopenharmony_ciextern UINT32 g_flowcheck; 2650d163575Sopenharmony_ciextern UINT32 g_failResult; 2660d163575Sopenharmony_ciextern UINT32 g_passResult; 2670d163575Sopenharmony_ciextern UINT32 g_testTskHandle; 2680d163575Sopenharmony_ciextern UINT32 g_testTaskID01; 2690d163575Sopenharmony_ciextern UINT32 g_testTaskID02; 2700d163575Sopenharmony_ciextern UINT32 g_testTaskID03; 2710d163575Sopenharmony_ciextern UINT32 g_testTaskID04; 2720d163575Sopenharmony_ciextern UINT32 g_hwiNum1; 2730d163575Sopenharmony_ciextern UINT32 g_hwiNum2; 2740d163575Sopenharmony_ciextern UINT32 g_semID; 2750d163575Sopenharmony_ciextern UINT32 g_semID2; 2760d163575Sopenharmony_ciextern UINT32 g_mutexTest; 2770d163575Sopenharmony_ciextern UINT32 g_cpupTestCount; 2780d163575Sopenharmony_ciextern UINT16 g_swTmrID; 2790d163575Sopenharmony_ciextern UINT32 g_semID; 2800d163575Sopenharmony_ciextern UINT32 g_testQueueID01; 2810d163575Sopenharmony_ciextern UINT32 g_testQueueID02; 2820d163575Sopenharmony_ciextern UINT32 g_testQueueID03; 2830d163575Sopenharmony_ciextern UINT32 g_testTskHandle; 2840d163575Sopenharmony_ciextern UINT32 g_leavingTaskNum; 2850d163575Sopenharmony_ciextern UINT32 g_mAuwTestTaskID[32]; 2860d163575Sopenharmony_ciextern UINT8 g_mUsIndex; 2870d163575Sopenharmony_ciextern UINT32 g_usSemID3[]; 2880d163575Sopenharmony_ciextern UINT32 g_testPeriod; 2890d163575Sopenharmony_ciextern BOOL g_isAddArray; 2900d163575Sopenharmony_ciextern BOOL g_isSpinorInit; 2910d163575Sopenharmony_ciextern BOOL g_isSdInit; 2920d163575Sopenharmony_ciextern UINT32 g_getTickConsume; 2930d163575Sopenharmony_ciextern UINT32 g_waitTestCount; 2940d163575Sopenharmony_ciextern INT32 g_libFilesystem; 2950d163575Sopenharmony_ci 2960d163575Sopenharmony_ciextern UINT32 GetTimer2Value(VOID); 2970d163575Sopenharmony_ciextern int hinand_erase(unsigned long start, unsigned long size); 2980d163575Sopenharmony_ci#define hispinor_erase(start, size) \ 2990d163575Sopenharmony_ci do { \ 3000d163575Sopenharmony_ci struct erase_info opts; \ 3010d163575Sopenharmony_ci struct mtd_info *pstMtd; \ 3020d163575Sopenharmony_ci pstMtd = get_mtd("spinor"); \ 3030d163575Sopenharmony_ci (void)memset_s(&opts, sizeof(opts), 0, sizeof(opts)); \ 3040d163575Sopenharmony_ci opts.addr = start; \ 3050d163575Sopenharmony_ci opts.len = size; \ 3060d163575Sopenharmony_ci pstMtd->erase(pstMtd, &opts); \ 3070d163575Sopenharmony_ci } while (0) 3080d163575Sopenharmony_ciextern void ipc_gmac_init(void); 3090d163575Sopenharmony_ci 3100d163575Sopenharmony_ciextern UINT32 Mem_Consume_Show(void); 3110d163575Sopenharmony_ciextern VOID shell_cmd_register(void); 3120d163575Sopenharmony_ciextern INT32 OsShellCmdSystemInfo(INT32 argc, const CHAR **argv); 3130d163575Sopenharmony_ciextern UINT32 OsShellCmdDumpTask(INT32 argc, const CHAR **argv); 3140d163575Sopenharmony_ciextern UINT32 OsShellCmdTaskCntGet(VOID); 3150d163575Sopenharmony_ciextern UINT32 OsShellCmdSwtmrCntGet(VOID); 3160d163575Sopenharmony_ciextern void msleep(unsigned int msecs); 3170d163575Sopenharmony_ciextern unsigned int sleep(unsigned int seconds); 3180d163575Sopenharmony_ciextern int usleep(unsigned useconds); 3190d163575Sopenharmony_ci 3200d163575Sopenharmony_ciextern VOID ipc_network_init(void); 3210d163575Sopenharmony_ci#ifdef LOSCFG_DRIVERS_MMC 3220d163575Sopenharmony_ciextern INT32 SD_MMC_Host_init(void); 3230d163575Sopenharmony_ci#endif 3240d163575Sopenharmony_ciextern VOID rdk_fs_init(void); 3250d163575Sopenharmony_ciextern VOID jffs2_fs_init(void); 3260d163575Sopenharmony_ciextern VOID ProcFsInit(void); 3270d163575Sopenharmony_ci 3280d163575Sopenharmony_ciextern UINT32 LOS_MemTotalUsedGet(VOID *pool); 3290d163575Sopenharmony_ciextern VOID ptestTickConsume(VOID); 3300d163575Sopenharmony_ciextern UINT32 TEST_TskDelete(UINT32 taskID); 3310d163575Sopenharmony_ciextern UINT32 TEST_SemDelete(UINT32 semHandle); 3320d163575Sopenharmony_ciextern VOID irq_trigger(unsigned int irq); 3330d163575Sopenharmony_ciextern VOID TestPartInit(char *type, UINT32 startAddr, UINT32 length); 3340d163575Sopenharmony_ciextern VOID TestPartDelete(char *type); 3350d163575Sopenharmony_ci 3360d163575Sopenharmony_ciextern VOID TestRunShell(VOID); 3370d163575Sopenharmony_ci 3380d163575Sopenharmony_ciextern VOID It_Usb_AutoTest(VOID); 3390d163575Sopenharmony_ciextern VOID Test_hid_dev_mode(VOID); 3400d163575Sopenharmony_ci 3410d163575Sopenharmony_ciextern UINT32 usbshell_cmd_reg(VOID); 3420d163575Sopenharmony_ciextern void usbshell_queue_control(VOID); 3430d163575Sopenharmony_ciextern UINT32 OsTestInit(VOID); 3440d163575Sopenharmony_ci 3450d163575Sopenharmony_ciextern void TEST_DT_COMMON(void); 3460d163575Sopenharmony_ci 3470d163575Sopenharmony_ciextern void it_process_testcase(void); 3480d163575Sopenharmony_ciextern void it_pthread_testcase(void); 3490d163575Sopenharmony_ciextern void it_mutex_test(void); 3500d163575Sopenharmony_ciextern void it_rwlock_test(void); 3510d163575Sopenharmony_ciextern void it_spinlock_test(void); 3520d163575Sopenharmony_ci 3530d163575Sopenharmony_ci/* Format options (3rd argument of f_mkfs) */ 3540d163575Sopenharmony_ci#define TEST_FM_FAT 0x01 3550d163575Sopenharmony_ci#define TEST_FM_FAT32 0x02 3560d163575Sopenharmony_ci#define TEST_FM_EXFAT 0x04 3570d163575Sopenharmony_ci#define TEST_FM_ANY 0x07 3580d163575Sopenharmony_ci#define TEST_FM_SFD 0x08 3590d163575Sopenharmony_ci 3600d163575Sopenharmony_ci#define BIG_FD 512 3610d163575Sopenharmony_citypedef struct testrunParam { 3620d163575Sopenharmony_ci CHAR testcase_sequence[16]; 3630d163575Sopenharmony_ci CHAR testcase_num[16]; 3640d163575Sopenharmony_ci CHAR testcase_layer[32]; 3650d163575Sopenharmony_ci CHAR testcase_module[32]; 3660d163575Sopenharmony_ci CHAR testcase_level[16]; 3670d163575Sopenharmony_ci CHAR testcase_type[16]; 3680d163575Sopenharmony_ci CHAR testcase_id[128]; 3690d163575Sopenharmony_ci} TEST_RUN_PARAM; 3700d163575Sopenharmony_ci 3710d163575Sopenharmony_citypedef enum test_type { 3720d163575Sopenharmony_ci HOST_U, // USB U PERFORMANCE 3730d163575Sopenharmony_ci HOST_MUTIL, // MUTIL 3740d163575Sopenharmony_ci HOST_DISK, // USB DISKPARTION 3750d163575Sopenharmony_ci HOST_HUB, // USB HUB 3760d163575Sopenharmony_ci HOST_ETH, // USB HOST ETH 3770d163575Sopenharmony_ci USB_SMP, 3780d163575Sopenharmony_ci HOST_UVC, // USB HOST UVC 3790d163575Sopenharmony_ci HOST_NULL 3800d163575Sopenharmony_ci} usb_test_type; 3810d163575Sopenharmony_ci 3820d163575Sopenharmony_ci 3830d163575Sopenharmony_ci#define SHELLTEST_QUEUE_BUFSIZE sizeof(TEST_RUN_PARAM) 3840d163575Sopenharmony_ci#ifdef LOSCFG_DRIVERS_USB 3850d163575Sopenharmony_ci 3860d163575Sopenharmony_civoid Test_usb_shellcmd(controller_type ctype, device_type dtype, usb_test_type typetest); 3870d163575Sopenharmony_ci#endif 3880d163575Sopenharmony_ci 3890d163575Sopenharmony_ciextern int Gettid(void); 3900d163575Sopenharmony_ci 3910d163575Sopenharmony_ci/* like the ctime/asctime api, use static buffer, though not thread-safe. */ 3920d163575Sopenharmony_cistatic inline const char *Curtime() 3930d163575Sopenharmony_ci{ 3940d163575Sopenharmony_ci struct timespec ts; 3950d163575Sopenharmony_ci struct tm t; 3960d163575Sopenharmony_ci static char buf[32]; 3970d163575Sopenharmony_ci (void)clock_gettime(CLOCK_REALTIME, &ts); 3980d163575Sopenharmony_ci (void)localtime_r(&ts.tv_sec, &t); 3990d163575Sopenharmony_ci (void)sprintf_s(buf, sizeof(buf), "%d-%02d-%02d %02d:%02d:%02d.%06ld", t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, 4000d163575Sopenharmony_ci t.tm_min, t.tm_sec, ts.tv_nsec / 1000); 4010d163575Sopenharmony_ci return buf; 4020d163575Sopenharmony_ci} 4030d163575Sopenharmony_ci 4040d163575Sopenharmony_ci#define LogPrintln(fmt, ...) \ 4050d163575Sopenharmony_ci printf("%s [%d] %s:%d " fmt "%c", Curtime(), Gettid(), __FILE__, __LINE__, ##__VA_ARGS__, \ 4060d163575Sopenharmony_ci ('\n' == " " fmt[sizeof(" " fmt) - 2]) ? '\0' : '\n') // trailing newline is auto appended 4070d163575Sopenharmony_ci 4080d163575Sopenharmony_ci#if !_REDIR_TIME64 || defined(__LP64__) 4090d163575Sopenharmony_ci#define TIME_F "ld" 4100d163575Sopenharmony_ci#else 4110d163575Sopenharmony_ci#define TIME_F "lld" 4120d163575Sopenharmony_ci#endif 4130d163575Sopenharmony_ci 4140d163575Sopenharmony_cistatic void noprintf (...) 4150d163575Sopenharmony_ci{ 4160d163575Sopenharmony_ci return; 4170d163575Sopenharmony_ci} 4180d163575Sopenharmony_ci#define TEST_PRINT printf 4190d163575Sopenharmony_ci 4200d163575Sopenharmony_ci/* the files with different access privilege used in testcases are define below */ 4210d163575Sopenharmony_ci#define FILEPATH_ENOENT "/storage/test_nosuchfile.txt" 4220d163575Sopenharmony_ci#define FILEPATHLEN_ENOENT (strlen(FILEPATH_ENOENT) +1U) 4230d163575Sopenharmony_ci 4240d163575Sopenharmony_ci#define FILEPATH_NOACCESS "noaccessssssssssssssssssssssssssssssssssssssssssss" 4250d163575Sopenharmony_ci#define FILEPATHLEN_NOACCESS (strlen(FILEPATH_NOACCESS) +1U) 4260d163575Sopenharmony_ci 4270d163575Sopenharmony_ci#define FILEPATH_000 "/storage/test_000.txt" 4280d163575Sopenharmony_ci#define FILEPATHLEN_000 (strlen(FILEPATH_000) +1U) 4290d163575Sopenharmony_ci 4300d163575Sopenharmony_ci#define FILEPATH_775 "/storage/test_775.txt" 4310d163575Sopenharmony_ci#define FILEPATHLEN_775 (strlen(FILEPATH_775) +1U) 4320d163575Sopenharmony_ci 4330d163575Sopenharmony_ci#define FILEPATH_755 "/storage/test_775.txt" 4340d163575Sopenharmony_ci#define FILEPATHLEN_755 (strlen(FILEPATH_755) +1U) 4350d163575Sopenharmony_ci 4360d163575Sopenharmony_ci#define FILEPATH_RELATIVE "./1.txt" 4370d163575Sopenharmony_ci#define FILEPATHLEN_RELATIVE (strlen(FILEPATH_RELATIVE) +1U) 4380d163575Sopenharmony_ci 4390d163575Sopenharmony_ci#define DIRPATH_775 "/storage" 4400d163575Sopenharmony_ci 4410d163575Sopenharmony_ci#define FD_EBADF 513 4420d163575Sopenharmony_ci#define FD_EFAULT -1000 4430d163575Sopenharmony_ci 4440d163575Sopenharmony_ci#define PATHNAME_ENAMETOOLONG "ENAMETOOLONG12345678912345678912345678912345678912345678912345678912345678911111\ 4450d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4460d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4470d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4480d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4490d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4500d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4510d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4520d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4530d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4540d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4550d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4560d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4570d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4580d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4590d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4600d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4610d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4620d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4630d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4640d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4650d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4660d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4670d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4680d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4690d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4700d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4710d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4720d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4730d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4740d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4750d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4760d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4770d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4780d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4790d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4800d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4810d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4820d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4830d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4840d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4850d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4860d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4870d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4880d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4890d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4900d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4910d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4920d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4930d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4940d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4950d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789\ 4960d163575Sopenharmony_ci12345678912345678912345678913245678912345678912345678913245678913456789123456789" 4970d163575Sopenharmony_ci 4980d163575Sopenharmony_ci#endif /* _OSTEST_H */ 499