Compare commits

..

66 Commits

Author SHA1 Message Date
openharmony_ci
9f19fd2e7a !918 Fix : POSIX 测试用例补充
Merge pull request !918 from yinjiaming/test-3
2022-11-22 06:58:12 +00:00
openharmony_ci
c10037d379 !877 更新liteos_m内核架构图
Merge pull request !877 from zhushengle/arch
2022-11-22 03:44:02 +00:00
yinjiaming
b483627ec7 fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix/mqueue 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I64efeb7d3ae3dbd966b716bf8e296a9eb0f5db06
2022-11-21 19:29:44 +08:00
openharmony_ci
d120f1e57a !921 其他分区已mount时会引起格式化失败
Merge pull request !921 from wangchen/1117_m
2022-11-18 09:34:41 +00:00
openharmony_ci
765add9660 !917 告警清理
Merge pull request !917 from 乔克叔叔/master
2022-11-18 09:15:46 +00:00
openharmony_ci
a650df0575 !916 修复用例告警
Merge pull request !916 from xuxinyu/1116
2022-11-18 09:14:03 +00:00
wangchen
08436dec9e fix: 其他分区已mount时会引起格式化失败
【背景】其他分区已mount时会引起格式化失败

【修改方案】
1, 格式化时判断方式修改为路径

【影响】
对现有的产品编译不会有影响。
re #I61P4K
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-18 06:31:12 +00:00
openharmony_ci
0818b28aa7 !919 fix:逗号格式错误
Merge pull request !919 from Hongjin Li/warning
2022-11-17 12:57:15 +00:00
Hongjin Li
2dc3998956 fix: add space after comma
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-11-17 20:15:53 +08:00
zhushengle
266a49fb88 feat: 更新liteos_m内核架构图
Close #I61OZZ

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I90afb1c83a9a34597e7b9699a784ad0fbff30f81
2022-11-17 18:41:40 +08:00
liuwenxin
fa6f0c393d fix:告警清理
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-17 17:23:44 +08:00
openharmony_ci
3019311435 !910 Fix : POSIX 测试用例补充
Merge pull request !910 from yinjiaming/test-2
2022-11-16 09:50:31 +00:00
xuxinyu
b25148107b fix:修复用例告警
Signed-off-by: xuxinyu <xuxinyu6@huawei.com>
Change-Id: Ide6f04adcd3bb12ae296f981cab84f9d7ce867fc
2022-11-16 15:55:34 +08:00
openharmony_ci
aee957bb1f !909 修复mount接口对MS_REMOUNT的支持
Merge pull request !909 from Far/master
2022-11-15 14:17:19 +00:00
Far
64d15df9ea fix: fix the MS_REMOUNT support
The mount interface can't deal with MS_REMOUNT flag now, fix it.

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Id0960c8d92ce767b8d8ef98b3ba2e1d1ab7db15d
2022-11-15 17:05:21 +08:00
yinjiaming
8e58b984ea fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix/mqueue 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I64efeb7d3ae3dbd966b716bf8e296a9eb0f5db06
2022-11-15 16:54:28 +08:00
openharmony_ci
be1267fafa !903 fix: 修复测试用例断言宏使用不规范的问题
Merge pull request !903 from Zhaotianyu/20221110test_fix_assert
2022-11-14 09:41:12 +00:00
openharmony_ci
6cb544b158 !892 m告警清理
Merge pull request !892 from 乔克叔叔/master
2022-11-14 08:50:22 +00:00
openharmony_ci
5e8225273f !904 Fix : 内核告警清理
Merge pull request !904 from yinjiaming/fix
2022-11-14 08:35:08 +00:00
openharmony_ci
aec7a45411 !894 Fix : POSIX 测试用例补充
Merge pull request !894 from yinjiaming/test-1
2022-11-14 08:34:29 +00:00
liuwenxin
2806c4af75 Fix:m核告警清理
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-11 17:40:25 +08:00
yinjiaming
7e442ddd61 fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix/mqueue 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I64efeb7d3ae3dbd966b716bf8e296a9eb0f5db06
2022-11-11 11:56:13 +08:00
openharmony_ci
527cec6e27 !906 RISC-V架构解依赖平台soc.h
Merge pull request !906 from zhushengle/soc
2022-11-10 12:47:40 +00:00
zhushengle
d68b5f0ab3 task: RISC-V架构解依赖平台soc.h
Close #I5M7JE

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I98f9f2a5d69576540a270778bf37899594c527f2
2022-11-10 18:45:27 +08:00
openharmony_ci
1cd2ae7b4e !901 risc-v系统异常时无法输出异常信息
Merge pull request !901 from zhushengle/medeleg
2022-11-10 10:30:50 +00:00
arvinzzz
27ed27eb89 fix: 修复测试用例断言宏使用不规范的问题
Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-11-10 17:45:43 +08:00
yinjiaming
098c5ea24d fix: 内核告警清理
Change-Id: Ic6d335964da545bc71edd40669c82b6f85e1bad6
Signed-off-by: yinjiaming <yinjiaming@huawei.com>
2022-11-10 17:32:52 +08:00
zhushengle
914913fab6 task: risc-v系统异常时取消对medeleg寄存器的保存
部分开源架构不支持该寄存器,且非常用寄存器

Close #I60IS5
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I8db31f84a24cc6143513c725691e4ba780ca99e9
2022-11-10 16:29:27 +08:00
openharmony_ci
2f08268983 !895 fix: buffersize paramter type error
Merge pull request !895 from Hongjin Li/fix
2022-11-09 09:29:57 +00:00
Hongjin Li
807c7e64cb fix: buffersize parameter type error
Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-11-09 16:49:59 +08:00
openharmony_ci
fc87e459d1 !891 在LOS_QueueReadCopy 和 LOS_QueueWriteCopy中增加hook函数
Merge pull request !891 from Hongjin Li/add_hook_call
2022-11-09 08:41:16 +00:00
lihongjin
c3d75f64b1 feat: add hook call in LOS_QueueReadCopy and LOS_QueueWriteCopy
Signed-off-by: lihongjin <lihongjin1@huawei.com>
Change-Id: I0c8ecb6e364d8e01b48f78847c25da6bc4cb961c
2022-11-08 18:32:41 +08:00
openharmony_ci
f447d15e78 !893 M核fs用例整改
Merge pull request !893 from wangchen/1108_test
2022-11-08 08:04:55 +00:00
wangchen
642d5ef709 fix: M核fs用例整改
【背景】M核fs用例整改

【修改方案】
1,增加部分判断,适配fatfs
2,增加部分接口

【影响】
对现有的产品编译不会有影响。
re #I5Z4DL
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-08 07:26:06 +00:00
openharmony_ci
74bbfa4893 !853 fix:修复文档中失效链接
Merge pull request !853 from zhangdengyu/fix_links_1019
2022-11-08 03:31:18 +00:00
openharmony_ci
fe5a091ca2 !864 feat: 支持mutex trace
Merge pull request !864 from zhangdengyu/add_mutex_trace_1028
2022-11-08 03:07:54 +00:00
openharmony_ci
c83b98ecbf !868 告警清理
Merge pull request !868 from 乔克叔叔/master
2022-11-07 10:57:34 +00:00
openharmony_ci
c9a96bc4b3 !886 cortex-m4支持iar编译器的gn适配
Merge pull request !886 from yiweiniunan/master
2022-11-07 10:34:19 +00:00
yiweiniunan
62cd8fec46 cortex-m4支持iar编译器的gn适配
Signed-off-by: yiweiniunan <michael.likai@huawei.com>
2022-11-07 16:15:29 +08:00
liuwenxin
8b54493665 fix:告警清理
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-07 14:58:48 +08:00
zhangdengyu
a940dda69a feat: 增加mutex trace功能
Close: #I5YJOZ

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: Id36ed4f4d23b9aa59ae9ee8cdb17c06d7e3c151b
2022-11-07 08:42:06 +08:00
openharmony_ci
1bc63d743b !881 feat: 提供死机场景下dump文件能力
Merge pull request !881 from Zhaotianyu/20221105vfs_lock
2022-11-07 00:41:11 +00:00
arvinzzz
474201593d feat: 提供死机场景下dump文件的能力
死机场景下,vfs层锁会放开,提供dump文件的能力

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Id8c9e63fbf011dbc6690b9b4557bd3370353bf21
2022-11-05 17:58:37 +08:00
openharmony_ci
3f54fdc898 !846 修复shell删除命令误删目录的问题
Merge pull request !846 from 方烨/master
2022-11-04 08:24:17 +00:00
openharmony_ci
8ac6771e0d !869 Fix : 给LOS_MuxDelete 函数前添加(VOID)
Merge pull request !869 from yinjiaming/fix
2022-11-04 08:23:38 +00:00
openharmony_ci
7101ddbeb8 !874 feat: pm idle添加到menuconfig中
Merge pull request !874 from zhushengle/pm_ilde
2022-11-03 14:10:34 +00:00
openharmony_ci
abbed4430e !847 解决部分平台ping失败
Merge pull request !847 from huohongpeng/ping_checksum
2022-11-03 14:05:50 +00:00
zhushengle
98d20e90ed feat: pm idle添加到menuconfig中
Close #I5ZD5L
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ibdedff3043a0902aa3cd9539497ef97fb6a1ce6c
2022-11-03 21:32:45 +08:00
openharmony_ci
9767191392 !859 Fix : POSIX 测试用例补充
Merge pull request !859 from yinjiaming/test-4
2022-11-03 02:17:32 +00:00
openharmony_ci
e540254ed9 !862 feature:支持厂商自定义malloc替换系统默认实现
Merge pull request !862 from Zhaotianyu/20221028iar_malloc
2022-11-01 13:48:15 +00:00
yinjiaming
ad4ef11410 fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I65adfd00faec185bcad3c1e38e305ce9e8cb9346
2022-11-01 16:26:56 +08:00
yinjiaming
20ffd89865 fix: 给函数LOS_MutexDelete 前添加(VOID)
Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I49a7c305e955bccca78b80ddeea66330e8b03ac0
2022-11-01 15:43:18 +08:00
arvinzzz
ae8d4fd275 feature: 支持厂商定制malloc替换系统默认实现
malloc的相关支持可以通过make menuconfig配置

close: #I5YBPE

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Ic40968aa83f43f539f7551c1dcec05f4f9832983
2022-10-28 18:53:53 +08:00
openharmony_ci
972d765c6e !861 Test : POSIX 测试用例补充
Merge pull request !861 from vincent-zhang/myfeature
2022-10-28 02:09:45 +00:00
vincent
47f883c11a zhangadong@huawei.com
Signed-off-by: vincent <zhangadong@huawei.com>
2022-10-28 09:33:36 +08:00
openharmony_ci
478b41b457 !857 Fix : POSIX 测试用例补充
Merge pull request !857 from yinjiaming/test-2
2022-10-26 06:33:41 +00:00
yinjiaming
69d17d522c fix: POSIX 测试用例后续补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib8ab772f9893e243ace9319cb7af1486a6bd2937
2022-10-25 15:45:33 +08:00
fangye
d4bfb577ef fix: 修复shell删除命令误删目录的问题
Signed-off-by: fangye <fangye@talkweb.com.cn>
Change-Id: Ia8f26ff4b250a6540f5644e2dd38fb22cd85d326
2022-10-25 12:19:46 +08:00
openharmony_ci
6e6cbe5de6 !855 Fix : POSIX 测试用例补充
Merge pull request !855 from yinjiaming/test-1
2022-10-24 11:11:57 +00:00
yinjiaming
383a1d23e9 fix: POSIX 测试用例补充
【背景】
kernel_litos_m 中需要补充 POSIX 相关的测试用例

【修改方案】
从 A 核中移植了一部分的POSIX 相关的测试用例
到 sample/posix 目录下

【影响】
对现有的产品编译不会有影响

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib8ab772f9893e243ace9319cb7af1486a6bd2937
2022-10-24 15:39:20 +08:00
openharmony_ci
b24353cf4b !854 Fix : 使用 newlibc 编译测试用例时报错
Merge pull request !854 from yinjiaming/master
2022-10-21 09:58:50 +00:00
openharmony_ci
f1ad086665 !842 cmsis测试用例补充
Merge pull request !842 from 乔克叔叔/branchname
2022-10-21 09:12:17 +00:00
yinjiaming
8fff50f59f fix: newlibc 编译错误修正
【背景】
使用newlibc 编译测试用例时会有编译错误

【修改方案】
删去了 newlibc 中没有的宏定义

【影响】
对现有的产品编译不会有影响。

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Id753640253e1b297654b3e523ddd5ca0abdca698
2022-10-20 19:52:32 +08:00
zhangdengyu
373d4f5649 fix: 修复文档中失效链接
Close: #I5WGWU

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I8c37da09e85e823edd59ebf65a3e284596b7bef9
2022-10-19 10:21:05 +08:00
Hongpeng Huo
3c8d20a89e fix: icmp hardware checksum failed for dwc gmac ip core
Signed-off-by: Hongpeng Huo <hongpeng.huo@hpmicro.com>
2022-10-17 20:33:11 +08:00
wenxin-liu_admin
a502a0917c :cmsis 测试用例补充
Signed-off-by: wenxin-liu_admin <liuwenxin11@huawei.com>
Change-Id: Iaa133871c465e20170a3bf2204cb1c6ba40fda72
2022-09-30 15:53:58 +08:00
196 changed files with 10696 additions and 550 deletions

18
Kconfig
View File

@@ -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

View File

@@ -11,7 +11,7 @@
OpenHarmony LiteOS-M内核是面向IoT领域构建的轻量级物联网操作系统内核具有小体积、低功耗、高性能的特点其代码结构简单主要包括内核最小功能集、内核抽象层、可选组件以及工程目录等分为硬件相关层以及硬件无关层硬件相关层提供统一的HALHardware Abstraction Layer接口提升硬件易适配性不同编译工具链和芯片架构的组合分类满足AIoT类型丰富的硬件和编译工具链的拓展。其架构图如图1所示
**图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
**图 1** OpenHarmony LiteOS-M核内核架构图<a name="fig0865152210223"></a>
![](figures/OpenHarmony-LiteOS-M核内核架构图.png "OpenHarmony-LiteOS-M核内核架构图")
## 目录<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源码

View 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 = [ "." ]
}

View File

@@ -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

View File

@@ -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"); \

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -184,6 +184,12 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
goto errout;
}
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;

View File

@@ -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);
}

View File

@@ -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,7 +123,7 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
return bestMp;
}
STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType, unsigned long mountflags)
STATIC struct MountPoint *VfsMountPointInit(const char *target, const char *fsType, unsigned long mountflags)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
@@ -155,6 +156,27 @@ STATIC struct MountPoint *MountPointInit(const char *target, const char *fsType,
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)
@@ -169,7 +191,13 @@ int LOS_FsMount(const char *source, const char *target,
(void)VfsLock();
mp = MountPointInit(target, fsType, mountflags);
if (mountflags & MS_REMOUNT) {
ret = VfsRemount(source, target, fsType, mountflags, data);
VfsUnlock();
return ret;
}
mp = VfsMountPointInit(target, fsType, mountflags);
if (mp == NULL) {
VfsUnlock();
return (int)LOS_NOK;

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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) {

View File

@@ -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);

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

View File

@@ -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;

View File

@@ -43,6 +43,7 @@ rsource "newlib/Kconfig"
config LIBC_ICCARM
bool "iar libc"
depends on COMPILER_ICCARM
rsource "iccarm/Kconfig"
endchoice

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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)) {

View File

@@ -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
}

View File

@@ -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.

View File

@@ -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

View File

@@ -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) */

View File

@@ -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);
}

View File

@@ -618,7 +618,7 @@ VOID LOS_SchedTickHandler(VOID)
VOID LOS_Schedule(VOID)
{
if (g_taskScheduled && LOS_CHECK_SCHEDULE) {
if (OsCheckKernelRunning()) {
ArchTaskSchedule();
}
}

View File

@@ -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;
}

View File

@@ -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;
@@ -112,19 +111,20 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis007, Function | MediumTest | Level1)
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);
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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++;

View File

@@ -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:

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -37,7 +37,7 @@ static VOID TaskF01(VOID)
{
}
VOID ItHwiM3B001F001()
static VOID ItHwiM3B001F001(VOID)
{
return;
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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.

View File

@@ -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.

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -39,7 +39,7 @@ static VOID Case1(UINT32 arg)
g_testCount++;
}
static VOID Case2()
static VOID Case2(VOID)
{
g_testCount++;
}

View File

@@ -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++;
}

View File

@@ -34,7 +34,7 @@
static UINT32 g_testCount1 = 0;
static VOID Case1()
static VOID Case1(VOID)
{
UINT32 ret;

View File

@@ -35,7 +35,7 @@
static UINT32 g_testCount1 = 0;
static VOID Case1()
static VOID Case1(VOID)
{
UINT32 ret;

View File

@@ -44,7 +44,7 @@ static VOID Case1(UINT32 arg)
return;
}
static VOID Case2()
static VOID Case2(VOID)
{
UINT32 ret;
UINT32 tick;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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.

View File

@@ -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);

View File

@@ -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.

View File

@@ -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 };

View File

@@ -28,6 +28,109 @@
static_library("test_posix") {
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",

View 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();
}

View 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

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View File

@@ -0,0 +1,71 @@
/*
* 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 qname[MQUEUE_STANDARD_NAME_LENGTH];
INT32 ret;
mqd_t queue;
ret = snprintf_s(qname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq017-1_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
queue = mq_open(qname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
if (queue == (mqd_t)-1) {
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue);
}
ret = mq_close(queue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(qname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return LOS_OK;
EXIT:
mq_close(queue);
mq_unlink(qname);
EXIT1:
return LOS_OK;
}
/**
* @tc.name: ItPosixQueue017
* @tc.desc: Test interface mq_close
* @tc.type: FUNC
* @tc.require: issueI603SR6
*/
VOID ItPosixQueue017(VOID)
{
TEST_ADD_CASE("ItPosixQueue017", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,92 @@
/*
* 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_MSG_SIZE 20
#define QUEUE_MAX_MSG_SIZE 20
static UINT32 Testcase(VOID)
{
INT32 ret;
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
CHAR msgrcd[QUEUE_MSG_SIZE] = {0};
struct mq_attr attr = {0};
struct timespec absTimeout = {0};
mqd_t mqueue;
(void)snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH - 1, MQUEUE_STANDARD_NAME_LENGTH, "/mq018_%d",
LOS_CurTaskIDGet());
attr.mq_msgsize = QUEUE_MSG_SIZE;
attr.mq_maxmsg = QUEUE_MAX_MSG_SIZE;
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR, &attr);
ICUNIT_ASSERT_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue);
ret = mq_timedsend(mqueue, "1234567890123456789", QUEUE_MSG_SIZE, 0, &absTimeout);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = mq_receive(mqueue, msgrcd, QUEUE_MSG_SIZE, NULL);
ICUNIT_GOTO_EQUAL(ret, QUEUE_MSG_SIZE, ret, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
mqueue = mq_open(mqname, O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
ret = mq_receive(mqueue, msgrcd, QUEUE_MSG_SIZE, NULL);
ICUNIT_GOTO_EQUAL(ret, -1, 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);
return LOS_OK;
}
/**
* @tc.name: ItPosixQueue018
* @tc.desc: Test interface mq_timedsend
* @tc.type: FUNC
* @tc.require: issueI603SR6
*/
VOID ItPosixQueue018(VOID)
{
TEST_ADD_CASE("ItPosixQueue018", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
}

View File

@@ -0,0 +1,53 @@
/*
* 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;
ret = mq_close((mqd_t)-1); // -1: invalid message queue descriptor
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
return LOS_OK;
}
/**
* @tc.name: ItPosixQueue019
* @tc.desc: Test interface mq_close
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue019(VOID)
{
TEST_ADD_CASE("ItPosixQueue019", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,87 @@
/*
* 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] = {0};
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
struct timespec ts;
mqd_t mqueue;
struct mq_attr attr = {0};
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq020_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
ts.tv_sec = 1;
ts.tv_nsec = 0;
ret = mq_timedsend(mqueue, msgptr, strlen(msgptr), 0, &ts);
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);
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue020
* @tc.desc: Test interface mq_receive
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue020(VOID)
{
TEST_ADD_CASE("ItPosixQueue020", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,71 @@
/*
* 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};
mqd_t mqueue;
struct sigevent se;
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq021_%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, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue021
* @tc.desc: Test interface mq_open
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue021(VOID)
{
TEST_ADD_CASE("ItPosixQueue021", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View 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 mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
mqd_t mqueue;
struct mq_attr attr = {0};
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq022_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
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);
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue022
* @tc.desc: Test interface mq_receive
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue022(VOID)
{
TEST_ADD_CASE("ItPosixQueue022", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View 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 = 0;
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
struct timespec ts;
mqd_t mqueue;
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq023_%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);
ts.tv_sec = 1;
ts.tv_nsec = 0;
ret = mq_timedsend(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX + 1, &ts);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue023
* @tc.desc: Test interface mq_timedsend
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue023(VOID)
{
TEST_ADD_CASE("ItPosixQueue023", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,75 @@
/*
* 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, \
"/mq024_%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_send(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue024
* @tc.desc: Test interface mq_send
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue024(VOID)
{
TEST_ADD_CASE("ItPosixQueue024", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,151 @@
/*
* 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 VOID *PthreadF01(VOID *argument)
{
INT32 i;
INT32 ret;
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
g_testCount = 1;
g_mqueueTaskPID = LOS_CurTaskIDGet();
for (i = 0; i < 5 + 1; i++) { // 5, The loop frequency.
ret = mq_send(g_gqueue, msgptr, strlen(msgptr), 0);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
}
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert the g_testCount.
g_testCount = 2; // 2, Init test count value.
return NULL;
EXIT:
g_testCount = 0;
return NULL;
}
static VOID *PthreadF02(VOID *argument)
{
INT32 j, ret;
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
g_testCount = 3; // 3, Init test count value.
ret = mq_receive(g_gqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, strlen(MQUEUE_SEND_STRING_TEST), ret, EXIT);
ret = mq_close(g_gqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(g_gqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
g_testCount = 4; // 4, Init test count value.
return NULL;
EXIT:
g_testCount = 0;
return NULL;
}
static UINT32 Testcase(VOID)
{
pthread_t newTh1, newTh2;
UINT32 ret;
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
struct mq_attr attr = {0};
pthread_attr_t attr1;
ret = snprintf_s(g_gqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq025_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = 5; // 5, queue max message size.
g_testCount = 0;
g_gqueue = mq_open(g_gqname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR, &attr);
ICUNIT_GOTO_NOT_EQUAL(g_gqueue, (mqd_t)-1, g_gqueue, EXIT);
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
MqueueTaskDelay(5); // 5, Set delay time.
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST2);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ret = pthread_create(&newTh2, &attr1, PthreadF02, NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ret = MqueueTaskDelay(5); // 5, Set delay time.
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, Here, assert the g_testCount.
ret = PosixPthreadDestroy(&attr1, newTh2);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = PosixPthreadDestroy(&attr1, newTh1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return LOS_OK;
EXIT2:
PosixPthreadDestroy(&attr1, newTh2);
EXIT1:
PosixPthreadDestroy(&attr1, newTh1);
EXIT:
mq_close(g_gqueue);
mq_unlink(g_gqname);
EXIT3:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue025
* @tc.desc: Test interface mq_send
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue025(VOID)
{
TEST_ADD_CASE("ItPosixQueue025", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,155 @@
/*
* 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 VOID *PthreadF01(VOID *argument)
{
INT32 i;
struct timespec ts;
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
UINT32 ret;
ts.tv_sec = 0xffff;
ts.tv_nsec = 0;
g_testCount = 1;
for (i = 0; i < 5 + 1; i++) { // 5, The loop frequency.
ret = mq_timedsend(g_gqueue, msgptr, strlen(msgptr), 0, &ts);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
}
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert the g_testCount.
g_testCount = 2; // 2, Init test count value.
EXIT1:
return NULL;
EXIT2:
g_testCount = 0;
return NULL;
}
static VOID *PthreadF02(VOID *argument)
{
INT32 ret;
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
g_testCount = 3; // 3, Init test count value.
ret = mq_receive(g_gqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, strlen(MQUEUE_SEND_STRING_TEST), ret, EXIT1);
TestExtraTaskDelay(2); // 2, Set delay time.
ret = mq_close(g_gqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(g_gqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
g_testCount = 4; // 4, Init test count value.
return NULL;
EXIT1:
mq_close(g_gqueue);
EXIT:
mq_unlink(g_gqname);
EXIT2:
g_testCount = 0;
return NULL;
}
static UINT32 Testcase(VOID)
{
UINT32 ret;
struct mq_attr attr = {0};
pthread_attr_t attr1;
pthread_t newTh1, newTh2;
ret = snprintf_s(g_gqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq026_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = 5; // 5, queue max message size.
g_gqueue = mq_open(g_gqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
ICUNIT_GOTO_NOT_EQUAL(g_gqueue, (mqd_t)-1, g_gqueue, EXIT);
g_testCount = 0;
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
MqueueTaskDelay(5); // 5, Set delay time.
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST2);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ret = pthread_create(&newTh2, &attr1, PthreadF02, NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ret = MqueueTaskDelay(5); // 5, Set delay time.
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, Here, assert the g_testCount.
ret = PosixPthreadDestroy(&attr1, newTh2);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = PosixPthreadDestroy(&attr1, newTh1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return LOS_OK;
EXIT2:
PosixPthreadDestroy(&attr1, newTh2);
EXIT1:
PosixPthreadDestroy(&attr1, newTh1);
EXIT:
mq_close(g_gqueue);
mq_unlink(g_gqname);
EXIT3:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue026
* @tc.desc: Test interface mq_timedsend
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue026(VOID)
{
TEST_ADD_CASE("ItPosixQueue026", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,97 @@
/*
* 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, i = 0;
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
CHAR msgptr[MQUEUE_STANDARD_NAME_LENGTH] = {0};
mqd_t mqueue;
struct mq_attr attr = {0};
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq027_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
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);
while (1) {
ret = snprintf_s(msgptr, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, "message %d", i);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
if (ret == -1) {
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
break;
}
i++;
}
ICUNIT_GOTO_EQUAL(i, MQUEUE_SHORT_ARRAY_LENGTH, i, EXIT1);
i = 0;
ret = snprintf_s(msgptr, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, "message %d", i);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
ret = strcmp(msgptr, msgrcd);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue027
* @tc.desc: Test interface mq_send
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue027(VOID)
{
TEST_ADD_CASE("ItPosixQueue027", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View 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] = {0};
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
mqd_t mqueue;
struct mq_attr attr = {0};
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq028_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
ICUNIT_ASSERT_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue);
ret = mq_send(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX - 1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
ICUNIT_GOTO_STRING_EQUAL(msgrcd, msgptr, msgrcd, EXIT1);
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue028
* @tc.desc: Test interface mq_receive
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue028(VOID)
{
TEST_ADD_CASE("ItPosixQueue028", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View 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] = {0};
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
mqd_t mqueue;
struct mq_attr attr = {0};
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq029_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
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_send((mqd_t)(&mqueue + 1), msgptr, strlen(msgptr), 0);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
ret = strcmp(msgptr, msgrcd);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue029
* @tc.desc: Test interface mq_send
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue029(VOID)
{
TEST_ADD_CASE("ItPosixQueue029", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,77 @@
/*
* 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 qname[MQUEUE_STANDARD_NAME_LENGTH] = "";
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
mqd_t queue;
INT32 unresolved = 0;
INT32 failure = 0;
INT32 ret = 0;
ret = snprintf_s(qname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq030-1_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT);
queue = mq_open(qname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
ICUNIT_GOTO_NOT_EQUAL(queue, (mqd_t)-1, queue, EXIT);
ret = mq_send((mqd_t)(&queue + 1), msgptr, strlen(msgptr), 0);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT2);
ret = mq_close(queue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = mq_unlink(qname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
return LOS_OK;
EXIT2:
mq_close(queue);
EXIT1:
mq_unlink(qname);
EXIT:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue030
* @tc.desc: Test interface mq_send
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue030(VOID)
{
TEST_ADD_CASE("ItPosixQueue030", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View 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 = 0;
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH * 2];
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
mqd_t mqueue;
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq031_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
mqueue = mq_open(mqname, O_CREAT | O_RDONLY | 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, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EMSGSIZE, errno, EXIT1);
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH * 2, NULL); // 2, mqueue message length.
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue031
* @tc.desc: Test interface mq_receive
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue031(VOID)
{
TEST_ADD_CASE("ItPosixQueue031", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View 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 = 0;
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
CHAR msgrv[MQUEUE_STANDARD_NAME_LENGTH] = {0};
const CHAR *msgptr = "test message";
mqd_t mqueue;
struct timespec ts;
struct mq_attr attr = {0};
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
"/mq032_%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;
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);
ts.tv_sec = 1;
ts.tv_nsec = -1;
ret = mq_timedreceive(mqueue, msgrv, MQUEUE_STANDARD_NAME_LENGTH, NULL, &ts);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue032
* @tc.desc: Test interface mq_timedreceive
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue032(VOID)
{
TEST_ADD_CASE("ItPosixQueue032", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -0,0 +1,79 @@
/*
* 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 i;
INT32 ret = 0;
INT32 mqueuePri[MQUEUE_PRIORITY_NUM_TEST] = {MQ_PRIO_MAX, MQ_PRIO_MAX + 1, MQ_PRIO_MAX + 5}; // 5, Mqueue priority.
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, \
"/mq033_%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);
for (i = 0; i < MQUEUE_PRIORITY_NUM_TEST; i++) {
ret = mq_send(mqueue, msgptr, strlen(msgptr), mqueuePri[i]);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
}
ret = mq_close(mqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
EXIT2:
return LOS_NOK;
}
/**
* @tc.name: ItPosixQueue033
* @tc.desc: Test interface mq_send
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue033(VOID)
{
TEST_ADD_CASE("ItPosixQueue033", 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