Compare commits
10 Commits
weekly_202
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7688a3f52d | ||
|
|
590ab9182d | ||
|
|
ed863e90dd | ||
|
|
491cefae76 | ||
|
|
36887d467d | ||
|
|
9f393bcc6d | ||
|
|
fe4db41b7c | ||
|
|
5c982f1087 | ||
|
|
9a3745384a | ||
|
|
0245b1a7b2 |
@@ -1475,6 +1475,110 @@ OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t fatfs_pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
INT32 ret;
|
||||
off_t savepos, pos;
|
||||
|
||||
if (buf == NULL) {
|
||||
errno = EFAULT;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
ret = FsLock();
|
||||
if (ret != 0) {
|
||||
errno = ret;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
if (!IsValidFd(fd)) {
|
||||
FsUnlock();
|
||||
errno = EBADF;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
savepos = (off_t)fatfs_lseek(fd, 0, SEEK_CUR);
|
||||
if (savepos == (off_t)-1) {
|
||||
errno = FatfsErrno(savepos);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
pos = (off_t)fatfs_lseek(fd, offset, SEEK_SET);
|
||||
if (pos == (off_t)-1) {
|
||||
errno = FatfsErrno(pos);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
ret = fatfs_read(fd, buf, nbyte);
|
||||
if (ret < 0) {
|
||||
FsUnlock();
|
||||
errno = FatfsErrno(ret);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
pos = (off_t)fatfs_lseek(fd, savepos, SEEK_SET);
|
||||
if ((pos == (off_t)-1) && (ret >= 0)) {
|
||||
errno = FatfsErrno(pos);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
FsUnlock();
|
||||
|
||||
return (ssize_t)ret;
|
||||
}
|
||||
|
||||
ssize_t fatfs_pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
INT32 ret;
|
||||
off_t savepos, pos;
|
||||
|
||||
if (buf == NULL) {
|
||||
errno = EFAULT;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
ret = FsLock();
|
||||
if (ret != 0) {
|
||||
errno = ret;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
if (!IsValidFd(fd)) {
|
||||
FsUnlock();
|
||||
errno = EBADF;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
savepos = (off_t)fatfs_lseek(fd, 0, SEEK_CUR);
|
||||
if (savepos == (off_t)-1) {
|
||||
errno = FatfsErrno(savepos);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
pos = (off_t)fatfs_lseek(fd, offset, SEEK_SET);
|
||||
if (pos == (off_t)-1) {
|
||||
errno = FatfsErrno(pos);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
ret = fatfs_write(fd, buf, nbyte);
|
||||
if (ret < 0) {
|
||||
FsUnlock();
|
||||
errno = FatfsErrno(ret);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
pos = (off_t)fatfs_lseek(fd, savepos, SEEK_SET);
|
||||
if ((pos == (off_t)-1) && (ret >= 0)) {
|
||||
errno = FatfsErrno(pos);
|
||||
return FS_FAILURE;
|
||||
}
|
||||
|
||||
FsUnlock();
|
||||
|
||||
return (ssize_t)ret;
|
||||
}
|
||||
|
||||
struct MountOps g_fatfsMnt = {
|
||||
.Mount = fatfs_mount,
|
||||
.Umount = fatfs_umount,
|
||||
@@ -1498,4 +1602,6 @@ struct FileOps g_fatfsFops = {
|
||||
.Getattr = fatfs_stat,
|
||||
.Fsync = fatfs_fsync,
|
||||
.Fstat = fatfs_fstat,
|
||||
.Pread = fatfs_pread,
|
||||
.Pwrite = fatfs_pwrite,
|
||||
};
|
||||
|
||||
@@ -69,6 +69,8 @@ int fatfs_rmdir(const char *path);
|
||||
int fatfs_rename(const char *oldName, const char *newName);
|
||||
int fatfs_statfs(const char *path, struct statfs *buf);
|
||||
int fatfs_ftruncate(int fd, off_t length);
|
||||
ssize_t fatfs_pread(int fd, void *buf, size_t nbyte, off_t offset);
|
||||
ssize_t fatfs_pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
|
||||
|
||||
/**
|
||||
* @brief divide a physical drive (SD card, U disk, and MMC card), this function is OHOS-specific
|
||||
|
||||
@@ -323,6 +323,8 @@ const struct FileOps g_lfsFops = {
|
||||
.Getattr = LfsStat,
|
||||
.Fsync = LfsFsync,
|
||||
.Fstat = LfsFstat,
|
||||
.Pread = LfsPread,
|
||||
.Pwrite = LfsPwrite,
|
||||
};
|
||||
|
||||
int LfsMount(const char *source, const char *target, const char *fileSystemType, unsigned long mountflags,
|
||||
@@ -801,5 +803,89 @@ int LfsFstat(int fd, struct stat *buf)
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = VFS_ERROR;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LfsPread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
int ret;
|
||||
off_t savepos, pos;
|
||||
|
||||
if (buf == NULL) {
|
||||
errno = EFAULT;
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
if (LfsFdIsValid(fd) == FALSE) {
|
||||
errno = EBADF;
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
savepos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), 0, SEEK_CUR);
|
||||
if (savepos == (off_t)-1) {
|
||||
errno = LittlefsErrno(savepos);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, SEEK_SET);
|
||||
if (pos == (off_t)-1) {
|
||||
errno = LittlefsErrno(pos);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
ret = lfs_file_read(g_handle[fd].lfsHandle, &(g_handle[fd].file), buf, nbyte);
|
||||
if (ret < 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = VFS_ERROR;
|
||||
}
|
||||
|
||||
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), savepos, SEEK_SET);
|
||||
if ((pos == (off_t)-1) && (ret >= 0)) {
|
||||
errno = LittlefsErrno(pos);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LfsPwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
int ret;
|
||||
off_t savepos, pos;
|
||||
|
||||
if (buf == NULL) {
|
||||
errno = EFAULT;
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
if (LfsFdIsValid(fd) == FALSE) {
|
||||
errno = EBADF;
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
savepos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), 0, SEEK_CUR);
|
||||
if (savepos == (off_t)-1) {
|
||||
errno = LittlefsErrno(savepos);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), offset, SEEK_SET);
|
||||
if (pos == (off_t)-1) {
|
||||
errno = LittlefsErrno(pos);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
ret = lfs_file_write(g_handle[fd].lfsHandle, &(g_handle[fd].file), buf, nbyte);
|
||||
if (ret < 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = VFS_ERROR;
|
||||
}
|
||||
|
||||
pos = (off_t)lfs_file_seek(g_handle[fd].lfsHandle, &(g_handle[fd].file), savepos, SEEK_SET);
|
||||
if ((pos == (off_t)-1) && (ret >= 0)) {
|
||||
errno = LittlefsErrno(pos);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -97,6 +97,8 @@ int LfsStat(const char *path, struct stat *buf);
|
||||
int LfsFsync(int fd);
|
||||
int LfsFstat(int fd, struct stat *buf);
|
||||
int SetDefaultMountPath(int pathNameIndex, const char* target);
|
||||
int LfsPread(int fd, void *buf, size_t nbyte, off_t offset);
|
||||
int LfsPwrite(int fd, const void *buf, size_t nbyte, off_t offset);
|
||||
|
||||
#endif /* _LFS_API_H_ */
|
||||
|
||||
|
||||
@@ -75,6 +75,8 @@ struct FileOps {
|
||||
int (*Fstat)(int fd, struct stat *buf);
|
||||
int (*Stat)(const char *path, struct stat *buf);
|
||||
int (*Ftruncate)(int fd, off_t length);
|
||||
int (*Pread)(int fd, void *buf, size_t nbyte, off_t offset);
|
||||
int (*Pwrite)(int fd, const void *buf, size_t nbyte, off_t offset);
|
||||
};
|
||||
|
||||
#endif /* _FS_OPERATIONS_H_ */
|
||||
|
||||
@@ -595,3 +595,55 @@ int LOS_Ftruncate(int fd, off_t length)
|
||||
}
|
||||
return g_fs->fsFops->Ftruncate(fd, length);
|
||||
}
|
||||
|
||||
ssize_t LOS_Pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
if (fd == RANDOM_DEV_FD) {
|
||||
if (nbyte == 0) {
|
||||
return FS_SUCCESS;
|
||||
}
|
||||
if (buf == NULL) {
|
||||
errno = EINVAL;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
if (nbyte > 1024) { /* 1024, max random_size */
|
||||
nbyte = 1024; /* hks_generate_random: random_size must <= 1024 */
|
||||
}
|
||||
struct hks_blob key = {HKS_BLOB_TYPE_RAW, (uint8_t *)buf, nbyte};
|
||||
if (hks_generate_random(&key) != 0) {
|
||||
errno = EIO;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
return (ssize_t)nbyte;
|
||||
}
|
||||
#endif
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
if (g_fs->fsFops == NULL || g_fs->fsFops->Pread == NULL) {
|
||||
errno = ENOSYS;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
return g_fs->fsFops->Pread(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
ssize_t LOS_Pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
if (fd == RANDOM_DEV_FD) {
|
||||
errno = EBADF; /* "/dev/random" is readonly */
|
||||
return FS_FAILURE;
|
||||
}
|
||||
#endif
|
||||
if (g_fs == NULL) {
|
||||
errno = ENODEV;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
if (g_fs->fsFops == NULL || g_fs->fsFops->Pwrite == NULL) {
|
||||
errno = ENOSYS;
|
||||
return FS_FAILURE;
|
||||
}
|
||||
return g_fs->fsFops->Pwrite(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
@@ -92,6 +92,10 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data);
|
||||
|
||||
ssize_t LOS_Pread(int fd, void *buf, size_t nbyte, off_t offset);
|
||||
|
||||
ssize_t LOS_Pwrite(int fd, const void *buf, size_t nbyte, off_t offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -157,6 +157,7 @@ STATIC VOID ParseAndExecCmdline(CmdParsed *cmdParsed, const CHAR *cmdline, UINT3
|
||||
ret = ShellMsgTypeGet(cmdParsed, cmdName);
|
||||
if (ret != LOS_OK) {
|
||||
PRINTK("%s:command not found\n", cmdName);
|
||||
free(cmdName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,3 +144,13 @@ int ftruncate(int fd, off_t length)
|
||||
{
|
||||
return LOS_Ftruncate(fd, length);
|
||||
}
|
||||
|
||||
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pread(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pwrite(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
@@ -147,6 +147,16 @@ int ioctl(int fd, int req, ...)
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pread(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pwrite(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
#else /* #ifdef LOSCFG_FS_VFS */
|
||||
|
||||
int _open(const char *path, int oflag, ...)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "los_task.h"
|
||||
#include "los_interrupt.h"
|
||||
#include "los_tick.h"
|
||||
#include "los_sortlink.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -43,7 +44,7 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define OS_SCHED_MINI_PERIOD (g_sysClock / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
|
||||
#define OS_SCHED_MAX_RESPONSE_TIME (UINT64)(((UINT64)-1) - 1U)
|
||||
#define OS_SCHED_MAX_RESPONSE_TIME OS_SORT_LINK_UINT64_MAX
|
||||
|
||||
extern UINT32 g_taskScheduled;
|
||||
typedef BOOL (*SchedScan)(VOID);
|
||||
|
||||
@@ -668,7 +668,6 @@ LITE_OS_SEC_TEXT_INIT STATIC_INLINE UINT32 OsTaskInitParamCheck(TSK_INIT_PARAM_S
|
||||
if (taskInitParam->uwStackSize == 0) {
|
||||
taskInitParam->uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
}
|
||||
taskInitParam->uwStackSize = ALIGN(taskInitParam->uwStackSize, OS_TASK_STACK_ADDR_ALIGN);
|
||||
|
||||
if (taskInitParam->uwStackSize < LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE) {
|
||||
return LOS_ERRNO_TSK_STKSZ_TOO_SMALL;
|
||||
@@ -704,6 +703,7 @@ STATIC UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *taskInitParam)
|
||||
}
|
||||
|
||||
if (taskInitParam->stackAddr == (UINTPTR)NULL) {
|
||||
taskCB->stackSize = ALIGN(taskInitParam->uwStackSize, OS_TASK_STACK_ADDR_ALIGN);
|
||||
#if (LOSCFG_EXC_HARDWARE_STACK_PROTECTION == 1)
|
||||
UINT32 stackSize = taskCB->stackSize + OS_TASK_STACK_PROTECT_SIZE;
|
||||
UINTPTR stackPtr = (UINTPTR)LOS_MemAllocAlign(OS_TASK_STACK_ADDR, stackSize, OS_TASK_STACK_PROTECT_SIZE);
|
||||
@@ -718,7 +718,8 @@ STATIC UINT32 OsNewTaskInit(LosTaskCB *taskCB, TSK_INIT_PARAM_S *taskInitParam)
|
||||
taskCB->taskStatus |= OS_TASK_FLAG_STACK_FREE;
|
||||
} else {
|
||||
taskCB->topOfStack = LOS_Align(taskInitParam->stackAddr, LOSCFG_STACK_POINT_ALIGN_SIZE);
|
||||
taskCB->stackSize = ALIGN(taskCB->stackSize, OS_TASK_STACK_ADDR_ALIGN);
|
||||
taskCB->stackSize = taskInitParam->uwStackSize - (taskCB->topOfStack - taskInitParam->stackAddr);
|
||||
taskCB->stackSize = TRUNCATE(taskCB->stackSize, OS_TASK_STACK_ADDR_ALIGN);
|
||||
}
|
||||
|
||||
/* initialize the task stack, write magic num to stack top */
|
||||
|
||||
@@ -51,6 +51,7 @@ kernel_module("test_init") {
|
||||
group("testsuites") {
|
||||
deps = [
|
||||
":test_init",
|
||||
"sample/cmsis:test_cmsis",
|
||||
"sample/kernel/atomic:test_atomic",
|
||||
"sample/kernel/event:test_event",
|
||||
"sample/kernel/hwi:test_hwi",
|
||||
@@ -61,6 +62,7 @@ group("testsuites") {
|
||||
"sample/kernel/sem:test_sem",
|
||||
"sample/kernel/swtmr:test_swtmr",
|
||||
"sample/kernel/task:test_task",
|
||||
"sample/posix:test_posix",
|
||||
]
|
||||
if (defined(LOSCFG_DYNLINK)) {
|
||||
deps += [ "sample/kernel/dynlink:test_dynlink" ]
|
||||
|
||||
@@ -87,12 +87,17 @@ extern "C" {
|
||||
#define LOS_KERNEL_MEM_TEST 1
|
||||
#define LOS_KERNEL_DYNLINK_TEST 0
|
||||
#define LOS_KERNEL_TICKLESS_TEST 0
|
||||
#if (LOSCFG_KERNEL_PM == 1)
|
||||
#define LOS_KERNEL_PM_TEST 1
|
||||
#else
|
||||
#define LOS_KERNEL_PM_TEST 0
|
||||
#endif
|
||||
#define LOS_KERNEL_LMS_TEST 0
|
||||
#define LOS_KERNEL_LMK_TEST 0
|
||||
#define LOS_KERNEL_SIGNAL_TEST 0
|
||||
|
||||
#define LITEOS_CMSIS_TEST 0
|
||||
#define LOS_POSIX_TEST 1
|
||||
#define LOS_CMSIS_TEST 1
|
||||
#define LOS_CMSIS2_CORE_TASK_TEST 0
|
||||
#define LOS_CMSIS2_IPC_MUX_TEST 0
|
||||
#define LOS_CMSIS2_IPC_SEM_TEST 0
|
||||
@@ -349,6 +354,10 @@ extern VOID ItSuiteLosPm(void);
|
||||
extern VOID ItSuiteLosLmk(void);
|
||||
extern VOID ItSuiteLosSignal(void);
|
||||
|
||||
extern int PthreadFuncTestSuite(void);
|
||||
|
||||
extern void CmsisFuncTestSuite(void);
|
||||
|
||||
extern VOID ItSuite_Cmsis_Lostask(void);
|
||||
extern VOID ItSuite_Cmsis_Lostask_add(void);
|
||||
extern VOID ItSuite_CMSIS_Losmsg(void);
|
||||
|
||||
33
testsuites/sample/cmsis/BUILD.gn
Normal file
33
testsuites/sample/cmsis/BUILD.gn
Normal file
@@ -0,0 +1,33 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
static_library("test_cmsis") {
|
||||
sources = [ "cmsis_func_test.c" ]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuites:include" ]
|
||||
}
|
||||
84
testsuites/sample/cmsis/cmsis_func_test.c
Normal file
84
testsuites/sample/cmsis/cmsis_func_test.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <securec.h>
|
||||
#include "osTest.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
#define TEST_STR(func) ItLos##func
|
||||
#define TEST_TO_STR(x) #x
|
||||
#define TEST_HEAD_TO_STR(x) TEST_TO_STR(x)
|
||||
#define ADD_TEST_CASE(func) \
|
||||
TEST_ADD_CASE(TEST_HEAD_TO_STR(TEST_STR(func)), func, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION)
|
||||
|
||||
#define Function 0
|
||||
#define MediumTest 0
|
||||
#define Level1 0
|
||||
#define LITE_TEST_CASE(module, function, flag) static int function(void)
|
||||
|
||||
static VOID CmsisStackFunc01(void)
|
||||
{
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number : SUB_KERNEL_PTHREAD_OPERATION_001
|
||||
* @tc.name : event operation for join
|
||||
* @tc.desc : [C- SOFTWARE -0200]
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis001, Function | MediumTest | Level1)
|
||||
{
|
||||
osThreadId_t threadId;
|
||||
osThreadAttr_t attr = {0};
|
||||
|
||||
g_testCount = 0;
|
||||
|
||||
void *stackAddr = malloc(OS_TSK_TEST_STACK_SIZE);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(stackAddr, NULL, stackAddr);
|
||||
|
||||
attr.stack_mem = stackAddr;
|
||||
attr.stack_size = OS_TSK_TEST_STACK_SIZE;
|
||||
attr.priority = osPriorityNormal;
|
||||
attr.attr_bits = osThreadDetached;
|
||||
threadId = osThreadNew((osThreadFunc_t)CmsisStackFunc01, NULL, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(threadId, 0, threadId, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
EXIT:
|
||||
free(stackAddr);
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
void CmsisFuncTestSuite(void)
|
||||
{
|
||||
ADD_TEST_CASE(TestCmsis001);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ static UINT32 TestCase(VOID)
|
||||
g_testCount = 0;
|
||||
|
||||
osTaskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskDeatchf01;
|
||||
osTaskInitParam.uwStackSize = OS_TSK_TEST_STACK_SIZE;
|
||||
osTaskInitParam.uwStackSize = 0x1003; /* 0x1003: The size is not aligned */
|
||||
osTaskInitParam.pcName = "deatch";
|
||||
osTaskInitParam.usTaskPrio = TASK_PRIO_TEST - 5; /* 5: Relatively high priority */
|
||||
osTaskInitParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
|
||||
33
testsuites/sample/posix/BUILD.gn
Normal file
33
testsuites/sample/posix/BUILD.gn
Normal file
@@ -0,0 +1,33 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
static_library("test_posix") {
|
||||
sources = [ "pthread_func_test.c" ]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuites:include" ]
|
||||
}
|
||||
1066
testsuites/sample/posix/pthread_func_test.c
Normal file
1066
testsuites/sample/posix/pthread_func_test.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -214,15 +214,22 @@ void TestCmsis2(void)
|
||||
|
||||
VOID TestTaskEntry()
|
||||
{
|
||||
UINT32 ret;
|
||||
PRINTF("\t\n --- Test Start --- \n\n");
|
||||
ICunitInit();
|
||||
|
||||
TestKernel();
|
||||
|
||||
#if (CMSIS_OS_VER == 1)
|
||||
PRINTF("\n --- cmsis 1 unsupport--- \n\n");
|
||||
#elif (CMSIS_OS_VER == 2)
|
||||
TestCmsis2();
|
||||
#if (LOS_POSIX_TEST == 1)
|
||||
ret = PthreadFuncTestSuite();
|
||||
if (ret != 0) {
|
||||
PRINTF("PthreadFuncTestSuite start failed! errno: %u\n", ret);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (LOS_CMSIS_TEST == 1)
|
||||
CmsisFuncTestSuite();
|
||||
#endif
|
||||
|
||||
/* The log is used for testing entrance guard, please do not make any changes. */
|
||||
|
||||
@@ -516,8 +516,8 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime003, Function | MediumTes
|
||||
*/
|
||||
LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimes, Function | MediumTest | Level1)
|
||||
{
|
||||
const int testClockt = 100;
|
||||
const int msPerClock = 10;
|
||||
const int testClockt = LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
const int msPerClock = OS_SYS_MS_PER_SECOND / LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
struct tms start = { 0 };
|
||||
struct tms end = { 0 };
|
||||
clock_t stTime = times(&start);
|
||||
@@ -562,6 +562,6 @@ void PosixTimeFuncTest()
|
||||
RUN_ONE_TESTCASE(testTimeStrftime001);
|
||||
RUN_ONE_TESTCASE(testTimeStrftime002);
|
||||
RUN_ONE_TESTCASE(testTimeStrftime003);
|
||||
|
||||
RUN_ONE_TESTCASE(testTimes);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user