Compare commits
87 Commits
OpenHarmon
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f19fd2e7a | ||
|
|
c10037d379 | ||
|
|
b483627ec7 | ||
|
|
d120f1e57a | ||
|
|
765add9660 | ||
|
|
a650df0575 | ||
|
|
08436dec9e | ||
|
|
0818b28aa7 | ||
|
|
2dc3998956 | ||
|
|
266a49fb88 | ||
|
|
fa6f0c393d | ||
|
|
3019311435 | ||
|
|
b25148107b | ||
|
|
aee957bb1f | ||
|
|
64d15df9ea | ||
|
|
8e58b984ea | ||
|
|
be1267fafa | ||
|
|
6cb544b158 | ||
|
|
5e8225273f | ||
|
|
aec7a45411 | ||
|
|
2806c4af75 | ||
|
|
7e442ddd61 | ||
|
|
527cec6e27 | ||
|
|
d68b5f0ab3 | ||
|
|
1cd2ae7b4e | ||
|
|
27ed27eb89 | ||
|
|
098c5ea24d | ||
|
|
914913fab6 | ||
|
|
2f08268983 | ||
|
|
807c7e64cb | ||
|
|
fc87e459d1 | ||
|
|
c3d75f64b1 | ||
|
|
f447d15e78 | ||
|
|
642d5ef709 | ||
|
|
74bbfa4893 | ||
|
|
fe5a091ca2 | ||
|
|
c83b98ecbf | ||
|
|
c9a96bc4b3 | ||
|
|
62cd8fec46 | ||
|
|
8b54493665 | ||
|
|
a940dda69a | ||
|
|
1bc63d743b | ||
|
|
474201593d | ||
|
|
3f54fdc898 | ||
|
|
8ac6771e0d | ||
|
|
7101ddbeb8 | ||
|
|
abbed4430e | ||
|
|
98d20e90ed | ||
|
|
9767191392 | ||
|
|
e540254ed9 | ||
|
|
ad4ef11410 | ||
|
|
20ffd89865 | ||
|
|
ae8d4fd275 | ||
|
|
972d765c6e | ||
|
|
47f883c11a | ||
|
|
478b41b457 | ||
|
|
69d17d522c | ||
|
|
d4bfb577ef | ||
|
|
6e6cbe5de6 | ||
|
|
383a1d23e9 | ||
|
|
b24353cf4b | ||
|
|
f1ad086665 | ||
|
|
8fff50f59f | ||
|
|
373d4f5649 | ||
|
|
3c8d20a89e | ||
|
|
e268ef95a9 | ||
|
|
296a546bcd | ||
|
|
a7135e252d | ||
|
|
e76dd685c2 | ||
|
|
54a5365a25 | ||
|
|
2d1160fdc4 | ||
|
|
f3d606b6dd | ||
|
|
392e4c2cec | ||
|
|
b334658723 | ||
|
|
a502a0917c | ||
|
|
2b1f2d554e | ||
|
|
2cf290bb7c | ||
|
|
8fc9852e34 | ||
|
|
816d03f5c1 | ||
|
|
61877ec97a | ||
|
|
0f952132c0 | ||
|
|
f94d3ee119 | ||
|
|
1a764df92a | ||
|
|
cf50cde1b7 | ||
|
|
bfef7bfb2e | ||
|
|
5bae8b58c6 | ||
|
|
6377f98e9e |
18
Kconfig
18
Kconfig
@@ -335,6 +335,14 @@ config KERNEL_PM
|
||||
Configuration item for low power frame tailoring.
|
||||
If you wish to build LiteOS with support for power management.
|
||||
|
||||
config KERNEL_PM_IDLE
|
||||
bool "Enable Power Management Idle"
|
||||
default n
|
||||
depends on KERNEL_PM
|
||||
help
|
||||
Configuration item for low power frame tailoring.
|
||||
If you wish to build LiteOS with support for power management idle.
|
||||
|
||||
config KERNEL_PM_TASK_PTIORITY
|
||||
int "Power Management Task Priority"
|
||||
default 1
|
||||
@@ -513,6 +521,14 @@ config DEBUG_QUEUE
|
||||
help
|
||||
Answer Y to enable debug queue.
|
||||
|
||||
config MUTEX_CREATE_TRACE
|
||||
bool "Enable Mutex Trace Debugging"
|
||||
default n
|
||||
depends on ARCH_ARM
|
||||
depends on DEBUG_KERNEL
|
||||
help
|
||||
Answer Y to enable debug mutex trace.
|
||||
|
||||
config DEBUG_DEADLOCK
|
||||
bool "Enable Mutex Deadlock Debugging"
|
||||
default n
|
||||
@@ -601,7 +617,7 @@ config VM_OVERLAP_CHECK
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
help
|
||||
Answer Y to enable vm overlap check.
|
||||
|
||||
|
||||
config TASK_MEM_USED
|
||||
bool "Enable show task mem used or not"
|
||||
default n
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系统内核,具有小体积、低功耗、高性能的特点,其代码结构简单,主要包括内核最小功能集、内核抽象层、可选组件以及工程目录等,分为硬件相关层以及硬件无关层,硬件相关层提供统一的HAL(Hardware Abstraction Layer)接口,提升硬件易适配性,不同编译工具链和芯片架构的组合分类,满足AIoT类型丰富的硬件和编译工具链的拓展。其架构图如图1所示:
|
||||
|
||||
**图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
|
||||
**图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
|
||||

|
||||
|
||||
## 目录<a name="section161941989596"></a>
|
||||
@@ -77,7 +77,7 @@ LiteOS-M内核的编译构建系统是一个基于gn和ninja的组件化构建
|
||||
|
||||
### 搭建系统基础环境
|
||||
|
||||
在搭建各个开发板环境前,需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境,详细介绍请参考官方站点[开发环境准备](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md)。开发者需要根据环境搭建文档完成环境搭建。
|
||||
在搭建各个开发板环境前,需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境,详细介绍请参考官方站点[开发环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/Readme-CN.md)。开发者需要根据环境搭建文档完成环境搭建。
|
||||
|
||||
### 获取OpenHarmony源码
|
||||
|
||||
|
||||
47
arch/arm/cortex-m4/iar/BUILD.gn
Normal file
47
arch/arm/cortex-m4/iar/BUILD.gn
Normal file
@@ -0,0 +1,47 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-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.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
|
||||
module_name = "arch"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"los_context.c",
|
||||
"los_dispatch.S",
|
||||
"los_exc.S",
|
||||
"los_interrupt.c",
|
||||
"los_mpu.c",
|
||||
"los_timer.c",
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
@@ -62,6 +62,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
|
||||
__asm("mrs %0, msp" : "=r" (msp));
|
||||
return msp;
|
||||
}
|
||||
|
||||
STATIC INLINE UINTPTR ArchLRGet(VOID)
|
||||
{
|
||||
UINTPTR lr;
|
||||
__asm("mov %0, lr" : "=r" (lr));
|
||||
return lr;
|
||||
}
|
||||
#elif defined(__CLANG_ARM) || defined(__GNUC__)
|
||||
STATIC INLINE UINTPTR ArchSpGet(VOID)
|
||||
{
|
||||
@@ -83,6 +90,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
|
||||
__asm volatile("mrs %0, msp" : "=r" (msp));
|
||||
return msp;
|
||||
}
|
||||
|
||||
STATIC INLINE UINTPTR ArchLRGet(VOID)
|
||||
{
|
||||
UINTPTR lr;
|
||||
__asm volatile("mov %0, lr" : "=r" (lr));
|
||||
return lr;
|
||||
}
|
||||
#else
|
||||
/* Other platforms to be improved */
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -63,6 +63,9 @@
|
||||
#define RISCV_MIE_MEIE 0x000000800
|
||||
|
||||
/************************** mcause ***********************/
|
||||
#ifndef MCAUSE_INT_ID_MASK
|
||||
#define MCAUSE_INT_ID_MASK 0x7FFFFFF
|
||||
#endif
|
||||
#define RISCV_MCAUSE_ECALL_U 8
|
||||
|
||||
#define RISCV_USER_SOFT_IRQ 0
|
||||
@@ -72,7 +75,6 @@
|
||||
#define RISCV_USER_EXT_IRQ 8
|
||||
#define RISCV_MACH_EXT_IRQ 11
|
||||
|
||||
|
||||
#define READ_CSR(reg) ({ \
|
||||
UINT32 _tmp; \
|
||||
__asm__ volatile("csrr %0, " #reg : "=r"(_tmp) : : "memory"); \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -35,7 +35,7 @@
|
||||
#include "los_task.h"
|
||||
#include "los_sched.h"
|
||||
#include "los_memory.h"
|
||||
#include "soc.h"
|
||||
#include "soc_common.h"
|
||||
|
||||
STATIC UINT32 g_sysNeedSched = FALSE;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -29,7 +29,7 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "soc.h"
|
||||
#include "soc_common.h"
|
||||
|
||||
.global HalEnableIRQ
|
||||
.global HalDisableIRQ
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2020, Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -31,7 +31,7 @@
|
||||
|
||||
#ifndef _LOS_EXC_S
|
||||
#define _LOS_EXC_S
|
||||
#include "soc.h"
|
||||
#include "soc_common.h"
|
||||
|
||||
.macro PUSH_CALLER_REG
|
||||
addi sp, sp, -(32 * REGBYTES)
|
||||
@@ -139,8 +139,7 @@ HalTrapEntry:
|
||||
sw a0, 0 * REGBYTES(sp)
|
||||
csrr t0, mtval
|
||||
sw t0, 1 * REGBYTES(sp)
|
||||
csrr t0, medeleg
|
||||
sw t0, 2 * REGBYTES(sp)
|
||||
sw zero, 2 * REGBYTES(sp)
|
||||
sw gp, 3 * REGBYTES(sp)
|
||||
mv a0, sp
|
||||
csrw mscratch, sp
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "securec.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_debug.h"
|
||||
#include "cmsis_os2.h"
|
||||
#include "los_sched.h"
|
||||
#include "vfs_files.h"
|
||||
#include "vfs_operations.h"
|
||||
#include "vfs_partition.h"
|
||||
@@ -73,7 +73,7 @@ static int FsLock(void)
|
||||
{
|
||||
int ret = 0;
|
||||
struct timespec absTimeout = {0};
|
||||
if (osKernelGetState() != osKernelRunning) {
|
||||
if (!OsCheckKernelRunning()) {
|
||||
return ret;
|
||||
}
|
||||
ret = clock_gettime(CLOCK_REALTIME, &absTimeout);
|
||||
@@ -88,7 +88,7 @@ static int FsLock(void)
|
||||
|
||||
static void FsUnlock(void)
|
||||
{
|
||||
if (osKernelGetState() != osKernelRunning) {
|
||||
if (!OsCheckKernelRunning()) {
|
||||
return;
|
||||
}
|
||||
(void)pthread_mutex_unlock(&g_fatfsMutex);
|
||||
@@ -282,6 +282,12 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
if (mountflags & MS_REMOUNT) {
|
||||
ret = Remount(mp, mountflags);
|
||||
FsUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *ldPath = GetLdPath(mp->mDev);
|
||||
if (ldPath == NULL) {
|
||||
errno = EFAULT;
|
||||
@@ -289,11 +295,6 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
|
||||
goto ERROUT;
|
||||
}
|
||||
|
||||
if (mountflags & MS_REMOUNT) {
|
||||
ret = Remount(mp, mountflags);
|
||||
goto ERROUT;
|
||||
}
|
||||
|
||||
fs = (FATFS *)malloc(sizeof(FATFS));
|
||||
if (fs == NULL) {
|
||||
errno = ENOMEM;
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static struct PartitionCfg g_partitionCfg;
|
||||
static struct lfs_config g_lfsCfg;
|
||||
static struct DeviceDesc *g_lfsDevice = NULL;
|
||||
|
||||
static uint32_t LfsGetStartAddr(int partition)
|
||||
@@ -177,6 +176,7 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||
{
|
||||
int ret;
|
||||
lfs_t *mountHdl = NULL;
|
||||
struct lfs_config *cfg = NULL;
|
||||
|
||||
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
|
||||
errno = EFAULT;
|
||||
@@ -184,22 +184,29 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mountHdl = (lfs_t *)malloc(sizeof(lfs_t));
|
||||
if (mountflags & MS_REMOUNT) {
|
||||
errno = ENOSYS;
|
||||
ret = (int)LOS_NOK;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mountHdl = (lfs_t *)malloc(sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
if (mountHdl == NULL) {
|
||||
errno = ENODEV;
|
||||
ret = (int)LOS_NOK;
|
||||
goto errout;
|
||||
}
|
||||
(void)memset_s(mountHdl, sizeof(lfs_t), 0, sizeof(lfs_t));
|
||||
(void)memset_s(mountHdl, sizeof(lfs_t) + sizeof(struct lfs_config), 0, sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
mp->mData = (void *)mountHdl;
|
||||
cfg = (void *)((UINTPTR)mountHdl + sizeof(lfs_t));
|
||||
|
||||
LfsConfigAdapter((struct PartitionCfg *)data, &g_lfsCfg);
|
||||
LfsConfigAdapter((struct PartitionCfg *)data, cfg);
|
||||
|
||||
ret = lfs_mount((lfs_t *)mp->mData, &g_lfsCfg);
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
if (ret != 0) {
|
||||
ret = lfs_format((lfs_t *)mp->mData, &g_lfsCfg);
|
||||
ret = lfs_format((lfs_t *)mp->mData, cfg);
|
||||
if (ret == 0) {
|
||||
ret = lfs_mount((lfs_t *)mp->mData, &g_lfsCfg);
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
}
|
||||
}
|
||||
if (ret != 0) {
|
||||
@@ -655,12 +662,13 @@ int LfsFormat(const char *partName, void *privData)
|
||||
{
|
||||
int ret;
|
||||
lfs_t lfs = {0};
|
||||
struct lfs_config cfg = {0};
|
||||
|
||||
(void)partName;
|
||||
|
||||
LfsConfigAdapter((struct PartitionCfg *)privData, &g_lfsCfg);
|
||||
LfsConfigAdapter((struct PartitionCfg *)privData, &cfg);
|
||||
|
||||
ret = lfs_format(&lfs, &g_lfsCfg);
|
||||
ret = lfs_format(&lfs, &cfg);
|
||||
if (ret != 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = (int)LOS_NOK;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
static struct File g_files[NR_OPEN_DEFAULT];
|
||||
|
||||
int FileToFd(struct File *file)
|
||||
int FileToFd(const struct File *file)
|
||||
{
|
||||
if (file == NULL) {
|
||||
return (int)LOS_NOK;
|
||||
|
||||
@@ -89,7 +89,7 @@ struct Dir {
|
||||
void *dData;
|
||||
};
|
||||
|
||||
int FileToFd(struct File *file);
|
||||
int FileToFd(const struct File *file);
|
||||
struct File *FdToFile(int fd);
|
||||
struct File *VfsFileGet(void);
|
||||
struct File *VfsFileGetSpec(int fd);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "fcntl.h"
|
||||
#include "los_mux.h"
|
||||
#include "los_debug.h"
|
||||
#include "los_sched.h"
|
||||
#include "limits.h"
|
||||
#include "securec.h"
|
||||
#include "vfs_config.h"
|
||||
@@ -96,6 +97,9 @@ UINT32 g_fsMutex;
|
||||
|
||||
int VfsLock(void)
|
||||
{
|
||||
if (!OsCheckKernelRunning()) {
|
||||
return LOS_OK;
|
||||
}
|
||||
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
|
||||
PRINT_ERR("VfsLock failed!");
|
||||
return (int)LOS_NOK;
|
||||
@@ -106,6 +110,9 @@ int VfsLock(void)
|
||||
|
||||
void VfsUnlock(void)
|
||||
{
|
||||
if (!OsCheckKernelRunning()) {
|
||||
return;
|
||||
}
|
||||
(void)LOS_MuxPost(g_fsMutex);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "vfs_config.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "errno.h"
|
||||
#include "vfs_operations.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_debug.h"
|
||||
@@ -122,14 +123,66 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
|
||||
return bestMp;
|
||||
}
|
||||
|
||||
STATIC struct MountPoint *VfsMountPointInit(const char *target, const char *fsType, unsigned long mountflags)
|
||||
{
|
||||
struct MountPoint *mp = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
struct FsMap *mFs = NULL;
|
||||
|
||||
/* find mp by target, to see if it was mounted */
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if (mp != NULL && pathInMp != NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find fsMap coresponding to the fsType */
|
||||
mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
|
||||
if (mp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mp->mFs = mFs;
|
||||
mp->mDev = NULL;
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
mp->mNext = g_mountPoints;
|
||||
|
||||
return mp;
|
||||
}
|
||||
|
||||
STATIC int VfsRemount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
(VOID)source;
|
||||
(VOID)fsType;
|
||||
struct MountPoint *mp;
|
||||
|
||||
mp = VfsMpFind(target, NULL);
|
||||
if (mp == NULL) {
|
||||
errno = EINVAL;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
LOS_ASSERT(mp->mFs != NULL);
|
||||
LOS_ASSERT(mp->mFs->fsMops != NULL);
|
||||
LOS_ASSERT(mp->mFs->fsMops->mount != NULL);
|
||||
|
||||
return mp->mFs->fsMops->mount(mp, mountflags, data);
|
||||
}
|
||||
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
int ret;
|
||||
struct MountPoint *mp = NULL;
|
||||
struct FsMap *mFs = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
|
||||
/* target must begin with '/', for example /system, /data, etc. */
|
||||
if ((target == NULL) || (target[0] != '/')) {
|
||||
@@ -137,29 +190,25 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
}
|
||||
|
||||
(void)VfsLock();
|
||||
/* find mp by target, to see if it was mounted */
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if (mp != NULL && pathInMp != NULL) {
|
||||
goto errout;
|
||||
|
||||
if (mountflags & MS_REMOUNT) {
|
||||
ret = VfsRemount(source, target, fsType, mountflags, data);
|
||||
VfsUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Find fsMap coresponding to the fsType */
|
||||
mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
|
||||
mp = VfsMountPointInit(target, fsType, mountflags);
|
||||
if (mp == NULL) {
|
||||
goto errout;
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
mp->mFs = mFs;
|
||||
mp->mDev = NULL;
|
||||
if (source != NULL) {
|
||||
mp->mDev = strdup(source);
|
||||
if (mp->mDev == NULL) {
|
||||
goto errout;
|
||||
free(mp);
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,10 +223,7 @@ int LOS_FsMount(const char *source, const char *target,
|
||||
PRINT_ERR("mount failed, target %s.\n", target);
|
||||
goto errout;
|
||||
}
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
mp->mNext = g_mountPoints;
|
||||
|
||||
g_mountPoints = mp;
|
||||
VfsUnlock();
|
||||
return LOS_OK;
|
||||
@@ -233,7 +279,7 @@ errout:
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
static void CloseFdsInMp(struct MountPoint *mp)
|
||||
static void CloseFdsInMp(const struct MountPoint *mp)
|
||||
{
|
||||
for (int fd = 0; fd < NR_OPEN_DEFAULT; fd++) {
|
||||
struct File *f = FdToFile(fd);
|
||||
|
||||
@@ -160,8 +160,7 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
|
||||
format is not allowed when the device has been mounted. */
|
||||
struct MountPoint *iter = NULL;
|
||||
LOS_MP_FOR_EACH_ENTRY(iter) {
|
||||
if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) &&
|
||||
strcmp(iter->mFs->fsType, fsType) == 0) {
|
||||
if ((iter->mPath != NULL) && (strcmp(iter->mPath, partName) == 0)) {
|
||||
errno = EBUSY;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
@@ -240,4 +240,7 @@
|
||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||
#endif
|
||||
|
||||
#define LWIP_SOCKET_IOCTL 0
|
||||
#define LWIP_SOCKET_FCNTL 0
|
||||
|
||||
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
||||
|
||||
@@ -373,7 +373,10 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
|
||||
while (!ping_kill && (forever || (i < cnt))) {
|
||||
iecho->seqno = htons((u16_t)i);
|
||||
iecho->chksum = 0;
|
||||
|
||||
#if (CHECKSUM_GEN_ICMP > 0)
|
||||
iecho->chksum = inet_chksum((void *)iecho, iecho_len);
|
||||
#endif
|
||||
|
||||
ret = sendto(sfd, iecho, iecho_len, 0, (struct sockaddr *)&to, (socklen_t)sizeof(to));
|
||||
if (ret < 0) {
|
||||
|
||||
@@ -211,6 +211,7 @@ int close(int fd)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_IOCTL
|
||||
#ifdef LWIP_SOCKET_IOCTL_FUNC
|
||||
int ioctl(int fd, int req, ...)
|
||||
{
|
||||
@@ -222,7 +223,9 @@ int ioctl(int fd, int req, ...)
|
||||
return lwip_ioctl(fd, (long)req, (void *)arg);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_FCNTL
|
||||
#ifdef LWIP_SOCKET_FCNTL_FUNC
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
@@ -234,6 +237,7 @@ int fcntl(int fd, int cmd, ...)
|
||||
return lwip_fcntl(fd, cmd, val);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_SELECT
|
||||
#ifdef LWIP_SOCKET_SELECT_FUNC
|
||||
|
||||
@@ -130,7 +130,7 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||
|
||||
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL) ||
|
||||
(pm->pmMode == LOS_SYS_NORMAL_SLEEP)) {
|
||||
(pm->sysMode == LOS_SYS_NORMAL_SLEEP)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -264,6 +264,7 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
|
||||
if (pm->sysctrl->suspendCheck != NULL) {
|
||||
pm->sysctrl->suspendCheck(mode);
|
||||
pm->sysMode = pm->pmMode;
|
||||
}
|
||||
|
||||
tickTimerStop = OsPmTickTimerStop(pm);
|
||||
|
||||
@@ -43,6 +43,10 @@
|
||||
#include "los_debugtools.h"
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_KERNEL_TRACE == 1)
|
||||
#include "los_trace_pri.h"
|
||||
#endif
|
||||
|
||||
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
|
||||
|
||||
STATIC CmdModInfo cmdInfo;
|
||||
@@ -75,6 +79,13 @@ CmdItem g_shellcmdAll[] = {
|
||||
{CMD_TYPE_EX, "st", 1, (CmdCallBackFunc)OsShellCmdSchedTrace},
|
||||
#endif
|
||||
{CMD_TYPE_EX, "help", 0, (CmdCallBackFunc)OsShellCmdHelp},
|
||||
#if (LOSCFG_KERNEL_TRACE == 1)
|
||||
{CMD_TYPE_EX, "trace_start", 0, (CmdCallBackFunc)LOS_TraceStart},
|
||||
{CMD_TYPE_EX, "trace_stop", 0, (CmdCallBackFunc)LOS_TraceStop},
|
||||
{CMD_TYPE_EX, "trace_mask", 1, (CmdCallBackFunc)OsShellCmdTraceSetMask},
|
||||
{CMD_TYPE_EX, "trace_reset", 0, (CmdCallBackFunc)LOS_TraceReset},
|
||||
{CMD_TYPE_EX, "trace_dump", 1, (CmdCallBackFunc)OsShellCmdTraceDump},
|
||||
#endif
|
||||
};
|
||||
|
||||
CmdModInfo *OsCmdInfoGet(VOID)
|
||||
|
||||
@@ -625,6 +625,24 @@ STATIC INT32 OsIsContainersWildcard(const CHAR *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Delete a non directory file */
|
||||
STATIC INT32 OsRmFileOnly(const CHAR *fullpath)
|
||||
{
|
||||
struct stat statInfo = {0};
|
||||
INT32 ret = stat(fullpath, &statInfo);
|
||||
if (ret == 0) {
|
||||
if (!S_ISDIR(statInfo.st_mode)) {
|
||||
ret = unlink(fullpath);
|
||||
} else {
|
||||
ret = 0;
|
||||
PRINTK("rm: cannot remove '%s': Is a directory\n", fullpath);
|
||||
}
|
||||
} else {
|
||||
PRINTK("stat: get '%s' statInfo fail!\n", fullpath);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Delete a matching file or directory */
|
||||
|
||||
STATIC INT32 OsWildcardDeleteFileOrDir(const CHAR *fullpath, wildcard_type mark)
|
||||
@@ -636,7 +654,7 @@ STATIC INT32 OsWildcardDeleteFileOrDir(const CHAR *fullpath, wildcard_type mark)
|
||||
ret = OsShellCmdDoRmdir(fullpath);
|
||||
break;
|
||||
case RM_FILE:
|
||||
ret = unlink(fullpath);
|
||||
ret = OsRmFileOnly(fullpath);
|
||||
break;
|
||||
case RM_DIR:
|
||||
ret = rmdir(fullpath);
|
||||
@@ -649,8 +667,6 @@ STATIC INT32 OsWildcardDeleteFileOrDir(const CHAR *fullpath, wildcard_type mark)
|
||||
perror("rm/rmdir error!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
PRINTK("%s match successful!delete!\n", fullpath);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -728,6 +744,10 @@ STATIC INT32 OsWildcardExtractDirectory(CHAR *fullpath, VOID *dst, wildcard_type
|
||||
break;
|
||||
}
|
||||
|
||||
if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = strcpy_s(src, PATH_MAX, f);
|
||||
if (ret != EOK) {
|
||||
goto closedir_out;
|
||||
@@ -910,7 +930,7 @@ INT32 OsShellCmdRm(INT32 argc, const CHAR **argv)
|
||||
if (OsIsContainersWildcard(fullpath)) {
|
||||
ret = OsWildcardExtractDirectory(fullpath, NULL, RM_FILE);
|
||||
} else {
|
||||
ret = unlink(fullpath);
|
||||
ret = OsRmFileOnly(fullpath);
|
||||
}
|
||||
}
|
||||
if (ret == -1) {
|
||||
|
||||
@@ -64,3 +64,11 @@ kernel_module(module_name) {
|
||||
include_dirs += [ "pipeline/serial" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [
|
||||
".",
|
||||
"cnv",
|
||||
"pipeline",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -235,7 +235,9 @@ VOID OsTraceCnvInit(VOID)
|
||||
LOS_HookReg(LOS_HOOK_TYPE_QUEUE_CREATE, LOS_TraceQueueCreate);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_QUEUE_DELETE, LOS_TraceQueueDelete);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_QUEUE_READ, LOS_TraceQueueRW);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_QUEUE_READ_COPY, LOS_TraceQueueRW);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_QUEUE_WRITE, LOS_TraceQueueRW);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_QUEUE_WRITE_COPY, LOS_TraceQueueRW);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_SEM_CREATE, LOS_TraceSemCreate);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_SEM_DELETE, LOS_TraceSemDelete);
|
||||
LOS_HookReg(LOS_HOOK_TYPE_SEM_POST, LOS_TraceSemPost);
|
||||
|
||||
@@ -411,12 +411,6 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdTraceDump(INT32 argc, const CHAR **argv)
|
||||
LOS_TraceRecordDump(toClient);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
SHELLCMD_ENTRY(tracestart_shellcmd, CMD_TYPE_EX, "trace_start", 0, (CmdCallBackFunc)LOS_TraceStart);
|
||||
SHELLCMD_ENTRY(tracestop_shellcmd, CMD_TYPE_EX, "trace_stop", 0, (CmdCallBackFunc)LOS_TraceStop);
|
||||
SHELLCMD_ENTRY(tracesetmask_shellcmd, CMD_TYPE_EX, "trace_mask", 1, (CmdCallBackFunc)OsShellCmdTraceSetMask);
|
||||
SHELLCMD_ENTRY(tracereset_shellcmd, CMD_TYPE_EX, "trace_reset", 0, (CmdCallBackFunc)LOS_TraceReset);
|
||||
SHELLCMD_ENTRY(tracedump_shellcmd, CMD_TYPE_EX, "trace_dump", 1, (CmdCallBackFunc)OsShellCmdTraceDump);
|
||||
#endif
|
||||
|
||||
#endif /* LOSCFG_KERNEL_TRACE == 1 */
|
||||
|
||||
@@ -152,6 +152,11 @@ extern VOID OsTraceRecordDump(BOOL toClient);
|
||||
#define OsTraceNotifyStop()
|
||||
#endif
|
||||
|
||||
#if (LOSCFG_SHELL == 1)
|
||||
extern UINT32 OsShellCmdTraceSetMask(INT32 argc, const CHAR **argv);
|
||||
extern UINT32 OsShellCmdTraceDump(INT32 argc, const CHAR **argv);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
#include "los_trace_pri.h"
|
||||
#include "trace_pipeline.h"
|
||||
#include "los_memory.h"
|
||||
#include "securec.h"
|
||||
|
||||
#if (LOSCFG_RECORDER_MODE_OFFLINE == 1)
|
||||
#define BITS_NUM_FOR_TASK_ID 16
|
||||
|
||||
@@ -86,10 +86,6 @@ optimize_config_cflags = []
|
||||
optimize_config_asmflags = []
|
||||
|
||||
if (defined(LOSCFG_COMPILE_DEBUG)) {
|
||||
optimize_config_cflags += [
|
||||
"-g",
|
||||
"-gdwarf-2",
|
||||
]
|
||||
optimize_config_cflags += [ "-On" ]
|
||||
} else {
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
|
||||
@@ -118,12 +114,14 @@ kconfig_config_cflags += [
|
||||
warn_config_cflags = []
|
||||
warn_config_asmflags = []
|
||||
|
||||
warn_config_cflags += [
|
||||
"--warnings_affect_exit_code",
|
||||
"--warnings_are_errors",
|
||||
"--warn_about_c_style_casts",
|
||||
"--warn_about_incomplete_constructors",
|
||||
]
|
||||
if (!defined(LOSCFG_TEST)) {
|
||||
warn_config_cflags += [
|
||||
"--warnings_affect_exit_code",
|
||||
"--warnings_are_errors",
|
||||
"--warn_about_c_style_casts",
|
||||
"--warn_about_incomplete_constructors",
|
||||
]
|
||||
}
|
||||
|
||||
#
|
||||
# dialect_config
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 118 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 106 KiB |
@@ -42,6 +42,9 @@
|
||||
#include "los_task.h"
|
||||
#include "los_timer.h"
|
||||
#include "los_debug.h"
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
#include "los_arch.h"
|
||||
#endif
|
||||
|
||||
#include "string.h"
|
||||
#include "securec.h"
|
||||
@@ -1002,6 +1005,10 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
|
||||
UINT32 ret;
|
||||
UINT32 muxId;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
UNUSED(attr);
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
@@ -1010,6 +1017,9 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
|
||||
|
||||
ret = LOS_MuxCreate(&muxId);
|
||||
if (ret == LOS_OK) {
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(muxId), regLR);
|
||||
#endif
|
||||
return (osMutexId_t)(GET_MUX(muxId));
|
||||
} else {
|
||||
return (osMutexId_t)NULL;
|
||||
|
||||
@@ -43,6 +43,7 @@ rsource "newlib/Kconfig"
|
||||
|
||||
config LIBC_ICCARM
|
||||
bool "iar libc"
|
||||
depends on COMPILER_ICCARM
|
||||
rsource "iccarm/Kconfig"
|
||||
|
||||
endchoice
|
||||
|
||||
@@ -35,4 +35,10 @@ config LIBC_ICCARM_FS
|
||||
help
|
||||
This enables POSIX style file system related APIs.
|
||||
|
||||
config LIBC_ICCARM_MALLOC
|
||||
bool "Enable POSIX malloc/free API support"
|
||||
default y
|
||||
help
|
||||
This enables POSIX malloc/free related APIs.
|
||||
|
||||
endif # LIBC_ICCARM
|
||||
|
||||
@@ -36,4 +36,10 @@ config LIBC_NEWLIB_FS
|
||||
help
|
||||
This enables POSIX style file system related APIs.
|
||||
|
||||
config LIBC_NEWLIB_MALLOC
|
||||
bool "Enable POSIX malloc/free API support"
|
||||
default y
|
||||
help
|
||||
This enables POSIX malloc/free related APIs.
|
||||
|
||||
endif # LIBC_NEWLIB
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "los_memory.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef LOSCFG_LIBC_NEWLIB_MALLOC
|
||||
void *zalloc(size_t size)
|
||||
{
|
||||
void *ptr = NULL;
|
||||
@@ -111,3 +112,4 @@ void *__wrap__calloc_r(struct _reent *reent, size_t nitems, size_t size)
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -694,7 +694,7 @@ UINT32 OsPipeInit(VOID)
|
||||
|
||||
ret = LOS_MuxCreate(&g_devFdMutex);
|
||||
if (ret != LOS_OK) {
|
||||
LOS_MuxDelete(g_devListMutex);
|
||||
(VOID)LOS_MuxDelete(g_devListMutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ STATIC INLINE INT32 PollTimedWait(struct pollfd *fds, nfds_t nfds, struct PollTa
|
||||
}
|
||||
} else if (left <= 0) {
|
||||
break;
|
||||
} else if (left > 0) {
|
||||
} else {
|
||||
clock_gettime(CLOCK_REALTIME, &curTime);
|
||||
last = (INT32)((curTime.tv_sec - startTime.tv_sec) * OS_SYS_MS_PER_SECOND +
|
||||
(curTime.tv_nsec - startTime.tv_nsec) / (OS_SYS_NS_PER_SECOND / OS_SYS_MS_PER_SECOND));
|
||||
|
||||
@@ -42,12 +42,6 @@
|
||||
#include "los_event.h"
|
||||
#include "los_mux.h"
|
||||
|
||||
typedef struct {
|
||||
volatile INT32 *realValue;
|
||||
INT32 value;
|
||||
UINT32 clearEvent;
|
||||
} EventCond;
|
||||
|
||||
#define INLINE inline
|
||||
|
||||
#define BROADCAST_EVENT 1
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
#include "los_debug.h"
|
||||
#include "los_hook.h"
|
||||
#include "los_sched.h"
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
#include "los_arch.h"
|
||||
#endif
|
||||
|
||||
#define MUTEXATTR_TYPE_MASK 0x0FU
|
||||
#define OS_SYS_NS_PER_MSECOND 1000000
|
||||
@@ -130,6 +133,10 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||
UINT32 muxHandle;
|
||||
UINT32 ret;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
if (mutex == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -148,6 +155,9 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||
mutex->stAttr = useAttr;
|
||||
mutex->magic = _MUX_MAGIC;
|
||||
mutex->handle = muxHandle;
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -324,6 +334,10 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||
struct timespec curTime = {0};
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
@@ -337,6 +351,9 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||
@@ -364,6 +381,11 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
{
|
||||
UINT32 ret;
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
LosTaskCB *runTask = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||
|
||||
ret = MuxPreCheck(mutex, runTask);
|
||||
@@ -376,6 +398,9 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||
@@ -394,6 +419,10 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||
UINT32 ret;
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
@@ -404,6 +433,9 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type != PTHREAD_MUTEX_RECURSIVE) && (muxPended->muxCount != 0)) {
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include "los_task.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -302,6 +301,9 @@ typedef struct {
|
||||
UINT32 muxID; /**< Handle ID */
|
||||
LOS_DL_LIST muxList; /**< Mutex linked list */
|
||||
LosTaskCB *owner; /**< The current thread that is locking a mutex */
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR createInfo; /**< Return address of the caller */
|
||||
#endif
|
||||
UINT16 priority; /**< Priority of the thread that is locking a mutex */
|
||||
} LosMuxCB;
|
||||
|
||||
@@ -351,6 +353,13 @@ extern UINT32 OsMuxInit(VOID);
|
||||
*/
|
||||
#define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosMuxCB, muxList)
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
STATIC INLINE VOID OsSetMutexCreateInfo(LosMuxCB *mux, UINTPTR val)
|
||||
{
|
||||
mux->createInfo = val;
|
||||
}
|
||||
#endif /* LOSCFG_MUTEX_CREATE_TRACE == 1 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -96,6 +96,11 @@ STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
return LOS_SysCycleGet();
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsCheckKernelRunning(VOID)
|
||||
{
|
||||
return (g_taskScheduled && LOS_CHECK_SCHEDULE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* @brief Get the time, in nanoseconds, remaining before the next tick interrupt response.
|
||||
|
||||
@@ -120,21 +120,6 @@ LITE_OS_SEC_TEXT_INIT VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
ArchSysExit();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
Function : OsRegister
|
||||
Description : Configuring the maximum number of tasks
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_INIT static VOID OsRegister(VOID)
|
||||
{
|
||||
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID)
|
||||
{
|
||||
return ArchStartSchedule();
|
||||
@@ -156,8 +141,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
|
||||
OsBackTraceInit();
|
||||
#endif
|
||||
|
||||
OsRegister();
|
||||
|
||||
#ifdef LOSCFG_KERNEL_LMS
|
||||
OsLmsInit();
|
||||
#endif
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
#include "los_memory.h"
|
||||
#include "los_sched.h"
|
||||
|
||||
|
||||
#if (LOSCFG_BASE_IPC_MUX == 1)
|
||||
|
||||
LITE_OS_SEC_BSS LosMuxCB* g_allMux = NULL;
|
||||
@@ -71,6 +70,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsMuxInit(VOID)
|
||||
muxNode->muxID = index;
|
||||
muxNode->owner = (LosTaskCB *)NULL;
|
||||
muxNode->muxStat = OS_MUX_UNUSED;
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
muxNode->createInfo = 0;
|
||||
#endif
|
||||
LOS_ListTailInsert(&g_unusedMuxList, &muxNode->muxList);
|
||||
}
|
||||
return LOS_OK;
|
||||
@@ -149,7 +151,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_MuxDelete(UINT32 muxHandle)
|
||||
|
||||
LOS_ListAdd(&g_unusedMuxList, &muxDeleted->muxList);
|
||||
muxDeleted->muxStat = OS_MUX_UNUSED;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
muxDeleted->createInfo = 0;
|
||||
#endif
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_MUX_DELETE, muxDeleted);
|
||||
@@ -320,5 +324,5 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxPost(UINT32 muxHandle)
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif /* (LOSCFG_BASE_IPC_MUX == 1) */
|
||||
|
||||
#endif /* (LOSCFG_BASE_IPC_MUX == 1) */
|
||||
|
||||
@@ -451,6 +451,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_QueueReadCopy(UINT32 queueID,
|
||||
}
|
||||
|
||||
operateType = OS_QUEUE_OPERATE_TYPE(OS_QUEUE_READ, OS_QUEUE_HEAD, OS_QUEUE_NOT_POINT);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_QUEUE_READ_COPY, (LosQueueCB *)GET_QUEUE_HANDLE(queueID),
|
||||
operateType, *bufferSize, timeOut);
|
||||
|
||||
return OsQueueOperate(queueID, operateType, bufferAddr, bufferSize, timeOut);
|
||||
}
|
||||
|
||||
@@ -485,6 +489,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_QueueWriteCopy(UINT32 queueID,
|
||||
}
|
||||
|
||||
operateType = OS_QUEUE_OPERATE_TYPE(OS_QUEUE_WRITE, OS_QUEUE_TAIL, OS_QUEUE_NOT_POINT);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_QUEUE_WRITE_COPY, (LosQueueCB *)GET_QUEUE_HANDLE(queueID),
|
||||
operateType, bufferSize, timeOut);
|
||||
|
||||
return OsQueueOperate(queueID, operateType, bufferAddr, &bufferSize, timeOut);
|
||||
}
|
||||
|
||||
|
||||
@@ -618,7 +618,7 @@ VOID LOS_SchedTickHandler(VOID)
|
||||
|
||||
VOID LOS_Schedule(VOID)
|
||||
{
|
||||
if (g_taskScheduled && LOS_CHECK_SCHEDULE) {
|
||||
if (OsCheckKernelRunning()) {
|
||||
ArchTaskSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
* @ingroup los_task
|
||||
* @brief check task id's validation
|
||||
*/
|
||||
#define OS_TASK_ID_CHECK(taskID) LOS_ASSERT_COND(OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
|
||||
#define OS_TASK_ID_CHECK(taskID) (OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -409,6 +409,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
|
||||
UINT32 size;
|
||||
UINT32 index;
|
||||
|
||||
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
|
||||
size = (g_taskMaxNum + 1) * sizeof(LosTaskCB);
|
||||
g_taskCBArray = (LosTaskCB *)LOS_MemAlloc(m_aucSysMem0, size);
|
||||
if (g_taskCBArray == NULL) {
|
||||
@@ -856,7 +857,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
|
||||
UINT32 retErr = OS_ERROR;
|
||||
BOOL needSched = FALSE;
|
||||
|
||||
if (taskID > LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
if (!OS_TASK_ID_CHECK(taskID)) {
|
||||
return LOS_ERRNO_TSK_ID_INVALID;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -340,6 +340,7 @@ typedef struct tagHwiHandleForm {
|
||||
#define TEST_HwiCreate(ID, prio, mode, Func, irqParam) LOS_HwiCreate(ID, prio, mode, Func, irqParam)
|
||||
#define uart_printf_func printf
|
||||
|
||||
extern VOID ItSuiteLosAtomic(void);
|
||||
extern VOID ItSuiteLosTask(void);
|
||||
extern VOID ItSuiteLosQueue(void);
|
||||
extern VOID ItSuiteLosMux(void);
|
||||
|
||||
@@ -91,7 +91,6 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis007, Function | MediumTest | Level1)
|
||||
{
|
||||
osMessageQueueId_t msgQueueId;
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
CHAR strbuff[] = "hello world";
|
||||
CHAR *name = NULL;
|
||||
INT32 ret;
|
||||
@@ -101,30 +100,31 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis007, Function | MediumTest | Level1)
|
||||
msgQueueId = osMessageQueueNew(1, strlen(strbuff), &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(msgQueueId, NULL, msgQueueId);
|
||||
|
||||
name = osMessageQueueGetName(msgQueueId);
|
||||
name = (CHAR *)osMessageQueueGetName(msgQueueId);
|
||||
ret = strcmp(name, "q1");
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = osMessageQueueDelete(msgQueueId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
name = osMessageQueueGetName(msgQueueId);
|
||||
name = (CHAR *)osMessageQueueGetName(msgQueueId);
|
||||
ICUNIT_ASSERT_EQUAL(name, NULL, name);
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
attr.mq_mem = staticBuff;
|
||||
attr.mq_size = STATCI_BUFF_SIZE;
|
||||
msgQueueId = osMessageQueueNew(1, STATCI_BUFF_SIZE, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(msgQueueId, NULL, msgQueueId);
|
||||
|
||||
name = osMessageQueueGetName(msgQueueId);
|
||||
name = (CHAR *)osMessageQueueGetName(msgQueueId);
|
||||
ret = strcmp(name, "q1");
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = osMessageQueueDelete(msgQueueId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
name = osMessageQueueGetName(msgQueueId);
|
||||
name = (CHAR *)osMessageQueueGetName(msgQueueId);
|
||||
ICUNIT_ASSERT_EQUAL(name, NULL, name);
|
||||
#endif
|
||||
|
||||
@@ -155,13 +155,13 @@ static VOID CmsisQueueTestThread1(VOID)
|
||||
osStatus_t status;
|
||||
|
||||
ret = osMessageQueuePut(g_msgQueueId1, &g_strbuff1, 0U, 0U);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, osOK, ret);
|
||||
|
||||
status = osMessageQueueGet(g_msgQueueId2, &data, NULL, QUEUE_WAIT_TIMEOUT);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
|
||||
|
||||
ret = strcmp(data, "world");
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
|
||||
}
|
||||
|
||||
static VOID CmsisQueueTestThread2(VOID)
|
||||
@@ -171,13 +171,13 @@ static VOID CmsisQueueTestThread2(VOID)
|
||||
osStatus_t status;
|
||||
|
||||
status = osMessageQueueGet(g_msgQueueId1, &data, NULL, QUEUE_WAIT_TIMEOUT);
|
||||
ICUNIT_ASSERT_EQUAL(status, osOK, status);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
|
||||
|
||||
ret = strcmp(data, "hello");
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
|
||||
|
||||
ret = osMessageQueuePut(g_msgQueueId2, &g_strbuff2, 0U, 0U);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, osOK, ret);
|
||||
}
|
||||
|
||||
static INT32 ThreadReadWriteTest(VOID)
|
||||
@@ -193,10 +193,10 @@ static INT32 ThreadReadWriteTest(VOID)
|
||||
g_msgQueueId2 = osMessageQueueNew(1, strlen(g_strbuff2), &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(g_msgQueueId2, NULL, g_msgQueueId2);
|
||||
|
||||
threadId1 = osThreadNew(CmsisQueueTestThread1, NULL, NULL);
|
||||
threadId1 = osThreadNew((osThreadFunc_t)CmsisQueueTestThread1, NULL, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(threadId1, NULL, threadId1);
|
||||
|
||||
threadId2 = osThreadNew(CmsisQueueTestThread2, NULL, NULL);
|
||||
threadId2 = osThreadNew((osThreadFunc_t)CmsisQueueTestThread2, NULL, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(threadId2, NULL, threadId2);
|
||||
|
||||
osThreadJoin(threadId1);
|
||||
@@ -239,8 +239,6 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis006, Function | MediumTest | Level1)
|
||||
LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis005, Function | MediumTest | Level1)
|
||||
{
|
||||
osMessageQueueId_t msgQueueId;
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
CHAR strbuff[] = "hello world";
|
||||
CHAR data[STATCI_BUFF_SIZE] = {0};
|
||||
INT32 ret;
|
||||
@@ -272,6 +270,8 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis005, Function | MediumTest | Level1)
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
/* static test */
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
attr.mq_mem = staticBuff;
|
||||
attr.mq_size = STATCI_BUFF_SIZE;
|
||||
msgQueueId = osMessageQueueNew(1, STATCI_BUFF_SIZE, &attr);
|
||||
@@ -311,8 +311,6 @@ EXIT:
|
||||
LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis004, Function | MediumTest | Level1)
|
||||
{
|
||||
osMessageQueueId_t msgQueueId;
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
CHAR strbuff[] = "hello world";
|
||||
CHAR data[STATCI_BUFF_SIZE] = {0};
|
||||
INT32 ret;
|
||||
@@ -335,6 +333,8 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis004, Function | MediumTest | Level1)
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
/* static test */
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
attr.mq_mem = staticBuff;
|
||||
attr.mq_size = strlen(strbuff) + 1;
|
||||
msgQueueId = osMessageQueueNew(1, strlen(strbuff), &attr);
|
||||
@@ -373,8 +373,6 @@ EXIT:
|
||||
LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis003, Function | MediumTest | Level1)
|
||||
{
|
||||
osMessageQueueId_t msgQueueId;
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
CHAR strbuff[] = "hello world";
|
||||
|
||||
/* dynmic test */
|
||||
@@ -386,6 +384,8 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis003, Function | MediumTest | Level1)
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
/* static test */
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
attr.mq_mem = staticBuff;
|
||||
attr.mq_size = STATCI_BUFF_SIZE;
|
||||
msgQueueId = osMessageQueueNew(0, strlen(strbuff), &attr);
|
||||
@@ -417,8 +417,6 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis003, Function | MediumTest | Level1)
|
||||
LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis002, Function | MediumTest | Level1)
|
||||
{
|
||||
osMessageQueueId_t msgQueueId;
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
CHAR strbuff[] = "hello world";
|
||||
INT32 ret;
|
||||
|
||||
@@ -434,6 +432,8 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis002, Function | MediumTest | Level1)
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
/* static test */
|
||||
osMessageQueueAttr_t attr = {0};
|
||||
CHAR staticBuff[STATCI_BUFF_SIZE] = {0};
|
||||
attr.mq_mem = staticBuff;
|
||||
attr.mq_size = STATCI_BUFF_SIZE;
|
||||
msgQueueId = osMessageQueueNew(1, STATCI_BUFF_SIZE, &attr);
|
||||
@@ -449,6 +449,53 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis002, Function | MediumTest | Level1)
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
static VOID timerCallback(void *arg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: TestCmsisTimer001
|
||||
* @tc.desc: Timer Management test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TQ0T
|
||||
*/
|
||||
LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsisTimer001, Function | MediumTest | Level1)
|
||||
{
|
||||
osTimerId_t time_id;
|
||||
const char *timerGetName = NULL;
|
||||
osStatus_t ret;
|
||||
|
||||
time_id = osTimerNew(timerCallback, osTimerOnce, NULL, NULL);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(time_id, NULL, time_id);
|
||||
|
||||
ret = osTimerStart(time_id, 100U); // 100, just for test
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
timerGetName = osTimerGetName(time_id);
|
||||
ICUNIT_GOTO_EQUAL(timerGetName, NULL, timerGetName, EXIT1);
|
||||
|
||||
ret = osTimerIsRunning(time_id);
|
||||
ICUNIT_GOTO_EQUAL(ret, 1, ret, EXIT1);
|
||||
|
||||
ret = osTimerStop(time_id);
|
||||
ICUNIT_GOTO_EQUAL(ret, osOK, ret, EXIT1);
|
||||
|
||||
ret = osTimerIsRunning(time_id);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = osTimerDelete(time_id);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT1:
|
||||
ret = osTimerDelete(time_id);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
return LOS_OK;
|
||||
};
|
||||
|
||||
|
||||
void CmsisFuncTestSuite(void)
|
||||
{
|
||||
@@ -465,5 +512,7 @@ void CmsisFuncTestSuite(void)
|
||||
#endif
|
||||
|
||||
ADD_TEST_CASE(TestCmsis007);
|
||||
|
||||
ADD_TEST_CASE(TestCmsisTimer001);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -56,6 +56,8 @@ extern VOID ItLosAtomic006(VOID);
|
||||
extern VOID ItLosAtomic007(VOID);
|
||||
extern VOID ItLosAtomic008(VOID);
|
||||
extern VOID ItLosAtomic009(VOID);
|
||||
extern VOID ItLosAtomic010(VOID);
|
||||
extern VOID ItLosAtomic011(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -62,9 +62,9 @@ static UINT32 TestCase(VOID)
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
LOS_TaskDelay(20); // delay 20 ticks.
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(g_testAtomicID05, TEST_LOOP, g_testAtomicID05, EXIT);
|
||||
EXIT:
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
ICUNIT_ASSERT_EQUAL(g_testAtomicID05, TEST_LOOP, g_testAtomicID05);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -232,8 +232,8 @@ static UINT32 TestCase(VOID)
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
LOS_TaskDelay(20); // delay 20 ticks.
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
EXIT:
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ STATIC UINT32 TestCase(VOID)
|
||||
VOID *handle = NULL;
|
||||
CHAR *dsoNeedOthers = DSO_FULL_PATH("Align4_dynamic_need_others.so");
|
||||
CHAR *dsoWithoutPIC = DSO_FULL_PATH("Align4_dynamic_nopic.so");
|
||||
INT32 ret;
|
||||
|
||||
handle = (VOID *)LOS_SoLoad(dsoNeedOthers, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
|
||||
|
||||
@@ -36,7 +36,6 @@ STATIC UINT32 TestCase(VOID)
|
||||
VOID *handle = NULL;
|
||||
VOID (*func)(INT32, INT32) = NULL;
|
||||
CHAR *dsoName = DSO_FULL_PATH("Align4_dynamic_stdlib.so");
|
||||
INT32 ret;
|
||||
|
||||
handle = (VOID *)LOS_SoLoad(dsoName, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(handle, NULL, handle);
|
||||
|
||||
@@ -74,7 +74,7 @@ static UINT32 Testcase(VOID)
|
||||
LOS_EventInit(&g_pevent);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
g_testCount++;
|
||||
@@ -84,7 +84,6 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
|
||||
|
||||
EXIT1:
|
||||
|
||||
ret = LOS_EventClear(&g_pevent, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ static UINT32 Testcase(VOID)
|
||||
LOS_EventInit(&g_pevent);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
|
||||
g_testCount++;
|
||||
|
||||
@@ -87,7 +87,7 @@ static UINT32 Testcase(VOID)
|
||||
ret = LOS_EventWrite(&g_pevent, 0x11);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT1);
|
||||
|
||||
ret = LOS_TaskResume(g_testTaskID01);
|
||||
(VOID)LOS_TaskResume(g_testTaskID01);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT1); // 5, Here, assert that g_testCount is equal to 5.
|
||||
|
||||
EXIT1:
|
||||
|
||||
@@ -90,7 +90,7 @@ static UINT32 Testcase(VOID)
|
||||
LOS_EventInit(&g_pevent);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
g_testCount++;
|
||||
@@ -111,7 +111,6 @@ static UINT32 Testcase(VOID)
|
||||
EXIT1:
|
||||
LOS_TaskDelete(g_testTaskID02);
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
@@ -88,7 +88,7 @@ static UINT32 Testcase(VOID)
|
||||
LOS_EventInit(&g_pevent);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
g_testCount++;
|
||||
@@ -106,7 +106,6 @@ static UINT32 Testcase(VOID)
|
||||
EXIT1:
|
||||
LOS_TaskDelete(g_testTaskID02);
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
@@ -85,13 +85,10 @@ static UINT32 Testcase(VOID)
|
||||
LOS_EventInit(&g_pevent);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 5, g_testCount); // 5, Here, assert that g_testCount is equal to 5.
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
@@ -129,14 +129,13 @@ static UINT32 Testcase(VOID)
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT2); // 3, Here, assert that g_testCount is equal to 3.
|
||||
|
||||
ret = LOS_EventWrite(&g_pevent, 0xF);
|
||||
(VOID)LOS_EventWrite(&g_pevent, 0xF);
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT3); // 6, Here, assert that g_testCount is equal to 6.
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, Here, assert that g_testCount is equal to 6.
|
||||
|
||||
EXIT3:
|
||||
ret = LOS_EventClear(&g_pevent, 0);
|
||||
(VOID)LOS_EventClear(&g_pevent, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
ret = LOS_EventDestroy(&g_pevent);
|
||||
|
||||
@@ -77,10 +77,9 @@ static UINT32 Testcase(VOID)
|
||||
|
||||
LOS_EventClear(&g_pevent, (~(0x11)));
|
||||
|
||||
ret = LOS_TaskResume(g_testTaskID01);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT1); // 4, Here, assert that g_testCount is equal to 4.
|
||||
(VOID)LOS_TaskResume(g_testTaskID01);
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
|
||||
|
||||
EXIT1:
|
||||
ret = LOS_EventClear(&g_pevent, 0);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ static VOID TaskF01(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
VOID ItHwiM3B001F001()
|
||||
static VOID ItHwiM3B001F001(VOID)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ static UINT32 TestCase(VOID)
|
||||
ICUNIT_ASSERT_NOT_EQUAL(buf, NULL, buf);
|
||||
buf[7] = '\0'; /* end index 7 */
|
||||
PRINTK("%d\n", __LINE__);
|
||||
ret = strcpy_s(buf, 100, src); /* Check LMS detection information when the strcpy_s dest max set 100 overflows. */
|
||||
(VOID)strcpy_s(buf, 100, src); /* Check LMS detection information when the strcpy_s dest max set 100 overflows. */
|
||||
PRINTK("%d\n", __LINE__);
|
||||
|
||||
ret = LOS_MemFree(g_testLmsPool, buf);
|
||||
|
||||
@@ -59,7 +59,7 @@ static UINT32 Testcase(VOID)
|
||||
task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
task.uwResved = 0;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task);
|
||||
(VOID)LOS_TaskCreate(&g_testTaskID01, &task);
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); // 1, Here, assert that g_testCount is equal to 1.
|
||||
|
||||
ret = LOS_MuxDelete(g_mutexTest);
|
||||
|
||||
@@ -68,7 +68,7 @@ static UINT32 Testcase(VOID)
|
||||
task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
task.uwResved = 0;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task);
|
||||
(VOID)LOS_TaskCreate(&g_testTaskID01, &task);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount); // 1, Here, assert that g_testCount is equal to 1.
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ static UINT32 Testcase(VOID)
|
||||
task.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
task.uwResved = 0;
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task);
|
||||
(VOID)LOS_TaskCreate(&g_testTaskID01, &task);
|
||||
|
||||
task2.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task2.usTaskPrio = (TASK_PRIO_TEST - 2); // 2, set new task priority, it is higher than the current task.
|
||||
|
||||
@@ -35,17 +35,19 @@
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 msgSize = (UINT32)QUEUE_BASE_MSGSIZE;
|
||||
|
||||
CHAR buff1[QUEUE_SHORT_BUFFER_LENGTH] = "UniDSP";
|
||||
CHAR buff2[QUEUE_SHORT_BUFFER_LENGTH] = {0};
|
||||
CHAR buff3[QUEUE_SHORT_BUFFER_LENGTH] = {0};
|
||||
|
||||
ret = LOS_QueueCreateStatic("Q1", QUEUE_BASE_NUM, &g_testQueueID01, buff3, 0, QUEUE_BASE_MSGSIZE);
|
||||
ret = LOS_QueueCreateStatic("Q1", QUEUE_BASE_NUM, &g_testQueueID01, (UINT8 *)buff3, 0, QUEUE_BASE_MSGSIZE);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, (UINT32)QUEUE_BASE_MSGSIZE, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, QUEUE_BASE_MSGSIZE, 0);
|
||||
ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &msgSize, 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = strcmp((CHAR *)buff2, (CHAR *)buff3);
|
||||
|
||||
@@ -68,7 +68,7 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
EXIT:
|
||||
ret = LOS_TaskDelete(g_testTaskID01);
|
||||
(VOID)LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
EXIT2:
|
||||
ret = LOS_SemDelete(g_usSemID);
|
||||
|
||||
@@ -69,7 +69,7 @@ static UINT32 g_uwsTick2;
|
||||
static UINT32 g_uwsTick3;
|
||||
|
||||
extern VOID LOS_GetCpuTick(UINT32 *puwCntHi, UINT32 *puwCntLo);
|
||||
extern VOID ItSuiteLosSwtmr();
|
||||
extern VOID ItSuiteLosSwtmr(VOID);
|
||||
extern VOID ItLosSwtmr001(VOID);
|
||||
extern VOID ItLosSwtmr002(VOID);
|
||||
extern VOID ItLosSwtmr003(VOID);
|
||||
|
||||
@@ -39,7 +39,7 @@ static VOID Case1(UINT32 arg)
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
static VOID Case2()
|
||||
static VOID Case2(VOID)
|
||||
{
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ static VOID Case1(UINT32 arg)
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
static VOID Case2()
|
||||
static VOID Case2(VOID)
|
||||
{
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
static VOID Case3()
|
||||
static VOID Case3(VOID)
|
||||
{
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
|
||||
|
||||
g_testCount1 = 0;
|
||||
// 1, Timeout interval of a periodic software timer.
|
||||
ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)Case2, &g_swtmrId1, &irqParam
|
||||
ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)Case2, &g_swtmrId1, (UINT32)&irqParam
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
, OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
static UINT32 g_testCount1 = 0;
|
||||
static VOID Case1()
|
||||
static VOID Case1(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
static UINT32 g_testCount1 = 0;
|
||||
|
||||
static VOID Case1()
|
||||
static VOID Case1(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ static VOID Case1(UINT32 arg)
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID Case2()
|
||||
static VOID Case2(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 tick;
|
||||
|
||||
@@ -61,7 +61,7 @@ static UINT32 Testcase(VOID)
|
||||
ret = LOS_SwtmrStart(swTmrID);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskDelay(10); // 10, set delay time.
|
||||
(VOID)LOS_TaskDelay(10); // 10, set delay time.
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ static UINT32 Testcase(VOID)
|
||||
ret = LOS_SwtmrStart(g_swTmrID2);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ret = LOS_TaskDelay(10); // 10, set delay time.
|
||||
(VOID)LOS_TaskDelay(10); // 10, set delay time.
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
@@ -49,8 +49,6 @@ static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
g_testCount1 = 0;
|
||||
UINT64 tickRecord;
|
||||
UINT64 tickUpdate;
|
||||
UINT64 deltaTicks;
|
||||
|
||||
// 4, Timeout interval of a periodic software timer.
|
||||
|
||||
@@ -50,7 +50,6 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
task1.pfnTaskEntry = (TSK_ENTRY_FUNC)TaskF01;
|
||||
task1.uwStackSize = LOSCFG_BASE_CORE_TSK_MIN_STACK_SIZE;
|
||||
task1.usTaskPrio = TASK_PRIO_TEST + 1;
|
||||
g_testCount = 0;
|
||||
|
||||
LOS_TaskLock();
|
||||
@@ -64,7 +63,6 @@ static UINT32 TestCase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
}
|
||||
|
||||
task1.usTaskPrio = index % OS_TASK_PRIORITY_LOWEST;
|
||||
task1.pcName = "TskA";
|
||||
task1.uwResved = LOS_TASK_STATUS_DETACHED;
|
||||
ret = LOS_TaskCreate(&testTaskID[index], &task1);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -71,7 +71,7 @@ static VOID TaskF01(VOID)
|
||||
#ifdef __RISC_V__
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
|
||||
#else
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 1);
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, (HwiIrqParam *)1);
|
||||
#endif
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
|
||||
@@ -46,10 +46,8 @@ static VOID TaskF01(UINT32 arg)
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 freeMem;
|
||||
UINT32 freeMem1;
|
||||
UINT32 freeMem2;
|
||||
UINT32 freeMem3;
|
||||
UINT32 freeMem4;
|
||||
UINT32 ret;
|
||||
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
@@ -66,7 +64,7 @@ static UINT32 TestCase(VOID)
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
freeMem1 = GetfreeMemSize(m_aucSysMem0);
|
||||
(VOID)GetfreeMemSize(m_aucSysMem0);
|
||||
|
||||
LOS_TaskDelay(10); // 10, task delay times.
|
||||
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static UINT32 g_freeMem1 = 0;
|
||||
static UINT32 g_freeMem2 = 0;
|
||||
|
||||
static UINT32 GetfreeMemSize(void *pool)
|
||||
{
|
||||
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
|
||||
@@ -55,7 +52,6 @@ static VOID TaskF01(VOID)
|
||||
static UINT32 TestCase(VOID)
|
||||
{
|
||||
UINT32 freeMem;
|
||||
UINT32 freeMem1;
|
||||
UINT32 freeMem2;
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S task1 = { 0 };
|
||||
|
||||
@@ -27,7 +27,138 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
static_library("test_posix") {
|
||||
sources = [ "pthread_func_test.c" ]
|
||||
sources = [
|
||||
"mqueue/It_posix_queue.c",
|
||||
"mqueue/It_posix_queue_001.c",
|
||||
"mqueue/It_posix_queue_002.c",
|
||||
"mqueue/It_posix_queue_003.c",
|
||||
"mqueue/It_posix_queue_004.c",
|
||||
"mqueue/It_posix_queue_005.c",
|
||||
"mqueue/It_posix_queue_006.c",
|
||||
"mqueue/It_posix_queue_007.c",
|
||||
"mqueue/It_posix_queue_008.c",
|
||||
"mqueue/It_posix_queue_009.c",
|
||||
"mqueue/It_posix_queue_010.c",
|
||||
"mqueue/It_posix_queue_011.c",
|
||||
"mqueue/It_posix_queue_012.c",
|
||||
"mqueue/It_posix_queue_013.c",
|
||||
"mqueue/It_posix_queue_014.c",
|
||||
"mqueue/It_posix_queue_015.c",
|
||||
"mqueue/It_posix_queue_016.c",
|
||||
"mqueue/It_posix_queue_017.c",
|
||||
"mqueue/It_posix_queue_018.c",
|
||||
"mqueue/It_posix_queue_019.c",
|
||||
"mqueue/It_posix_queue_020.c",
|
||||
"mqueue/It_posix_queue_021.c",
|
||||
"mqueue/It_posix_queue_022.c",
|
||||
"mqueue/It_posix_queue_023.c",
|
||||
"mqueue/It_posix_queue_024.c",
|
||||
"mqueue/It_posix_queue_025.c",
|
||||
"mqueue/It_posix_queue_026.c",
|
||||
"mqueue/It_posix_queue_027.c",
|
||||
"mqueue/It_posix_queue_028.c",
|
||||
"mqueue/It_posix_queue_029.c",
|
||||
"mqueue/It_posix_queue_030.c",
|
||||
"mqueue/It_posix_queue_031.c",
|
||||
"mqueue/It_posix_queue_032.c",
|
||||
"mqueue/It_posix_queue_033.c",
|
||||
"mqueue/It_posix_queue_034.c",
|
||||
"mqueue/It_posix_queue_035.c",
|
||||
"mqueue/It_posix_queue_036.c",
|
||||
"mqueue/It_posix_queue_037.c",
|
||||
"mqueue/It_posix_queue_038.c",
|
||||
"mqueue/It_posix_queue_039.c",
|
||||
"mqueue/It_posix_queue_040.c",
|
||||
"mqueue/It_posix_queue_041.c",
|
||||
"mqueue/It_posix_queue_042.c",
|
||||
"mqueue/It_posix_queue_043.c",
|
||||
"mqueue/It_posix_queue_044.c",
|
||||
"mqueue/It_posix_queue_045.c",
|
||||
"mqueue/It_posix_queue_046.c",
|
||||
"mqueue/It_posix_queue_047.c",
|
||||
"mqueue/It_posix_queue_048.c",
|
||||
"mqueue/It_posix_queue_049.c",
|
||||
"mqueue/It_posix_queue_050.c",
|
||||
"mqueue/It_posix_queue_051.c",
|
||||
"mqueue/It_posix_queue_052.c",
|
||||
"mutex/It_posix_mutex.c",
|
||||
"mutex/It_posix_mutex_001.c",
|
||||
"mutex/It_posix_mutex_002.c",
|
||||
"mutex/It_posix_mutex_003.c",
|
||||
"mutex/It_posix_mutex_004.c",
|
||||
"mutex/It_posix_mutex_005.c",
|
||||
"mutex/It_posix_mutex_006.c",
|
||||
"mutex/It_posix_mutex_007.c",
|
||||
"mutex/It_posix_mutex_008.c",
|
||||
"mutex/It_posix_mutex_009.c",
|
||||
"mutex/It_posix_mutex_010.c",
|
||||
"mutex/It_posix_mutex_011.c",
|
||||
"mutex/It_posix_mutex_012.c",
|
||||
"mutex/It_posix_mutex_013.c",
|
||||
"mutex/It_posix_mutex_014.c",
|
||||
"mutex/It_posix_mutex_015.c",
|
||||
"mutex/It_posix_mutex_016.c",
|
||||
"mutex/It_posix_mutex_017.c",
|
||||
"mutex/It_posix_mutex_018.c",
|
||||
"mutex/It_posix_mutex_019.c",
|
||||
"mutex/It_posix_mutex_020.c",
|
||||
"mutex/It_posix_mutex_021.c",
|
||||
"mutex/It_posix_mutex_022.c",
|
||||
"mutex/It_posix_mutex_023.c",
|
||||
"mutex/It_posix_mutex_024.c",
|
||||
"mutex/It_posix_mutex_025.c",
|
||||
"mutex/It_posix_mutex_026.c",
|
||||
"mutex/It_posix_mutex_027.c",
|
||||
"mutex/It_posix_mutex_028.c",
|
||||
"mutex/It_posix_mutex_029.c",
|
||||
"mutex/It_posix_mutex_030.c",
|
||||
"mutex/It_posix_mutex_031.c",
|
||||
"mutex/It_posix_mutex_032.c",
|
||||
"mutex/It_posix_mutex_033.c",
|
||||
"mutex/It_posix_mutex_034.c",
|
||||
"mutex/It_posix_mutex_035.c",
|
||||
"mutex/It_posix_mutex_036.c",
|
||||
"mutex/It_posix_mutex_037.c",
|
||||
"mutex/It_posix_mutex_038.c",
|
||||
"mutex/It_posix_mutex_039.c",
|
||||
"mutex/It_posix_mutex_040.c",
|
||||
"mutex/It_posix_mutex_041.c",
|
||||
"mutex/It_posix_mutex_042.c",
|
||||
"mutex/It_posix_mutex_043.c",
|
||||
"mutex/It_posix_mutex_044.c",
|
||||
"mutex/It_posix_mutex_045.c",
|
||||
"mutex/It_posix_mutex_046.c",
|
||||
"mutex/It_posix_mutex_047.c",
|
||||
"mutex/It_posix_mutex_048.c",
|
||||
"mutex/It_posix_mutex_049.c",
|
||||
"pthread/It_posix_pthread.c",
|
||||
"pthread/It_posix_pthread_001.c",
|
||||
"pthread/It_posix_pthread_002.c",
|
||||
"pthread/It_posix_pthread_003.c",
|
||||
"pthread/It_posix_pthread_004.c",
|
||||
"pthread/It_posix_pthread_005.c",
|
||||
"pthread/It_posix_pthread_006.c",
|
||||
"pthread/It_posix_pthread_007.c",
|
||||
"pthread/It_posix_pthread_008.c",
|
||||
"pthread/It_posix_pthread_009.c",
|
||||
"pthread/It_posix_pthread_010.c",
|
||||
"pthread/It_posix_pthread_011.c",
|
||||
"pthread/It_posix_pthread_012.c",
|
||||
"pthread/It_posix_pthread_013.c",
|
||||
"pthread/It_posix_pthread_014.c",
|
||||
"pthread/It_posix_pthread_015.c",
|
||||
"pthread/It_posix_pthread_016.c",
|
||||
"pthread/It_posix_pthread_017.c",
|
||||
"pthread/It_posix_pthread_018.c",
|
||||
"pthread/It_posix_pthread_019.c",
|
||||
"pthread/It_posix_pthread_020.c",
|
||||
"pthread/It_posix_pthread_021.c",
|
||||
"pthread/It_posix_pthread_022.c",
|
||||
"pthread/It_posix_pthread_023.c",
|
||||
"pthread/It_posix_pthread_024.c",
|
||||
"pthread/It_posix_pthread_025.c",
|
||||
"pthread_func_test.c",
|
||||
]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuites:include" ]
|
||||
}
|
||||
|
||||
107
testsuites/sample/posix/mqueue/It_posix_queue.c
Normal file
107
testsuites/sample/posix/mqueue/It_posix_queue.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Copyright (c) 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 "stdio.h"
|
||||
#include "It_posix_queue.h"
|
||||
|
||||
CHAR *g_mqueueMsessage[MQUEUE_SHORT_ARRAY_LENGTH] = {"0123456789", "1234567890", "2345678901",
|
||||
"3456789012", "4567890123", "5678901234",
|
||||
"6789012345", "7890123456", "lalalalala",
|
||||
"hahahahaha"};
|
||||
CHAR g_gqname[MQUEUE_STANDARD_NAME_LENGTH];
|
||||
CHAR g_mqueueName[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1][MQUEUE_STANDARD_NAME_LENGTH];
|
||||
mqd_t g_mqueueId[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
|
||||
SEM_HANDLE_T g_mqueueSem;
|
||||
mqd_t g_messageQId;
|
||||
mqd_t g_gqueue;
|
||||
|
||||
VOID TestAssertWaitDelay(UINT32 *testCount, UINT32 flag)
|
||||
{
|
||||
while (*testCount != flag) {
|
||||
usleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
VOID ItSuitePosixMqueue(void)
|
||||
{
|
||||
printf("*********** BEGIN SAMPLE POSIX MQUEUE TEST ************\n");
|
||||
ItPosixQueue001();
|
||||
ItPosixQueue002();
|
||||
ItPosixQueue003();
|
||||
ItPosixQueue004();
|
||||
ItPosixQueue005();
|
||||
ItPosixQueue006();
|
||||
ItPosixQueue007();
|
||||
ItPosixQueue008();
|
||||
ItPosixQueue009();
|
||||
ItPosixQueue010();
|
||||
ItPosixQueue011();
|
||||
ItPosixQueue012();
|
||||
ItPosixQueue013();
|
||||
ItPosixQueue014();
|
||||
ItPosixQueue015();
|
||||
ItPosixQueue016();
|
||||
ItPosixQueue017();
|
||||
ItPosixQueue018();
|
||||
ItPosixQueue019();
|
||||
ItPosixQueue020();
|
||||
ItPosixQueue021();
|
||||
ItPosixQueue022();
|
||||
ItPosixQueue023();
|
||||
ItPosixQueue024();
|
||||
ItPosixQueue025();
|
||||
ItPosixQueue026();
|
||||
ItPosixQueue027();
|
||||
ItPosixQueue028();
|
||||
ItPosixQueue029();
|
||||
ItPosixQueue030();
|
||||
ItPosixQueue031();
|
||||
ItPosixQueue032();
|
||||
ItPosixQueue033();
|
||||
ItPosixQueue034();
|
||||
ItPosixQueue035();
|
||||
ItPosixQueue036();
|
||||
ItPosixQueue037();
|
||||
ItPosixQueue038();
|
||||
ItPosixQueue039();
|
||||
ItPosixQueue040();
|
||||
ItPosixQueue041();
|
||||
ItPosixQueue042();
|
||||
ItPosixQueue043();
|
||||
ItPosixQueue044();
|
||||
ItPosixQueue045();
|
||||
ItPosixQueue046();
|
||||
ItPosixQueue047();
|
||||
ItPosixQueue048();
|
||||
ItPosixQueue049();
|
||||
ItPosixQueue050();
|
||||
ItPosixQueue051();
|
||||
ItPosixQueue052();
|
||||
}
|
||||
160
testsuites/sample/posix/mqueue/It_posix_queue.h
Normal file
160
testsuites/sample/posix/mqueue/It_posix_queue.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Copyright (c) 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.
|
||||
*/
|
||||
|
||||
#ifndef IT_POSIX_QUEUE_H
|
||||
#define IT_POSIX_QUEUE_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <mqueue.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
#include <osTest.h>
|
||||
#include "pthread.h"
|
||||
|
||||
#define MAXMSG5 5
|
||||
#define MSGLEN 10
|
||||
#define MAXMSG 10
|
||||
|
||||
#define MQUEUE_SEND_STRING_TEST "0123456789"
|
||||
#define MQUEUE_SHORT_ARRAY_LENGTH 10 // 10: strlen(MQUEUE_SEND_STRING_TEST)
|
||||
#define MQUEUE_STANDARD_NAME_LENGTH 50
|
||||
|
||||
#define MQUEUE_PTHREAD_PRIORITY_TEST1 3
|
||||
#define MQUEUE_PTHREAD_PRIORITY_TEST2 4
|
||||
#define MQUEUE_PATH_MAX_TEST PATH_MAX
|
||||
#define MQUEUE_NAME_MAX_TEST NAME_MAX
|
||||
#define MQUEUE_PTHREAD_NUM_TEST 5
|
||||
#define MQUEUE_PRIORITY_TEST 0
|
||||
#define MQUEUE_TIMEOUT_TEST 7
|
||||
#define MQUEUE_PRIORITY_NUM_TEST 3
|
||||
#define MQUEUE_MAX_NUM_TEST (LOSCFG_BASE_IPC_QUEUE_CONFIG - QUEUE_EXISTED_NUM)
|
||||
#define MQ_MAX_MSG_NUM 16
|
||||
#define MQ_MAX_MSG_LEN 64
|
||||
#define HWI_NUM_TEST 1
|
||||
#define HWI_NUM_TEST1 2
|
||||
|
||||
#if (LOSCFG_LIBC_NEWLIB == 1)
|
||||
#define MQ_PRIO_MAX 1
|
||||
#endif
|
||||
|
||||
#define LOSCFG_BASE_IPC_QUEUE_CONFIG 1024
|
||||
|
||||
#define LOS_AtomicInc(a) (++*(a))
|
||||
#define MqueueTaskDelay(tick) (usleep((tick) * 10000))
|
||||
|
||||
#ifdef __LP64__
|
||||
#define PER_ADDED_VALUE 8
|
||||
#else
|
||||
#define PER_ADDED_VALUE 4
|
||||
#endif
|
||||
|
||||
#define ICUNIT_GOTO_WITHIN_EQUAL(param, value1, value2, retcode, label) \
|
||||
do { \
|
||||
if ((param) < (value1) || (param) > (value2)) { \
|
||||
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
|
||||
goto label; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
typedef UINT32 TSK_HANDLE_T;
|
||||
typedef UINT32 SEM_HANDLE_T ;
|
||||
|
||||
extern SEM_HANDLE_T g_mqueueSem;
|
||||
|
||||
static TSK_HANDLE_T g_mqueueTaskPID;
|
||||
extern CHAR g_gqname[MQUEUE_STANDARD_NAME_LENGTH];
|
||||
extern CHAR g_mqueueName[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1][MQUEUE_STANDARD_NAME_LENGTH];
|
||||
extern mqd_t g_mqueueId[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
|
||||
|
||||
extern CHAR *g_mqueueMsessage[MQUEUE_SHORT_ARRAY_LENGTH];
|
||||
extern mqd_t g_messageQId;
|
||||
extern mqd_t g_gqueue;
|
||||
|
||||
extern VOID ItSuitePosixMqueue(VOID);
|
||||
extern UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri);
|
||||
extern UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread);
|
||||
extern VOID TestAssertWaitDelay(UINT32 *testCount, UINT32 flag);
|
||||
|
||||
VOID ItPosixQueue001(VOID);
|
||||
VOID ItPosixQueue002(VOID);
|
||||
VOID ItPosixQueue003(VOID);
|
||||
VOID ItPosixQueue004(VOID);
|
||||
VOID ItPosixQueue005(VOID);
|
||||
VOID ItPosixQueue006(VOID);
|
||||
VOID ItPosixQueue007(VOID);
|
||||
VOID ItPosixQueue008(VOID);
|
||||
VOID ItPosixQueue009(VOID);
|
||||
VOID ItPosixQueue010(VOID);
|
||||
VOID ItPosixQueue011(VOID);
|
||||
VOID ItPosixQueue012(VOID);
|
||||
VOID ItPosixQueue013(VOID);
|
||||
VOID ItPosixQueue014(VOID);
|
||||
VOID ItPosixQueue015(VOID);
|
||||
VOID ItPosixQueue016(VOID);
|
||||
VOID ItPosixQueue017(VOID);
|
||||
VOID ItPosixQueue018(VOID);
|
||||
VOID ItPosixQueue019(VOID);
|
||||
VOID ItPosixQueue020(VOID);
|
||||
VOID ItPosixQueue021(VOID);
|
||||
VOID ItPosixQueue022(VOID);
|
||||
VOID ItPosixQueue023(VOID);
|
||||
VOID ItPosixQueue024(VOID);
|
||||
VOID ItPosixQueue025(VOID);
|
||||
VOID ItPosixQueue026(VOID);
|
||||
VOID ItPosixQueue027(VOID);
|
||||
VOID ItPosixQueue028(VOID);
|
||||
VOID ItPosixQueue029(VOID);
|
||||
VOID ItPosixQueue030(VOID);
|
||||
VOID ItPosixQueue031(VOID);
|
||||
VOID ItPosixQueue032(VOID);
|
||||
VOID ItPosixQueue033(VOID);
|
||||
VOID ItPosixQueue034(VOID);
|
||||
VOID ItPosixQueue035(VOID);
|
||||
VOID ItPosixQueue036(VOID);
|
||||
VOID ItPosixQueue037(VOID);
|
||||
VOID ItPosixQueue038(VOID);
|
||||
VOID ItPosixQueue039(VOID);
|
||||
VOID ItPosixQueue040(VOID);
|
||||
VOID ItPosixQueue041(VOID);
|
||||
VOID ItPosixQueue042(VOID);
|
||||
VOID ItPosixQueue043(VOID);
|
||||
VOID ItPosixQueue044(VOID);
|
||||
VOID ItPosixQueue045(VOID);
|
||||
VOID ItPosixQueue046(VOID);
|
||||
VOID ItPosixQueue047(VOID);
|
||||
VOID ItPosixQueue048(VOID);
|
||||
VOID ItPosixQueue049(VOID);
|
||||
VOID ItPosixQueue050(VOID);
|
||||
VOID ItPosixQueue051(VOID);
|
||||
VOID ItPosixQueue052(VOID);
|
||||
#endif
|
||||
76
testsuites/sample/posix/mqueue/It_posix_queue_001.c
Normal file
76
testsuites/sample/posix/mqueue/It_posix_queue_001.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
struct mq_attr attr = {0};
|
||||
mqd_t mqueue;
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = 0;
|
||||
|
||||
(void)snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH - 1, MQUEUE_STANDARD_NAME_LENGTH, "/mq001_%d",
|
||||
LOS_CurTaskIDGet());
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue001
|
||||
* @tc.desc: Test interface mq_open
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue001", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
84
testsuites/sample/posix/mqueue/It_posix_queue_002.c
Normal file
84
testsuites/sample/posix/mqueue/It_posix_queue_002.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
struct mq_attr attr = {0};
|
||||
mqd_t mqueue;
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = 1;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq002_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT1);
|
||||
ICUNIT_GOTO_STRING_EQUAL(msgrcd, MQUEUE_SEND_STRING_TEST, msgrcd, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT2:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue002
|
||||
* @tc.desc: Test interface mq_send
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue002", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
80
testsuites/sample/posix/mqueue/It_posix_queue_003.c
Normal file
80
testsuites/sample/posix/mqueue/It_posix_queue_003.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrv1[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
struct mq_attr attr = {0};
|
||||
INT32 ret = 0;
|
||||
INT32 i;
|
||||
pthread_t pthread1;
|
||||
pthread_t pthread2;
|
||||
mqd_t mqueue1;
|
||||
mqd_t mqueue2;
|
||||
struct timespec ts;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||
"/mq003_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
|
||||
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1);
|
||||
|
||||
mqueue2 = mq_open(mqname, O_RDWR | O_EXCL, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(mqueue2, (mqd_t)-1, mqueue2);
|
||||
|
||||
ts.tv_sec = 1;
|
||||
ts.tv_nsec = 1;
|
||||
ret = mq_timedreceive(mqueue1, msgrv1, MQUEUE_STANDARD_NAME_LENGTH, NULL, &ts);
|
||||
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||
|
||||
EXIT:
|
||||
mq_close(mqueue1);
|
||||
mq_close(mqueue2);
|
||||
mq_unlink(mqname);
|
||||
EXIT1:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue003
|
||||
* @tc.desc: Test interface mq_timedreceive
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue003(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue003", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
64
testsuites/sample/posix/mqueue/It_posix_queue_004.c
Normal file
64
testsuites/sample/posix/mqueue/It_posix_queue_004.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq004_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||
mqueue = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
mq_close(mqueue);
|
||||
mq_unlink(mqname);
|
||||
EXIT1:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue004
|
||||
* @tc.desc: Test interface mq_open
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue004(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue004", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
78
testsuites/sample/posix/mqueue/It_posix_queue_005.c
Normal file
78
testsuites/sample/posix/mqueue/It_posix_queue_005.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t roqueue;
|
||||
mqd_t roqueue2;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq005_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||
|
||||
roqueue = mq_open(mqname, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(roqueue, (mqd_t)-1, roqueue, EXIT);
|
||||
|
||||
roqueue2 = mq_open(mqname, O_RDONLY, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(roqueue2, (mqd_t)-1, roqueue2, EXIT1);
|
||||
|
||||
ret = mq_close(roqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_close(roqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT1:
|
||||
mq_close(roqueue2);
|
||||
EXIT:
|
||||
mq_close(roqueue);
|
||||
mq_unlink(mqname);
|
||||
EXIT2:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue005
|
||||
* @tc.desc: Test interface mq_close
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue005(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue005", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
96
testsuites/sample/posix/mqueue/It_posix_queue_006.c
Normal file
96
testsuites/sample/posix/mqueue/It_posix_queue_006.c
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd2[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t rdwrqueue;
|
||||
mqd_t rdwrqueue2;
|
||||
struct mq_attr attr = {0};
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq006_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
rdwrqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(rdwrqueue, (mqd_t)-1, rdwrqueue, EXIT);
|
||||
|
||||
ret = mq_send(rdwrqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = mq_receive(rdwrqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT);
|
||||
|
||||
rdwrqueue2 = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(rdwrqueue2, (mqd_t)-1, rdwrqueue2, EXIT1);
|
||||
|
||||
ret = mq_send(rdwrqueue2, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_receive(rdwrqueue2, msgrcd2, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
|
||||
|
||||
ret = mq_close(rdwrqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_close(rdwrqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT1:
|
||||
mq_close(rdwrqueue2);
|
||||
EXIT:
|
||||
mq_close(rdwrqueue);
|
||||
mq_unlink(mqname);
|
||||
EXIT2:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue006
|
||||
* @tc.desc: Test interface mq_receive
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue006(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue006", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
86
testsuites/sample/posix/mqueue/It_posix_queue_007.c
Normal file
86
testsuites/sample/posix/mqueue/It_posix_queue_007.c
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret = 0;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue1;
|
||||
mqd_t mqueue2;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq007_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||
|
||||
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue1, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
mqueue2 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue2, (mqd_t)-1, mqueue2, EXIT2);
|
||||
|
||||
ret = mq_send(mqueue2, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue1);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT2:
|
||||
mq_close(mqueue2);
|
||||
EXIT1:
|
||||
mq_close(mqueue1);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT3:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue007
|
||||
* @tc.desc: Test interface mq_close
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue007(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue007", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
78
testsuites/sample/posix/mqueue/It_posix_queue_008.c
Normal file
78
testsuites/sample/posix/mqueue/It_posix_queue_008.c
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = {0};
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq008_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_getattr(mqueue, &attr);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_curmsgs, 0, attr.mq_curmsgs, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_flags, O_CREAT | O_RDWR, attr.mq_flags, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_maxmsg, MQ_MAX_MSG_NUM, attr.mq_maxmsg, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attr.mq_msgsize, MQ_MAX_MSG_LEN, attr.mq_msgsize, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT2:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue008
|
||||
* @tc.desc: Test interface mq_getattr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue008(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue008", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
85
testsuites/sample/posix/mqueue/It_posix_queue_009.c
Normal file
85
testsuites/sample/posix/mqueue/It_posix_queue_009.c
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
struct mq_attr attr = {0};
|
||||
struct mq_attr attrget;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq009_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||
|
||||
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||
attr.mq_msgsize = 5; // 5, queue message size.
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_getattr(mqueue, &attrget);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_curmsgs, 0, attrget.mq_curmsgs, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_flags, O_CREAT | O_RDWR | O_NONBLOCK, attrget.mq_flags, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_maxmsg, attr.mq_maxmsg, attrget.mq_maxmsg, EXIT1);
|
||||
ICUNIT_GOTO_EQUAL(attrget.mq_msgsize, attr.mq_msgsize, attrget.mq_msgsize, EXIT1);
|
||||
|
||||
if (!(attrget.mq_flags & O_NONBLOCK)) {
|
||||
goto EXIT1;
|
||||
}
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT2:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue009
|
||||
* @tc.desc: Test interface mq_getattr
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue009(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue009", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
76
testsuites/sample/posix/mqueue/It_posix_queue_010.c
Normal file
76
testsuites/sample/posix/mqueue/It_posix_queue_010.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue1;
|
||||
mqd_t mqueue2;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq010_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||
|
||||
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||
|
||||
mqueue2 = mq_open(mqname, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue2, (mqd_t)-1, mqueue2, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue1);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT2:
|
||||
mq_close(mqueue2);
|
||||
EXIT1:
|
||||
mq_close(mqueue1);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT3:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue010
|
||||
* @tc.desc: Test interface mq_unlink
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue010(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue010", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
74
testsuites/sample/posix/mqueue/It_posix_queue_011.c
Normal file
74
testsuites/sample/posix/mqueue/It_posix_queue_011.c
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq011_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT2:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue011
|
||||
* @tc.desc: Test interface mq_send
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue011(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue011", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
95
testsuites/sample/posix/mqueue/It_posix_queue_012.c
Normal file
95
testsuites/sample/posix/mqueue/It_posix_queue_012.c
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||
mqd_t mqueue1;
|
||||
mqd_t mqueue2;
|
||||
struct mq_attr attr = {0};
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq012_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||
|
||||
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||
|
||||
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||
|
||||
ret = mq_receive(mqueue1, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||
|
||||
ret = mq_send(mqueue1, msgptr, strlen(msgptr), 0);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
mqueue2 = mq_open(mqname, O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT2);
|
||||
|
||||
ret = mq_receive(mqueue1, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue1);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||
|
||||
ret = mq_close(mqueue2);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT2:
|
||||
mq_close(mqueue2);
|
||||
EXIT1:
|
||||
mq_close(mqueue1);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT3:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue012
|
||||
* @tc.desc: Test interface mq_receive
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue012(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue012", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
72
testsuites/sample/posix/mqueue/It_posix_queue_013.c
Normal file
72
testsuites/sample/posix/mqueue/It_posix_queue_013.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
struct sigevent ev;
|
||||
struct sigaction act;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq013_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||
|
||||
ret = mq_close(mqueue);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||
|
||||
ret = mq_unlink(mqname);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT1:
|
||||
mq_close(mqueue);
|
||||
EXIT:
|
||||
mq_unlink(mqname);
|
||||
EXIT2:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue013
|
||||
* @tc.desc: Test interface mq_close
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue013(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue013", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
64
testsuites/sample/posix/mqueue/It_posix_queue_014.c
Normal file
64
testsuites/sample/posix/mqueue/It_posix_queue_014.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t mqueue;
|
||||
|
||||
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||
"/mq014_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||
|
||||
mqueue = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
mq_close(mqueue);
|
||||
mq_unlink(mqname);
|
||||
EXIT1:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue014
|
||||
* @tc.desc: Test interface mq_open
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue014(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue014", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
72
testsuites/sample/posix/mqueue/It_posix_queue_015.c
Normal file
72
testsuites/sample/posix/mqueue/It_posix_queue_015.c
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
#define QUEUE_NAME_MAX_LEN (MQUEUE_NAME_MAX_TEST * 2)
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
CHAR mqname[QUEUE_NAME_MAX_LEN];
|
||||
mqd_t mqueue;
|
||||
UINT32 ret;
|
||||
INT32 i;
|
||||
|
||||
ret = snprintf_s(mqname, QUEUE_NAME_MAX_LEN, QUEUE_NAME_MAX_LEN - 1, \
|
||||
"/mq015_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||
|
||||
for (i = 0; i < MQUEUE_NAME_MAX_TEST; i++) {
|
||||
ret = strcat_s(mqname, QUEUE_NAME_MAX_LEN, "0");
|
||||
ICUNIT_ASSERT_EQUAL(ret, EOK, ret);
|
||||
}
|
||||
|
||||
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENAMETOOLONG, errno);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
mq_close(mqueue);
|
||||
mq_unlink(mqname);
|
||||
EXIT1:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue015
|
||||
* @tc.desc: Test interface mq_open
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue015(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue015", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
64
testsuites/sample/posix/mqueue/It_posix_queue_016.c
Normal file
64
testsuites/sample/posix/mqueue/It_posix_queue_016.c
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright (c) 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 "It_posix_queue.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
CHAR qname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||
mqd_t queue;
|
||||
|
||||
ret = snprintf_s(qname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||
"/mq016-1_%d", LOS_CurTaskIDGet());
|
||||
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||
|
||||
queue = mq_open(qname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||
ICUNIT_GOTO_EQUAL(queue, (mqd_t)-1, queue, EXIT);
|
||||
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
mq_close(queue);
|
||||
mq_unlink(qname);
|
||||
EXIT1:
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixQueue016
|
||||
* @tc.desc: Test interface mq_open
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI603SR6
|
||||
*/
|
||||
|
||||
VOID ItPosixQueue016(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixQueue016", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user