Compare commits

..

67 Commits

Author SHA1 Message Date
openharmony_ci
9c79993721 !1039 挑单增加los错误码和posix错误码对接接口 到3.2
Merge pull request !1039 from wangchen/0317_re
2023-03-18 08:29:41 +00:00
root
a8141a7b92 fix: 挑单增加los错误码和posix错误码对接接口
方案描述:
1, 增加一个内部接口, 用于los接口返回的错误码转换成posix错误码

BREAKING CHANGE:
无新增接口, 原有接口pthread_create错误时的错误码进行了区分

Close #I6O2WI
Signed-off-by: wangchen <wangchen240@huawei.com>
2023-03-17 18:33:53 +08:00
openharmony_ci
11c5e52d22 !1033 Fix : 修复 LWIP_IPV6 相关的编译错误 挑单到monthly_20221018
Merge pull request !1033 from yinjiaming/cherry-pick-1677658640
2023-03-02 02:02:58 +00:00
yinjiaming
4398713789 fixed d058b64 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/1029
fix:打开LWIP_IPV6时有编译错误
更改了出错的参与算数运算的指针的数据类型

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I6891797cd1afa801faeecf1bfb891f0ac7db7f68
2023-03-01 08:17:27 +00:00
openharmony_ci
5b1ae297be !1028 【回合monthly1018】Panic支持ExcHook
Merge pull request !1028 from zhangdengyu/cherry-pick-1677047148
2023-02-22 11:45:24 +00:00
zhangdengyu
4722d95fb9 fixed 809db71 from https://gitee.com/zhangdengyu/kernel_liteos_m/pulls/1027
feat:Panic支持ExcHook

方案描述:
1、在EXC_TYPE枚举中添加EXC_PANIC成员用于Panic支持ExcHook
2、在LOS_Panic接口执行异常处理钩子函数

BREAKING CHANGE:
无

Close: #I6GR6G

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: I99d293622ff6ddbc49348c692512e5b7780460e6
2023-02-22 06:25:49 +00:00
openharmony_ci
a5dffd7cdb !1024 【回合monthly_1018】fix: pthread_create时序调整
Merge pull request !1024 from Zhaotianyu/cherry-pick-1676023301
2023-02-11 08:03:47 +00:00
arvinzzz
90c71e3e42 fixed f038492 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/1023
fix: pthread_create内部逻辑时序调整

在线程创建成功后,pthread_create内部先将函数返回值设置好,再进行TaskResume就绪调度状态

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I795c115da612123b67f34cdc57e85eac955bbc08
2023-02-10 10:01:41 +00:00
openharmony_ci
4176459693 !1014 Fix : OsLs内存问题修复挑单到monthly_20221018
Merge pull request !1014 from yinjiaming/cherry-pick-1673836500
2023-01-17 09:30:24 +00:00
openharmony_ci
44e7c46e5b !1013 Fix : statfs函数问题修复挑单到monthly_20221018
Merge pull request !1013 from yinjiaming/cherry-pick-1673836173
2023-01-17 08:57:17 +00:00
yinjiaming
cd8237fb5e fixed 9a4e967 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/1009
fix:修复OsLs函数内存泄漏问题
当d = NULL时,path没有释放,现释放path所指向的内存

close #I6A07U

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Iee9fd8d2171c6fdcf353a48e7af385bbd1660520
2023-01-16 02:35:00 +00:00
yinjiaming
a9cdef1cd4 fixed 2f2a0b7 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/1006
fix:修复statfs函数内部判断错误

修复函数调用的是statfs却用stat!=NULL来判断,当文件系统是little_fs时导致死机的问题。

close #I69BXB

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ib9784c017f4260433c3f12e352470108ea83ec19
2023-01-16 02:29:37 +00:00
openharmony_ci
47103b943a !1011 告警清理
Merge pull request !1011 from 乔克叔叔/cherry-pick-1673590318
2023-01-13 06:57:20 +00:00
liuwenxin
b4e2c8a8e2 fixed 705bfbd from https://gitee.com/wenxin-liu_admin/kernel_liteos_m/pulls/1010
fix:release告警清理

release分支告警清理

close:#I6AD15

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-01-13 06:11:59 +00:00
openharmony_ci
5e5acfd04f !1003 【同步到monthly_20221018分支】mutex trace中ArchLRGet等接口改变实现方式
Merge pull request !1003 from zhangdengyu/cherry-pick-1673256956
2023-01-10 12:10:29 +00:00
zhangdengyu
0b4895cca6 fixed 84d1c20 from https://gitee.com/zhangdengyu/kernel_liteos_m/pulls/1000
fix:mutex trace中ArchLRGet接口改变实现方式

方案描述:
将ArchLRGet接口的实现方式由内联函数修改为宏,
防止产品添加--no_inline等编译选项导致函数无法在调用点展开,
造成由于函数调用过程中函数栈帧的变化带来的LR寄存器中存储的值的变化。

Close #I69D9N

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
Change-Id: If417bc2ec9febf064c63da198faf4ac000d70c52
2023-01-10 14:33:02 +08:00
openharmony_ci
3d7e94ea57 !984 修复codecheck告警同步至monthly_20221018
Merge pull request !984 from 夏不白/cherry-pick-1672373774
2023-01-03 03:08:21 +00:00
xiacong
911e736dab fixed 07091c5 from https://gitee.com/xia-bubai/kernel_liteos_m/pulls/983
fix:修复codecheck告警
1、修复空格、空行使用错误告警;
2、将超过10行的inline函数去除内联符号

fix #I685E3

Signed-off-by: xiacong <xiacong4@huawei.com>
2022-12-30 04:16:14 +00:00
openharmony_ci
f109218089 !981 【回合monthly1018】fix: mktime获取的时间缺少时区信息
Merge pull request !981 from Zhaotianyu/cherry-pick-1672302591
2022-12-29 12:48:05 +00:00
arvinzzz
bd4d9ffb58 fixed 2a4282f from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/979
fix: The tm struct obtained by mktime lacks timezone information

BREAKING CHANGE:
The tm struct obtained by mktime lacks timezone information
变更API:
time_t mktime(struct tm *tmptr)
原先mktime从入参中获取时区信息进行计算,变更后tm结构体和返回值time_t的计算使用系统g_timezone时区环境变量。

Close I67UIA

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I766cffbff3c1a25bb33cbd245225ee117909af3a
2022-12-29 08:29:51 +00:00
openharmony_ci
015c79a5a9 !976 【monthly_20221018】VfsMpFind接口优化
Merge pull request !976 from Far/monthly_20221018
2022-12-26 02:04:03 +00:00
Far
46bad48e12 fix: VfsMpFind optimize
1. provide VfsMpFind which doesn't support mounting recursively;
2. provide a macro to set whether supporting recursive-mount or not.
3. adding path length checking

BREAKING CHANGE:
new config option:
LOSCFG_FS_SUPPORT_MOUNT_TARGET_RECURSIVE

fix #I677ZT
Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I92a752fe2bcdd2b036630b5e4e8d7df1562629e0
2022-12-24 10:45:01 +08:00
openharmony_ci
18ffbf44ee !975 【回合monthly1018】fix: misc_config中defines未初始化导致编译失败
Merge pull request !975 from Zhaotianyu/cherry-pick-1671695812
2022-12-23 09:04:20 +00:00
arvinzzz
690e15682b fixed b817c49 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/974
fix: 修复misc_config中defines未初始化的错误

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I4eecfc1af2b0cdc39922a8ce299eb8ab6b7c6e8c
2022-12-22 07:56:53 +00:00
openharmony_ci
84d34eafe1 !967 【monthly_20221018】修复文件系统不合理的锁操作
Merge pull request !967 from Far/monthly_20221018_lock
2022-12-22 06:33:10 +00:00
Far
819833072f fix: 修复文件系统不合理的锁操作
1. 移除了fatfs和littlefs中冗余的加锁操作。
2. 增加了配置选项FS_LOCK_TIMEOUT(宏LOSCFG_FS_LOCK_TIMEOUT),提供文件
   系统锁超时判定能力。
3. 新增对外接口LOS_FsLock()和LOS_FsUnlock()接口,提供HAL层与文件系统的
   互斥操作。

BREAKING CHANGE:
修复文件系统不合理的锁操作
新增API:
los_fs.h:
int LOS_FsLock(void)
int LOS_FsUnlock(void)
新增配置项:
LOSCFG_FS_LOCK_TIMEOUT(menuconfig FS_LOCK_TIMEOUT)

fix #I66A1M

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I2d7b67a209049162cd69f8ef3611ab0431df4d4a
2022-12-22 10:40:30 +08:00
openharmony_ci
8541f81c1e !970 【回合monthly_1018】open接口内存泄漏优化
Merge pull request !970 from wangchen/1217_1018
2022-12-19 07:02:08 +00:00
openharmony_ci
bddda6dcf7 !964 【monthly_20221018】修复文件系统close中的不合理操作
Merge pull request !964 from Far/monthly_20221018
2022-12-19 03:05:37 +00:00
wangchen
2bc508bdd3 fix: 回合1018 open接口内存泄漏修复
方案描述:
1, 修改路径正确时打开失败可能的异常

fix #I66KHK
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-12-17 08:23:19 +00:00
Far
77e204ab62 fix: 修复close接口中无法正常关闭文件的问题
1. close未考虑保留描述符0、1和2,导致fd合法性判断出现错误,这会导致
上限附近的fd不能被正常的关闭
2. 释放file结构体时未在锁的保护中进行,可能存在问题

fix #I66F6I

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I084c7e0e9cfc51a123ebad07d0c94f47e544baa6
2022-12-17 16:06:02 +08:00
arvinzzz
852181749d refactor: vfs opt
1. vfs重构优化,统一fs模块的对外接口,减少不必要的冗余调用,由fs组件直接提供posix对外接口
  2. vfs与libc关系整理
  3. fs接口实现规范化

BREAKING CHANGE:
删除API:
int LOS_Open(const char *path, int flags, ...);
int LOS_Close(int fd);
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
ssize_t LOS_Write(int fd, const void *buff, size_t bytes);
off_t LOS_Lseek(int fd, off_t off, int whence);
int LOS_Stat(const char *path, struct stat *stat);
int LOS_Statfs(const char *path, struct statfs *buf);
int LOS_Unlink(const char *path);
int LOS_Rename(const char *oldpath, const char *newpath);
int LOS_Fsync(int fd);
DIR *LOS_Opendir(const char *path);
struct dirent *LOS_Readdir(DIR *dir);
int LOS_Closedir(DIR *dir);
int LOS_Mkdir(const char *path, mode_t mode);
int LOS_Rmdir(const char *path);
int LOS_Lstat(const char *path, struct stat *buffer);
int LOS_Fstat(int fd, struct stat *buf);
int LOS_Fcntl(int fd, int cmd, ...);
int LOS_Ioctl(int fd, int req, ...);
ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt);
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off);
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off);
int LOS_Isatty(int fd);
int LOS_Access(const char *path, int amode);
int LOS_Ftruncate(int fd, off_t length);
int LOS_FsUmount(const char *target);
int LOS_FsUmount2(const char *target, int flag);
int LOS_FsMount(const char *source, const char *target,
                const char *fsType, unsigned long mountflags,
                const void *data);
int OsFcntl(int fd, int cmd, va_list ap);
int OsIoctl(int fd, int req, va_list ap);

Close #I66F6I

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
2022-12-16 10:26:19 +08:00
openharmony_ci
eb08c1744d !961 【同步到monthly_20221018分支】feat:支持mutex trace
Merge pull request !961 from zhangdengyu/monthly_20221018
2022-12-09 00:56:50 +00:00
openharmony_ci
2a68a0e6d4 !956 【挑单】优化CPUP计算方式, 解耦系统调频
Merge pull request !956 from zhushengle/cherry-pick-1670312099
2022-12-08 14:49:17 +00:00
zhangdengyu
2eb0da90fe feat: 同步:新增mutex trace
方案描述:
1. 新增mutex trace

Close: I5ZMML

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-12-08 16:38:04 +08:00
openharmony_ci
da29e90bca !959 fix: monthly_20221018 对外提供CONFIG_NFILE_DESCRIPTORS宏表示最大可打开fd数量
Merge pull request !959 from Hongjin Li/cherry-pick-1670397258
2022-12-07 07:49:48 +00:00
openharmony_ci
20cd0e4fde !951 合入monthly_20221018:添加LOSCFG_MAX_OPEN_DIRS标识最大可打开dir数量
Merge pull request !951 from Hongjin Li/monthly_20221018
2022-12-07 07:31:58 +00:00
Hongjin Li
0c39af1d9b fixed a3ce436 from https://gitee.com/hongjin-li/kernel_liteos_m/pulls/934
fix: 提供CONFIG_NFILE_DESCRIPTORS宏标识最大可打开fd数量

提供CONFIG_NFILE_DESCRIPTORS宏,标识最大可打开fd数量。
提供FAT_MAX_OPEN_FILES宏,标识FAT文件系统中最大可打开fd数量。

如果只有FAT文件系统,那么CONFIG_NFILE_DESCRIPTORS等于FAT_MAX_OPEN_FILES。
如果有多个文件系统,比如fat+little+yaffs,那么CONFIG_NFILE_DESCRIPTORS应该定义为多个文件系统可打开fd数量之和。

BREAKING CHANGE:

对外提供的CONFIG_NFILE_DESCRIPTORS宏,用来标识最大可打开fd数量。

开发者可以在target_config.h中自定义CONFIG_NFILE_DESCRIPTORS和FAT_MAX_OPEN_FILES宏。

Close #I62WDU

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-12-07 07:14:18 +00:00
openharmony_ci
9cac5041f2 !954 【monthly_20221018】对内核模块暴露OsMemNodeHead/OsMemPoolHead等结构体
Merge pull request !954 from Far/monthly_20221018
2022-12-06 13:57:37 +00:00
openharmony_ci
02ad24988b !936 feat: 挑单 fs增加注册接口 到1030
Merge pull request !936 from wangchen/1124_1030
2022-12-06 09:17:09 +00:00
openharmony_ci
9e4b228f3b !946 挑单 vfs 分区逻辑修改 到 monthly_20221018
Merge pull request !946 from wangchen/1129_x_partit
2022-12-06 09:03:20 +00:00
zhushengle
2fad9065c8 fixed 974182d from https://gitee.com/zhushengle/kernel_liteos_m/pulls/955
feat: 优化CPUP计算方式, 解耦系统调频

Close #I5R9XG

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: I07cb388732b1190943374802f792d32bd666c06e
2022-12-06 07:35:00 +00:00
Far
c23f36940d feat: 对内核模块暴露OsMemNodeHead/OsMemPoolHead
对内核其他模块暴露OsMemNodeHead/OsMemPoolHead等结构体,
以便于对堆内存管理的调测及管理。

fix #I64OVX

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I603188722beaf67ba65e26ed93168617485e770a
2022-12-05 17:10:58 +08:00
wangchen
83198b9a6c feat: 挑单 fs增加注册接口 到1030
方案描述:
增加注册机制, 并增加重复注册判断

BREAKING CHANGE:
挑单 fs增加注册接口 到1030
新增API:
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
                   const struct FileOps *fsFops, const struct FsManagement *fsMgt);

fix #I62WMS
Signed-off-by: wangchen <wangchen240@huawei.com>
https://gitee.com/openharmony/kernel_liteos_m/issues/I62WMS
2022-12-01 02:49:05 +00:00
Hongjin Li
ee66077ec6 fix: 添加LOSCFG_MAX_OPEN_DIRS标识最大可打开dir数量
提供LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。新增g_dirNum静态变量,标识已打开的dir数量。
在opendir成功时g_dirNum++,在closedir成功时g_dirNum--。

BREAKING CHANGE:
新增LOSCFG_MAX_OPEN_DIRS宏定义,标识最大可打开dir数量。

Close #I641DZ

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-12-01 10:03:51 +08:00
wangchen
bbbf0b857c fix: 挑单 vfs 分区逻辑修改 到 1018
方案描述:
1,删除fat分区时调用的adddevice的动作

fix #I63QXK
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-29 09:06:04 +00:00
openharmony_ci
af5fcc0e6c !942 【monthly_20221018】文件系统提供动态内存分配器钩子
Merge pull request !942 from Far/monthly_20221018
2022-11-29 03:53:36 +00:00
Far
e004ca9783 feat: 文件系统提供动态内存分配器钩子
增加LOS_FS_MALLOC/LOS_FS_FREE宏以提供用户配置动态内存分配器的能力。
用户只需要在components/fs/vfs/los_fs.h中修改对应的函数即可。

BREAKING CHANGE:
文件系统提供动态内存分配器钩子
新增宏:
LOS_FS_MALLOC
LOS_FS_FREE

fix #I63IZ8

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Ia18cbf907709dbfaa1bbc4e779537ec8e659a0ec
2022-11-28 20:01:36 +08:00
openharmony_ci
257364f873 !931 Fix : 内核告警清理挑单
Merge pull request !931 from yinjiaming/cherry-pick-1669172283
2022-11-23 11:07:51 +00:00
yinjiaming
86ee9aff2e fixed a4087a6 from https://gitee.com/hgbveiu743/kernel_liteos_m/pulls/930
Fix: 内核告警清理
消除了多余的空格

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: Ibe90fcf8c46ef9a60c0a8f4dbba07d399e139b8c
2022-11-23 02:58:04 +00:00
openharmony_ci
e709718fdc !926 告警清理
Merge pull request !926 from 乔克叔叔/cherry-pick-1669000234
2022-11-23 01:46:38 +00:00
openharmony_ci
34fcef1bf1 !924 告警清理
Merge pull request !924 from 乔克叔叔/cherry-pick-1668998063
2022-11-21 14:06:09 +00:00
liuwenxin
f5833a19ce fixed 2806c4a from https://gitee.com/wenxin-liu_admin/kernel_liteos_m/pulls/892
Fix:m核告警清理

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-21 16:43:48 +08:00
liuwenxin
5b65d5d0f3 fixed fa6f0c3 from https://gitee.com/wenxin-liu_admin/kernel_liteos_m/pulls/917
fix:告警清理

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2022-11-21 02:34:24 +00:00
openharmony_ci
1a525b1f0f !920 告警清理 合入monthly_20221018
Merge pull request !920 from Hongjin Li/cherry-pick-1668687992
2022-11-19 07:08:11 +00:00
openharmony_ci
780227205d !923 挑单 其他分区已mount时会引起格式化失败至monthly_20221018
Merge pull request !923 from wangchen/1118_1030_m
2022-11-18 10:21:09 +00:00
wangchen
171ffc4f4b fix: 挑单 其他分区已mount时会引起格式化失败至monthly_20221018
【背景】其他分区已mount时会引起格式化失败至monthly_20221018

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

【影响】
对现有的产品编译不会有影响。
re #I61W0J
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-18 06:58:29 +00:00
Hongjin Li
87e957c6a6 fixed 2dc3998 from https://gitee.com/hongjin-li/kernel_liteos_m/pulls/919
fix: add space after comma

Signed-off-by: Hongjin Li <lihongjin1@huawei.com>
2022-11-17 12:26:32 +00:00
openharmony_ci
03a72de3ed !914 【monthly_20221018】修复mount接口对MS_REMOUNT的支持
Merge pull request !914 from Far/cherry-pick-1668503371
2022-11-17 04:56:30 +00:00
Far
ed3ad6e65f fixed 64d15df from https://gitee.com/yesiyuanjim/kernel_liteos_m/pulls/909
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 09:09:32 +00:00
openharmony_ci
48b116bebb !883 【回合monthly1018】feat: 提供死机场景下dump文件能力
Merge pull request !883 from Zhaotianyu/cherry-pick-1667647264
2022-11-14 02:23:37 +00:00
openharmony_ci
d4cbd3b563 !888 cortex-m4支持iar编译器的gn适配
Merge pull request !888 from yiweiniunan/cherry-pick-1667812780
2022-11-07 11:15:42 +00:00
yiweiniunan
787eaac712 fixed 62cd8fe from https://gitee.com/yiweiniunan/kernel_liteos_m/pulls/886
cortex-m4支持iar编译器的gn适配

Signed-off-by: yiweiniunan <michael.likai@huawei.com>
2022-11-07 09:19:40 +00:00
openharmony_ci
de6e3829b2 !872 挑单 解决部分平台ping失败
Merge pull request !872 from wangchen/1103_net
2022-11-07 01:37:53 +00:00
arvinzzz
9c0ea618df fixed 4742015 from https://gitee.com/arvinzzz/kernel_liteos_m/pulls/881
feat: 提供死机场景下dump文件的能力

死机场景下,vfs层锁会放开,提供dump文件的能力

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: Id8c9e63fbf011dbc6690b9b4557bd3370353bf21
2022-11-05 11:21:05 +00:00
openharmony_ci
6fdbdf18cb !876 挑单-pm idle控制选项添加到menuconfig中至monthly_20221018
Merge pull request !876 from zhushengle/cherry-pick-1667528978
2022-11-04 09:38:11 +00:00
zhushengle
9454dd8bda fixed 98d20e9 from https://gitee.com/zhushengle/kernel_liteos_m/pulls/874
feat: pm idle添加到menuconfig中

Close #I5ZD5L
Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ibdedff3043a0902aa3cd9539497ef97fb6a1ce6c
2022-11-04 02:29:38 +00:00
wangchen
291cb06744 fix: 挑单 解决部分平台ping失败
【背景】挑单 解决部分平台ping失败

【修改方案】
挑单 解决部分平台ping失败

【影响】
对现有的产品编译不会有影响。
re #I5Z9TP
Signed-off-by: wangchen <wangchen240@huawei.com>
2022-11-03 07:18:47 +00:00
191 changed files with 2180 additions and 12667 deletions

View File

@@ -10,12 +10,6 @@
### 测试用例(新增、改动、可能影响的功能)
### 是否涉及对外变更典型的如对外API规格变更、新增对外接口等等
必须选择一项在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
- [ ] 是,涉及对外变更: 需要在commit message中按【[模板要求](https://gitee.com/openharmony/kernel_liteos_m/wikis/Commit%20message%E8%A7%84%E8%8C%83)】描述变更点
- [ ] 否,不涉及对外变更
### 是否需要同步至release3.0LTS ... )分支?
必须选择一项在MarkDown模式下用[x]替换[ ]即可勾选对应选项):

View File

@@ -91,8 +91,9 @@ config("dialect_config") {
}
config("misc_config") {
defines = []
if (!defined(LOSCFG_COMPILER_ICCARM)) {
defines = [ "__LITEOS__" ]
defines += [ "__LITEOS__" ]
defines += [ "__LITEOS_M__" ]
}
if (!defined(LOSCFG_DEBUG_VERSION)) {

View File

@@ -1,465 +0,0 @@
# (2022-03-30)
### Bug Fixes
* c-sky等芯片架构的BUILD.gn优化 ([3311d73](https://gitee.com/openharmony/kernel_liteos_m/commits/3311d73406b68d289b6f715a099e90f62c86abd1)), closes [#I4D129](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D129)
* change the sensitive words ([8e2248c](https://gitee.com/openharmony/kernel_liteos_m/commits/8e2248c062aaca2444cc1001873fe8e8d8cdd3c6)), closes [#I4K7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4K7)
* cortex-m55栈优化 ([59e9c6e](https://gitee.com/openharmony/kernel_liteos_m/commits/59e9c6ed73caeeed56081a768198eccc7448df6c)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* csky等新增模块的HalTickStart函数定义和实现不一致 ([07ab6a5](https://gitee.com/openharmony/kernel_liteos_m/commits/07ab6a5b77c6955f6093beeab976bdc1b32d1db9)), closes [#I4D1](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D1)
* FD_SETSIZE compatible newlibc ([82c6d5f](https://gitee.com/openharmony/kernel_liteos_m/commits/82c6d5f17478fb47ea5977a32fb76d783ee3e815))
* fix compile warning saying dereference void * pointer ([29126a9](https://gitee.com/openharmony/kernel_liteos_m/commits/29126a98fe7a8f75695910bdf8fa1ccc6ff67288))
* gcc编译testsuite编译问题修复 ([f7d26b8](https://gitee.com/openharmony/kernel_liteos_m/commits/f7d26b8e12fb1ba4bebe6c0fc9ca9e392537419f)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* Kconfig中打开littlefs选项默认关联打开LOSCFG_SUPPORT_LITTLEFS宏 ([b2bcab3](https://gitee.com/openharmony/kernel_liteos_m/commits/b2bcab3a5bd794c86dd4d93b1b5aeca2d097289b)), closes [#I4ENQ1](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ENQ1)
* kernel接口融合添加/修改kernel函数 ([cee9714](https://gitee.com/openharmony/kernel_liteos_m/commits/cee9714a90f2660a0b4455f4f5a2fc42870a6aa5))
* L0 pthread_cond_timedwait接口实现存在的几个问题 ([2219c32](https://gitee.com/openharmony/kernel_liteos_m/commits/2219c32784071b6c37ea57185382e3228ed4b0a7)), closes [#I4N9P8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4N9P8)
* liteos_kernel_only=true编译内核报错 ([adc2105](https://gitee.com/openharmony/kernel_liteos_m/commits/adc21052b2b9b55de9fc493cf74645f470edf9b5)), closes [#I4O204](https://gitee.com/openharmony/kernel_liteos_m/issues/I4O204)
* los_exc.S中_ExcInMsp主栈中异常处理函数中异常返回类型错误 ([c51df7a](https://gitee.com/openharmony/kernel_liteos_m/commits/c51df7a94c1f21803db25f46a73a7fb291588eda)), closes [#I4EJI4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4EJI4)
* los_interrupt.c存在未使用的参数编译出错 ([5af4c2e](https://gitee.com/openharmony/kernel_liteos_m/commits/5af4c2e2139cabe49049283f7a4280460bbf353a)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* LOS_Panic接口中增加需要增加LOS_BackTrace(),方便定位主动异常位置 ([f51d675](https://gitee.com/openharmony/kernel_liteos_m/commits/f51d675fee217e0ad519f2fa79f70b033f313dce)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* los_trace.h接口注释错误修正 ([693468e](https://gitee.com/openharmony/kernel_liteos_m/commits/693468e5274af310721f5962602a915d701a7bf0)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* m4核在任务中异常时backtrace使用的是MSP所在的栈而不是PSP所在的栈 ([3e8aea2](https://gitee.com/openharmony/kernel_liteos_m/commits/3e8aea224e481322efef9397e4aafc3450a09d28)), closes [#I4D7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D7)
* M核posix接口fs模块用例完善 ([ee380fb](https://gitee.com/openharmony/kernel_liteos_m/commits/ee380fb9be45ef033979ec3b8875d980b7f13198)), closes [#I4L7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4L7)
* optimize default configuration ([b2e3849](https://gitee.com/openharmony/kernel_liteos_m/commits/b2e3849bfbd470981602b0dc02f47bffb38bfe11)), closes [#I4FSC9](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FSC9)
* OsGetAllTskInfo调用和异常时无任务回调函数地址 ([1c605a3](https://gitee.com/openharmony/kernel_liteos_m/commits/1c605a338ad2317aeb464bdac85df5b9a79c99fd)), closes [#I4MG2](https://gitee.com/openharmony/kernel_liteos_m/issues/I4MG2)
* pm codex告警清零 ([9666380](https://gitee.com/openharmony/kernel_liteos_m/commits/96663805ecfd3248e33b4deb877c8d55cc4e8eec)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* pm模块解冻线程时存在删除空链表且时间片频繁唤醒系统 ([9f185b5](https://gitee.com/openharmony/kernel_liteos_m/commits/9f185b5b52ed9506a4913f233c9ddfe45452ec05)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* **posix unittest:** posix unittest 融合 ([ad6f249](https://gitee.com/openharmony/kernel_liteos_m/commits/ad6f249d1ea878f06864d79bdbed772b21eeac49))
* **posix:** posix兼容回退 ([207efc1](https://gitee.com/openharmony/kernel_liteos_m/commits/207efc15b859fe18d8b1dac2a3da9d7a5831aa6e))
* **posix:** posix接口融合接口规范兼容性修改 ([e0b1275](https://gitee.com/openharmony/kernel_liteos_m/commits/e0b12758da4a25e42110ba32da25b6d18ebed8ef))
* **posix接口融合:** posix接口融合接口规范兼容性修改 ([4b607fd](https://gitee.com/openharmony/kernel_liteos_m/commits/4b607fd0740a5379cd373890482235845d782b62))
* posix线程和LOS_TaskCreate任务不兼容补齐接口防护防止访问野指针 ([60805e1](https://gitee.com/openharmony/kernel_liteos_m/commits/60805e1a7c3736db86695ed86cd03cfaab70a427))
* pr模板补充说明 ([7b86f69](https://gitee.com/openharmony/kernel_liteos_m/commits/7b86f69cc0ccd5512b69fd3a1181b3440747ddb2))
* ReadMe中无对动态加载模块待加载的共享库的限制说明。 ([f86b971](https://gitee.com/openharmony/kernel_liteos_m/commits/f86b97180f97903bb2def271b7b11fc1ae1bf9bb)), closes [#I4ICK8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ICK8)
* shell 输入不识别命令时内存泄漏 ([0245b1a](https://gitee.com/openharmony/kernel_liteos_m/commits/0245b1a7b24fd36d23f9602d0755b274581a84ce)), closes [#I4UR9](https://gitee.com/openharmony/kernel_liteos_m/issues/I4UR9)
* **shell:** cat针对大文件无法工作 ([d518bad](https://gitee.com/openharmony/kernel_liteos_m/commits/d518bad0dc7dd9e3fbb45423a7db5cb8c1c922dc)), closes [#I4J4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4J4)
* shell模块task命令踩内存问题修改 ([6ffd55d](https://gitee.com/openharmony/kernel_liteos_m/commits/6ffd55dcd07ce17b693a97bb678668f763480e4d)), closes [#I4A70](https://gitee.com/openharmony/kernel_liteos_m/issues/I4A70)
* switch inet_addr to a function ([b30e913](https://gitee.com/openharmony/kernel_liteos_m/commits/b30e9139d5502acab8c36ae9a56d4cd640786c44)), closes [#I4G4I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4I4)
* **testsuites:** cpup和测试套解耦 ([692651f](https://gitee.com/openharmony/kernel_liteos_m/commits/692651fe40f668f19b479186e52fea34d092b458))
* tick timer时钟频率赋值修改为运行时赋值 ([ae02afc](https://gitee.com/openharmony/kernel_liteos_m/commits/ae02afc8504f64ff6bc09828f55e9602bcbcae56)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* tick中断处理时无挂起任务时应更新当前运行任务的时间片, 并触发一次调度 ([ea12d40](https://gitee.com/openharmony/kernel_liteos_m/commits/ea12d40caf1301b4a7b6d60a2c599ceff4746c90)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* **time_func_test_01.c:** 修复testTimes测试单板配置LOSCFG_BASE_CORE_TICK_PER_SECOND = 1000的问题 ([5c982f1](https://gitee.com/openharmony/kernel_liteos_m/commits/5c982f1087f95174f2836c72648eab58adf37fd7))
* 中断向量表对齐大小支持可配置 ([cf9c838](https://gitee.com/openharmony/kernel_liteos_m/commits/cf9c8387e3785d994aacf948b7c1b61324a3dd63)), closes [#I4M20](https://gitee.com/openharmony/kernel_liteos_m/issues/I4M20)
* 优化trace buffer初始化删除swtmr 桩中的无效参数 ([afbc9a5](https://gitee.com/openharmony/kernel_liteos_m/commits/afbc9a593b61461072556cb5531d90b30ce2e394)), closes [#I4DPR7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4DPR7)
* 优化低功耗流程 ([c6600d9](https://gitee.com/openharmony/kernel_liteos_m/commits/c6600d9dddb666f397ba659d47d64f334691af6b)), closes [#I46](https://gitee.com/openharmony/kernel_liteos_m/issues/I46)
* 修复arch目录调整影响到的target目录下的文件 ([d5725b2](https://gitee.com/openharmony/kernel_liteos_m/commits/d5725b22644da8ab3e719169230303e44c7d8750)), closes [#I4JM7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4JM7)
* 修复cortex-m系列系统提供的timer在低频下时间不准的问题 ([3e569ba](https://gitee.com/openharmony/kernel_liteos_m/commits/3e569bac587d90dcd21aff7d8ec53216dfbb8f1c)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 修复hook层LOS_HOOK_TYPE_SEM_PEND的runningTask入参可能为空 ([3fd22ac](https://gitee.com/openharmony/kernel_liteos_m/commits/3fd22ac2b0b4c690669a659246aba099fd4311ec)), closes [#I4BU4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4BU4)
* 修复irqNum = HwiNumGet()编译错误的问题 ([16e87d7](https://gitee.com/openharmony/kernel_liteos_m/commits/16e87d78d89bec7d85c076fc738ed4ad0614b865)), closes [#I4S81](https://gitee.com/openharmony/kernel_liteos_m/issues/I4S81)
* 修复Kconfig信息错误 ([bb04582](https://gitee.com/openharmony/kernel_liteos_m/commits/bb045829104211522cd12a7273d5853400c1ea26)), closes [#I4MZ1](https://gitee.com/openharmony/kernel_liteos_m/issues/I4MZ1)
* 修复L0_Emulator 门禁高概率失败的问题 ([7ad2f62](https://gitee.com/openharmony/kernel_liteos_m/commits/7ad2f62a03481a3919fef1f1e46e4c9677b1e65c)), closes [#I4NB0](https://gitee.com/openharmony/kernel_liteos_m/issues/I4NB0)
* 修复liteos-m在iar环境下的编译问题 ([4c4784e](https://gitee.com/openharmony/kernel_liteos_m/commits/4c4784e33d7944e7850009be192375aaa6e2b125)), closes [#I4Q5Q5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4Q5Q5)
* 修复los_interrupt.c文件中HalHwiInit函数里未使能未对齐异常问题 ([d32e25f](https://gitee.com/openharmony/kernel_liteos_m/commits/d32e25f3ae8e8e5ec24effa98dc8f0b3ba94d0c1)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 修复newlib缺省PTHREAD_KEYS_MAX 问题 ([65f04bf](https://gitee.com/openharmony/kernel_liteos_m/commits/65f04bf093376a478e9585dadfc1238158cc3641)), closes [#I4OX47](https://gitee.com/openharmony/kernel_liteos_m/issues/I4OX47)
* 修复OsQueueMailFree提早释放内存的问题 ([ec88d16](https://gitee.com/openharmony/kernel_liteos_m/commits/ec88d1628937b3def6dd613246116f6bfa4141eb))
* 修复pm编译告警导致内核编译失败 ([18b0524](https://gitee.com/openharmony/kernel_liteos_m/commits/18b052458e1cea113df7a6bb4798a6d5e1eb751e)), closes [#I49](https://gitee.com/openharmony/kernel_liteos_m/issues/I49)
* 修复pthread 编译告警 ([cc57f81](https://gitee.com/openharmony/kernel_liteos_m/commits/cc57f81ab85a5eb9bb4be9bd7d2863978996bcf3)), closes [#I4U16](https://gitee.com/openharmony/kernel_liteos_m/issues/I4U16)
* 修复pthread_create相关问题 ([cd949dd](https://gitee.com/openharmony/kernel_liteos_m/commits/cd949ddae0aa4e7291b0b7f6ba83c2034cdf1301)), closes [#I4P78](https://gitee.com/openharmony/kernel_liteos_m/issues/I4P78)
* 修复pthread_create行为与posix不一致问题 ([2b1e5a7](https://gitee.com/openharmony/kernel_liteos_m/commits/2b1e5a7a130fbca1b86a787b54f474e183541d6d)), closes [#I49W9](https://gitee.com/openharmony/kernel_liteos_m/issues/I49W9)
* 修复readme中文档链接错误 ([8ee70a0](https://gitee.com/openharmony/kernel_liteos_m/commits/8ee70a0f8f856da29139a36ba6f8589201cdb109)), closes [#I4FD5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FD5)
* 修复risc-v异常时异常信息混乱且backtrace无法输出的问题 ([0fb49d4](https://gitee.com/openharmony/kernel_liteos_m/commits/0fb49d4422245e83c2435468eb7f2690f2e2c6e4)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 修复shcmd.h需要用宏包起来的问题 ([a7a8a62](https://gitee.com/openharmony/kernel_liteos_m/commits/a7a8a62bcb7398b4194b37f62098da9cb1ce717e)), closes [#I45FU2](https://gitee.com/openharmony/kernel_liteos_m/issues/I45FU2)
* 修复shell 模块存在大量的编译告警及codeCheck。 ([e0d8b53](https://gitee.com/openharmony/kernel_liteos_m/commits/e0d8b5328f53dcef9427a34e8b0462250bb6a40f)), closes [#I48V2](https://gitee.com/openharmony/kernel_liteos_m/issues/I48V2)
* 修复任务栈对齐问题及补充posix和cmsis测试用例 ([ed863e9](https://gitee.com/openharmony/kernel_liteos_m/commits/ed863e90dd9aceb5d3b6d92b0a94703101b83f80))
* 修复公版gcc编译内核调用calloc崩溃 ([8d0ced2](https://gitee.com/openharmony/kernel_liteos_m/commits/8d0ced206951f35d5caab61969344b0ab259e5fb)), closes [#I4OFG6](https://gitee.com/openharmony/kernel_liteos_m/issues/I4OFG6)
* 修复未使用的参数和类型比较编译报错问题 ([21b46e8](https://gitee.com/openharmony/kernel_liteos_m/commits/21b46e82f31030703d052369701f4d6d736a4a86))
* 修复调度时间最大值不一致问题 ([9f393bc](https://gitee.com/openharmony/kernel_liteos_m/commits/9f393bcc6df592efb6940e9864ff93e932ae59ad))
* 修正liteos-m内核README不准确信息 ([0e067b2](https://gitee.com/openharmony/kernel_liteos_m/commits/0e067b239354c28e16b05489274b33051d002508)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 修正部分编码风格问题 ([91903a3](https://gitee.com/openharmony/kernel_liteos_m/commits/91903a37165ef364750916104be4f7dfd1d8f9a6)), closes [#I4K8M7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4K8M7)
* 内核ERR打印线程信息不方便问题定位。 ([232fec2](https://gitee.com/openharmony/kernel_liteos_m/commits/232fec27ac8cd2f46b5a2f5cfbe4677d0e287314)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 内源检视问题修复 ([c24363b](https://gitee.com/openharmony/kernel_liteos_m/commits/c24363bc50364b0be1fba3b993a83c6936fc3d08))
* 删除C文件中无用的__cplusplus ([7fe3aad](https://gitee.com/openharmony/kernel_liteos_m/commits/7fe3aaddf56b300ffcb2b186ae01ed64bef1c069)), closes [#I4D0](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D0)
* 删除OsMemboxExcInfoGetSub内存调测方法中多余的赋值语句。 ([94db0fe](https://gitee.com/openharmony/kernel_liteos_m/commits/94db0fe7a30edaa10786101f1ef662987a27734a)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 去掉没有使用的入参consoleid。 ([a627953](https://gitee.com/openharmony/kernel_liteos_m/commits/a62795304da31e13021ea2c675d124afd2594102)), closes [#I43](https://gitee.com/openharmony/kernel_liteos_m/issues/I43)
* 去掉编译选项-fno-short-enums ([b542aab](https://gitee.com/openharmony/kernel_liteos_m/commits/b542aab09dd92397f8c1305ac656ef14a012b5f8)), closes [#I4JY32](https://gitee.com/openharmony/kernel_liteos_m/issues/I4JY32)
* 取消cpu进入低功耗前开中断操作 ([bd39e9e](https://gitee.com/openharmony/kernel_liteos_m/commits/bd39e9e6d67310222c363e132141bb7fee1213f1)), closes [#I4KDP8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4KDP8)
* 告警修复 ([7d2fd01](https://gitee.com/openharmony/kernel_liteos_m/commits/7d2fd01c2d7d6d4c653a307a1419bc094f5332f0))
* 告警修复 ([2d7bf3b](https://gitee.com/openharmony/kernel_liteos_m/commits/2d7bf3b7d8ea84961e802c366899aca891f38377))
* 在头文件中补充LOSCFG_MEM_FREE_BY_TASKID函数的声明 ([ad18026](https://gitee.com/openharmony/kernel_liteos_m/commits/ad18026a59fc2853c9580e040f959f9f42082640)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 将curl依赖的函数新增至newlib库 ([bd04d9f](https://gitee.com/openharmony/kernel_liteos_m/commits/bd04d9f29a0b77445a71378f88b01ffdae24554f)), closes [#I4RG71](https://gitee.com/openharmony/kernel_liteos_m/issues/I4RG71)
* 将未定义小写"true""false"改为"TRUE""FALSE"。 ([9819eb5](https://gitee.com/openharmony/kernel_liteos_m/commits/9819eb567636adf1774de9fd6039d274bee8f69b)), closes [#I43D20](https://gitee.com/openharmony/kernel_liteos_m/issues/I43D20)
* 当前仓代码编译告警的问题 ([194ac58](https://gitee.com/openharmony/kernel_liteos_m/commits/194ac5898d1e2ffaa17f6dca405614b73da6f8bb)), closes [#I4N50](https://gitee.com/openharmony/kernel_liteos_m/issues/I4N50)
* 支持硬浮点编译 ([988fd85](https://gitee.com/openharmony/kernel_liteos_m/commits/988fd85fae454a0d9fe01ef1c921b4f3667d5ac8)), closes [#I48](https://gitee.com/openharmony/kernel_liteos_m/issues/I48)
* 测试用例任务栈的宏定义重复定义导致在osTest.h中修改不生效 ([ce6cf68](https://gitee.com/openharmony/kernel_liteos_m/commits/ce6cf6879f4564393765a24c4d65448e0fddc3eb)), closes [#I4BA5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4BA5)
* 添加L0 测试门禁 ([5c168fc](https://gitee.com/openharmony/kernel_liteos_m/commits/5c168fc3e0d08dd4a8924696e17a498eb444fa70)), closes [#I4C5R4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C5R4)
* 添加newlib对ipv6的支持 ([f7400fb](https://gitee.com/openharmony/kernel_liteos_m/commits/f7400fbcb275cbb3b75f1aef2af1459b794432de)), closes [#I4M1](https://gitee.com/openharmony/kernel_liteos_m/issues/I4M1)
* 添加文件版权头等信息 ([cf4e017](https://gitee.com/openharmony/kernel_liteos_m/commits/cf4e017970f8a3113bc8b6028d75775f747512c6)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 清除因g_tm变量没有使用引入的编译告警 ([9689522](https://gitee.com/openharmony/kernel_liteos_m/commits/9689522a8e08b79244ad339dc24074843b99d33b)), closes [#I4LW3](https://gitee.com/openharmony/kernel_liteos_m/issues/I4LW3)
* 移除los_arch_interrupt.h文件中冗余声明的函数VOID OsExcInit(VOID) ([136952f](https://gitee.com/openharmony/kernel_liteos_m/commits/136952f193fe97cfd6a88932e71811e12edfa7a5)), closes [#I4D9](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D9)
* 补充net相关头文件 ([93f616b](https://gitee.com/openharmony/kernel_liteos_m/commits/93f616b64e961013be5c5267e50d58a40b5cc6c9))
* 解决gmtime和localtime接口由于g_tm全局变量导致的竞态问题 ([1454b76](https://gitee.com/openharmony/kernel_liteos_m/commits/1454b76482d42e78c1904028de55d82261e5ecaa)), closes [#I4LW3](https://gitee.com/openharmony/kernel_liteos_m/issues/I4LW3)
* 解决los_pm.c:743:19: warning 编译告警 ([0c72c8b](https://gitee.com/openharmony/kernel_liteos_m/commits/0c72c8bf94b053ff90bbf2019006c52adf1eb8df)), closes [#I4D4L8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4D4L8)
* 解决定时器超时但还在队列中无法删除的问题 ([ecce17e](https://gitee.com/openharmony/kernel_liteos_m/commits/ecce17ea4878c7bdf7d7de9a6848e6bf871563de)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 解除net对cmsis的依赖net属于内核模块不应该依赖内核对外接口 ([9982624](https://gitee.com/openharmony/kernel_liteos_m/commits/99826240d979c3aa820ab2aace62e3338978e6d1))
* 调度中将pm相关的部分用LOSCFG_KERNEL_PM包含 ([d7c0059](https://gitee.com/openharmony/kernel_liteos_m/commits/d7c0059dc4fcca3f85d2cad1012353892ce28021)), closes [#I4L00](https://gitee.com/openharmony/kernel_liteos_m/issues/I4L00)
* 调用LOS_TaskDetach操作已退出的joinable的任务时未正确回收该任务 ([49c93b3](https://gitee.com/openharmony/kernel_liteos_m/commits/49c93b37c5e215612bbeb4619e73c809f9eb1cac)), closes [#I4DZL7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4DZL7)
* 针对pr是否同步至release分支增加原因说明规则 ([1ee543d](https://gitee.com/openharmony/kernel_liteos_m/commits/1ee543d5d31524d543ffb297b121224dedf8602f))
* 队列相关的API实现中,参数的校验不完全,导致程序异常 ([eef7c80](https://gitee.com/openharmony/kernel_liteos_m/commits/eef7c80a725d68af254ae55091bd36f978cf4284))
### Features
* adapt net ([8594ee4](https://gitee.com/openharmony/kernel_liteos_m/commits/8594ee469ad2d40a363e5d77f94f292ab3cb8c21))
* add option for ioctl ([5e8ac4b](https://gitee.com/openharmony/kernel_liteos_m/commits/5e8ac4b8883f64bbffa5bb3f063a601112058396)), closes [#I4I3W5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4I3W5)
* add option SIOCGIFBRDADDR for ioctl ([33ee492](https://gitee.com/openharmony/kernel_liteos_m/commits/33ee49295329e3c394d1cc7b16f77a23ac2255a8)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* added assembly atomic interface ([1513f50](https://gitee.com/openharmony/kernel_liteos_m/commits/1513f50a474d1227a83fb655ad18c19cd792f235))
* backtrace for arm9 ([03de7f3](https://gitee.com/openharmony/kernel_liteos_m/commits/03de7f37450a8821ea05e60e94a5d1dd359c4f99)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* Board 和 SoC分离编译适配 ([3f1c04d](https://gitee.com/openharmony/kernel_liteos_m/commits/3f1c04dd57bca0379ce37162d9d824801e7d880f))
* **build:** add module_group and comment out arch_cflags ([e5636f7](https://gitee.com/openharmony/kernel_liteos_m/commits/e5636f7acaf7e8b7d14dc07930b2a16c86e63c85))
* **build:** support Kconfig ([7e67343](https://gitee.com/openharmony/kernel_liteos_m/commits/7e673430dc42c55b3a0a6d955ba8fea21d6d58ea))
* **cmsis:** support max_count for osSemaphoreNew ([d478152](https://gitee.com/openharmony/kernel_liteos_m/commits/d478152762013975551e1af154df42987596c9a6))
* cortex-m55支持psplimit ([db7d641](https://gitee.com/openharmony/kernel_liteos_m/commits/db7d641c223db8ab25501d79c2a6331f743d830b)), closes [#I4T7R3](https://gitee.com/openharmony/kernel_liteos_m/issues/I4T7R3)
* littlefs最大打开文件个数修改为可通过menuconfig配置 ([9bc9f3a](https://gitee.com/openharmony/kernel_liteos_m/commits/9bc9f3aa53be7bf392d3da09adcb184dec8e3da2))
* newlib支持pthread_equal ([ce5357e](https://gitee.com/openharmony/kernel_liteos_m/commits/ce5357eee1daf1c1b3a3aa7bdeaef0cc5a8901bf)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* provide read write for socket by #define ([d044eda](https://gitee.com/openharmony/kernel_liteos_m/commits/d044eda3c3640ae135ef528739d0c9609f40c822)), closes [#I4H8](https://gitee.com/openharmony/kernel_liteos_m/issues/I4H8)
* synchronizing arch api ([04bf3a6](https://gitee.com/openharmony/kernel_liteos_m/commits/04bf3a682f149482d8ebdbb9ff96d6889edb487a)), closes [#I4N7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4N7)
* synchronous los_hwicreate interface ([6c68ada](https://gitee.com/openharmony/kernel_liteos_m/commits/6c68adad4db7f6112990764eafe6a3bd5f8759a5))
* 低内存资源回收low memory killer ([ab886d8](https://gitee.com/openharmony/kernel_liteos_m/commits/ab886d848ab809942c11d0e408b8ff76c41b92b2)), closes [#I4ID0](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ID0)
* 低功耗支持冻结线程等需求 ([9b5739a](https://gitee.com/openharmony/kernel_liteos_m/commits/9b5739ab11ae7a89d35ba6f54fc62137ddc6d897)), closes [#I49](https://gitee.com/openharmony/kernel_liteos_m/issues/I49)
* 内核提供Interrupt框架支持多架构多平台通用化 ([e8538d0](https://gitee.com/openharmony/kernel_liteos_m/commits/e8538d041a93817cea4ae3914afcfdc6182483e7))
* 内核提供tick timer框架支持多架构多平台通用化 ([f635450](https://gitee.com/openharmony/kernel_liteos_m/commits/f635450d7cf7f674de3803b5eb9d759b6e4d005b)), closes [#I4N7](https://gitee.com/openharmony/kernel_liteos_m/issues/I4N7)
* 同步调度部分优化至liteos_m ([fb11ab1](https://gitee.com/openharmony/kernel_liteos_m/commits/fb11ab181e69289f7a2edfd5857595b89f1d5d67))
* 支持cortex-m55 ([6e17805](https://gitee.com/openharmony/kernel_liteos_m/commits/6e1780546c173365262c7a50b81896f5b3c46389)), closes [#I4Q9](https://gitee.com/openharmony/kernel_liteos_m/issues/I4Q9)
* 支持Lms ([7b838e8](https://gitee.com/openharmony/kernel_liteos_m/commits/7b838e8a7b8e9f7fb34ca495e5cb46d70d12722b)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 支持posix 和 cmsis join能力 ([ecfdf7f](https://gitee.com/openharmony/kernel_liteos_m/commits/ecfdf7ff9bf1adf06835968dc6f06b7c45e04862)), closes [#I44V26](https://gitee.com/openharmony/kernel_liteos_m/issues/I44V26)
* 支持posix线程私有数据能力 ([a856303](https://gitee.com/openharmony/kernel_liteos_m/commits/a856303b9cdadcfade33de0d3a335db0332f5761)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 支持pthread_condattr_setclock ([68dad2c](https://gitee.com/openharmony/kernel_liteos_m/commits/68dad2ccc9856dc2c1ac112bc8f30a703c1af5d9)), closes [#I4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4)
* 支持pthread_mutex属性相关接口 ([d2be4d7](https://gitee.com/openharmony/kernel_liteos_m/commits/d2be4d7a460365844a7732df8a3eb59e6bb64897)), closes [#I4G4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4)
* 支持select.h的FD_SETSIZE宏配置 ([05642f0](https://gitee.com/openharmony/kernel_liteos_m/commits/05642f05ae6b220df977f4402bc31f396bf08603)), closes [#I4RYK4](https://gitee.com/openharmony/kernel_liteos_m/issues/I4RYK4)
* 支持任务栈可配置 ([96cc92d](https://gitee.com/openharmony/kernel_liteos_m/commits/96cc92d03561e1a9f1030c71916068584b349626))
* 调度、任务及pm解耦 ([cc8a794](https://gitee.com/openharmony/kernel_liteos_m/commits/cc8a794229f4236a1611183fd482740b3badbcd7)), closes [#I4JTN6](https://gitee.com/openharmony/kernel_liteos_m/issues/I4JTN6)
* 适配三方库FatFs升级至r0.14a版本 ([92ea355](https://gitee.com/openharmony/kernel_liteos_m/commits/92ea355756ebd92b8809ecb638ffb5355d89c5e9))
### BREAKING CHANGES
* pthread_create 支持任务栈设置
osThreadNew 支持任务栈设置
TSK_INIT_PARAM_S 结构体添加stackAddr 字段
* 涉及接口修改:
LOS_HwiCreate LOS_HwiDelete
改动内容:
中断处理函数参数类型由HWI_ARG_T统一改为HwiIrqParam封装原有arg参数及riscv部分实际使用变量pDevId, 这样一方面统一LiteOS接口也统一了中断处理函数的arg参数
同步LOS_HwiDelete接口入参新增HWI_IRQ_PARAM_S *irqParam参数为后续共享中断功能的添加预留
* 新增接口:
LOS_TaskResRecycle
LOS_CurrNanosec
LOS_MDelay
接口修改:
LOS_QueueCreate第一个入参添加const修饰并增加一种异常情况处理
los_memory.c中 OS_ERROR 修改为LOS_NOK重定义LOS_NOK为UINT32-1。
接口位置转移:
LOS_UDelay 由los_task.h/.c转移到los_tick.h/.c
宏修改:
LOS_ERRNO_MUX_PEND_INTERR 改名为 LOS_ERRNO_MUX_IN_INTERR
* **posix接口融合:**
接口修改:
calloc
pthread_mutex_init
mq_unlink
pthread_join
pthread_exit
pthread_attr_init
pthread_attr_destroy
pthread_condattr_destroy
pthread_cond_timedwait
pthread_mutexattr_init
pthread_mutexattr_settype
pthread_mutex_destroy
pthread_mutex_timedlock
pthread_mutex_trylockk
pthread_mutex_unlock
sem_getvalue
sem_timedwait
pthread_cond_timedwait
nanosleep
timer_create
timer_settime
timer_gettime
testStdlibStrtoull005
testStdlibStrtol011
testStdlibStrtoul007
testPthread004
新增接口:
CheckForCancel
pthread_setcancelstate
pthread_setcanceltype
pthread_once
pthread_setschedprio
pthread_attr_setstack
pthread_attr_getstack
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_condattr_getclock
pthread_mutexattr_gettype
CheckMutexAttr
OsMuxPreCheck
sem_trywait
MuxPendForPosix
MuxPostForPosix
增加overrun功能
接口变化:
mq_getsetattr 改为内部接口MqGetSetAttr
GetTickTimeFromNow->OsGetTickTimeFromNow
接口位置转移:
pthread_equal接口由newlib下转移到kal/posix/src/pthread.c中
* **posix:** 接口修改:
calloc
pthread_mutex_init
mq_unlink
pthread_join
pthread_exit
pthread_attr_init
pthread_attr_destroy
pthread_condattr_destroy
pthread_cond_timedwait
pthread_mutexattr_init
pthread_mutexattr_settype
pthread_mutex_destroy
pthread_mutex_timedlock
pthread_mutex_trylockk
pthread_mutex_unlock
sem_getvalue
新增接口:
CheckForCancel
pthread_setcancelstate
pthread_setcanceltype
pthread_once
pthread_setschedprio
pthread_attr_setstack
pthread_attr_getstack
pthread_condattr_getpshared
pthread_condattr_setpshared
pthread_condattr_getclock
pthread_mutexattr_gettype
CheckMutexAttr
OsMuxPreCheck
sem_trywait
接口变化:
mq_getsetattr 改为内部接口OsMqGetSetAttr
接口位置转移:
pthread_equal接口由newlib下转移到kal/posix/src/pthread.c中
* 新增接口:
LOS_HwiTrigger ArchIntTrigger
LOS_HwiEnable ArchIntEnable
LOS_HwiDisable ArchIntDisable
LOS_HwiClear ArchIntClear
LOS_HwiSetPriority ArchIntSetPriority
* Assembly implementation:
ArchAtomicRead
ArchAtomicSet
ArchAtomicAdd
ArchAtomicSub
ArchAtomicInc
ArchAtomicIncRet
ArchAtomicDec
ArchAtomicDecRet
* 原来版本中每个架构下提供的tick timer相关操作函数为弱函数
WEAK UINT32 HalTickStart(OS_TICK_HANDLER handler);
WEAK VOID HalSysTickReload(UINT64 nextResponseTime);
WEAK UINT64 HalGetTickCycle(UINT32 *period);
WEAK VOID HalTickLock(VOID);
WEAK VOID HalTickUnlock(VOID);
用户如果需要启用自己的tick timer需要自己实现相关接口(强属性),在 "内核初始化之前" 通过调用:
LOS_TickTimerRegister 接口替换系统默认提供的tick timer相关接口。
无论用户提供的tick timer 还是系统默认提供的,均在内核初始化时启动。
* int pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
int pthread_key_delete(pthread_key_t k)
int pthread_setspecific(pthread_key_t k, const void *x)
void *pthread_getspecific(pthread_key_t k)
* 1.修改arch/include下接口以ArchXX命名函数
2.提取公共函数声明:ArchAtomicXchg32bits、ArchAtomicDecRet、ArchAtomicCmpXchg32bits
3.新增部分原子操作c内联实现
* 增加低内存资源回收注册相关接口LOS_LmkOpsNodeRegister、LOS_LmkOpsNodeUnregister和内存资源释放和任务恢复接口LOS_LmkTasksKill和LOS_LmkTasksRestore.
* SwtmrHandlerItem结构体新增swtmrID字段用于标识超时队列中软件定时器id
* 新增支持API:
LOS_LmsCheckPoolAdd使能检测指定内存池
LOS_LmsCheckPoolDel不检测指定内存池
LOS_LmsAddrProtect为指定内存段上锁不允许访问
LOS_LmsAddrDisableProtect去能指定内存段的访问保护
# (2021-09-30)
### Bug Fixes
* M核代码告警清零 ([cb5f862](https://gitee.com/openharmony/kernel_liteos_m/commits/cb5f862eafd91675bf53d0320616cc8f707a6e5a)), closes [#I4386](https://gitee.com/openharmony/kernel_liteos_m/issues/I4386)
* M核告警消除 ([5a9d53b](https://gitee.com/openharmony/kernel_liteos_m/commits/5a9d53b6444a3bbe084f575ef079f0da36c27c2a)), closes [#I46](https://gitee.com/openharmony/kernel_liteos_m/issues/I46)
* M核编译配置修改 ([deff7c9](https://gitee.com/openharmony/kernel_liteos_m/commits/deff7c921f606ed85663f91d21c12163c15aa7f8)), closes [#I46](https://gitee.com/openharmony/kernel_liteos_m/issues/I46)
* shell模块task命令踩内存问题修改 ([b5e84d5](https://gitee.com/openharmony/kernel_liteos_m/commits/b5e84d5516b599257151f88b5a830d6fe9e0e188)), closes [#II4](https://gitee.com/openharmony/kernel_liteos_m/issues/II4)
* trustzone 中断适配 ([15a2c17](https://gitee.com/openharmony/kernel_liteos_m/commits/15a2c17f791b7d6703863718d92fa35402c41067)), closes [#I42](https://gitee.com/openharmony/kernel_liteos_m/issues/I42)
* add API LOS_HwiCreate and LOS_HwDelete ([eb668eb](https://gitee.com/openharmony/kernel_liteos_m/commits/eb668eb9e0021961230858f9bfa1599646da9a8f)), closes [#I3R75](https://gitee.com/openharmony/kernel_liteos_m/issues/I3R75)
* add liteos_m vfs ([5479dd6](https://gitee.com/openharmony/kernel_liteos_m/commits/5479dd66d7ec96d2206a9890586fe5f07d50fbb9)), closes [#I3R493](https://gitee.com/openharmony/kernel_liteos_m/issues/I3R493)
* backtrace代码段判断函数定义成弱函数如果有多个代码段那么可根据实际情况重定义 ([8692ed3](https://gitee.com/openharmony/kernel_liteos_m/commits/8692ed33a3b975bac7aa5b6ce3c40a84e281f6c5)), closes [#I420](https://gitee.com/openharmony/kernel_liteos_m/issues/I420)
* change cpup retval range ([d00a35b](https://gitee.com/openharmony/kernel_liteos_m/commits/d00a35ba9288047e9eaba06a8ed1d15806bfca40))
* change description according to review ([a38365e](https://gitee.com/openharmony/kernel_liteos_m/commits/a38365ed097fb398f922a5d1a72305933ae3e7b3))
* change queuePosion to queuePosition ([e772ccb](https://gitee.com/openharmony/kernel_liteos_m/commits/e772ccb3ccd3b31269066fa59a434a23af98ce51))
* change to OpenHarmony LiteOS-M ([259fb54](https://gitee.com/openharmony/kernel_liteos_m/commits/259fb54b3c1a208c5672f1f6551ba0424505e4b2))
* comment error ([a37b73d](https://gitee.com/openharmony/kernel_liteos_m/commits/a37b73d7599a62a728dbf564de9d9927f995ec1b))
* compile warning fix ([8dea15c](https://gitee.com/openharmony/kernel_liteos_m/commits/8dea15c4fcaff2957c60351781180f964c0a882d)), closes [#I4330](https://gitee.com/openharmony/kernel_liteos_m/issues/I4330)
* compile warnings ([75f6187](https://gitee.com/openharmony/kernel_liteos_m/commits/75f61870a002e238385bc9a7632d42b0b2488c9a)), closes [#I3Y57](https://gitee.com/openharmony/kernel_liteos_m/issues/I3Y57)
* correct ECB in comment ([e2aeb1f](https://gitee.com/openharmony/kernel_liteos_m/commits/e2aeb1ff1d4cd54a752c9f6ef976ee8e353da620))
* correct spelling ([dd5cefb](https://gitee.com/openharmony/kernel_liteos_m/commits/dd5cefb0dace4b7a7276c880e45d5520950e9844))
* correct spelling ([e7ea50f](https://gitee.com/openharmony/kernel_liteos_m/commits/e7ea50f13142e34a9860e75be051538fe91e234e))
* correct the counter of exception type ([bff6587](https://gitee.com/openharmony/kernel_liteos_m/commits/bff65877a281ac1cdcbefd325dcd3ad4933edac9))
* correct typo ([3ceface](https://gitee.com/openharmony/kernel_liteos_m/commits/3ceface13e1c15d107bc3c8460c17b9dd4c95e26))
* cpup funciton repair ([c842251](https://gitee.com/openharmony/kernel_liteos_m/commits/c842251bab7ea6365f2bee8ae880e6efb60f0c73))
* delete unused symbols for default config ([7ad3a22](https://gitee.com/openharmony/kernel_liteos_m/commits/7ad3a22b4d62c8b00876ff338c4ce8d1e3f3cbe2)), closes [#I45HN3](https://gitee.com/openharmony/kernel_liteos_m/issues/I45HN3)
* fix __cplusplus typo ([c3eb3e5](https://gitee.com/openharmony/kernel_liteos_m/commits/c3eb3e59e692371f67a4e21e4b38004195ce5e10))
* fix backtrace check issue ([b6664e6](https://gitee.com/openharmony/kernel_liteos_m/commits/b6664e66f14d432b02101c883a53cb333dc4c195))
* fix bad params def in HalTickStart ([4443b74](https://gitee.com/openharmony/kernel_liteos_m/commits/4443b74ea63d2e458af69723a7198bbbaeb856ea)), closes [#I48](https://gitee.com/openharmony/kernel_liteos_m/issues/I48)
* fix comment typo issue ([0c2a675](https://gitee.com/openharmony/kernel_liteos_m/commits/0c2a675e2d163eaf05aff7df226404888d78ca37))
* fix destroy typo ([4ba6259](https://gitee.com/openharmony/kernel_liteos_m/commits/4ba6259e94bd677764922b0470fddc2590f6efa5))
* fix function name ([f7d50d0](https://gitee.com/openharmony/kernel_liteos_m/commits/f7d50d0fbf53cdd352e94a387cf707083f1641bb))
* fix length typo ([98d6580](https://gitee.com/openharmony/kernel_liteos_m/commits/98d65801de9e37199b5df9c8734ebcb6ff5d853d))
* fix LOS_MEMBOX_ALIGNED macro name ([fced899](https://gitee.com/openharmony/kernel_liteos_m/commits/fced8992cf4fbc26c9722d528d642a7afe479170))
* fix LOS_TaskNameGet comment ([c70b28b](https://gitee.com/openharmony/kernel_liteos_m/commits/c70b28bf785da12fd60ecc92a5a63fb54e52c22a))
* fix macro typo ([1600360](https://gitee.com/openharmony/kernel_liteos_m/commits/16003604a948d081151ca4fcf0cfeea91c9e1960))
* fix misspell in comments ([4572814](https://gitee.com/openharmony/kernel_liteos_m/commits/457281427ba286e24386d7916c4bc81f112f1c60))
* fix NULL UNUSED redefined issue ([765bd55](https://gitee.com/openharmony/kernel_liteos_m/commits/765bd551990e906f457ec1145aea4f2bf5856547))
* fix OS_TASK_STACK_PROTECT_SIZE undeclared error ([2a5a515](https://gitee.com/openharmony/kernel_liteos_m/commits/2a5a515f50a0f344d416218046bf0880facfb97c)), closes [#I4C5](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C5)
* fix print format compilation warning ([ef12c89](https://gitee.com/openharmony/kernel_liteos_m/commits/ef12c89c7a79791665125a0b7391f9e533a06a0f))
* fix readme link issue ([9e332c6](https://gitee.com/openharmony/kernel_liteos_m/commits/9e332c69a5813027575786424b78f0ae2f9a4c5a))
* fix some typo issues ([f6b8cab](https://gitee.com/openharmony/kernel_liteos_m/commits/f6b8cab2539e4d1ee9e47ab8e3eb12f1630f7393))
* fix typo in comment ([811d3fa](https://gitee.com/openharmony/kernel_liteos_m/commits/811d3fae8a39686a1c66dfd61c897b7fd3fac2ac))
* fix typos ([191644e](https://gitee.com/openharmony/kernel_liteos_m/commits/191644e4412fccb7142cfcd34316ad8e2d24fcdf))
* Fixed a spelling error in FS_LOCK_TIMEOUT_SEC. ([42dc308](https://gitee.com/openharmony/kernel_liteos_m/commits/42dc3083693be13c5fa8f2ad8213245465e28adf)), closes [#I3TL66](https://gitee.com/openharmony/kernel_liteos_m/issues/I3TL66)
* include file log_config.h in los_mpu.c ([1932d71](https://gitee.com/openharmony/kernel_liteos_m/commits/1932d714a589c9e87258d7c8ed647b6110bde543))
* L0 GN compilation problem ([2f9bfcc](https://gitee.com/openharmony/kernel_liteos_m/commits/2f9bfcc6ee436ee3568d0c8158a8e43c9ef02623)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* l0 shell adapt new master ([fd2227e](https://gitee.com/openharmony/kernel_liteos_m/commits/fd2227e5c858c840f63629c27e559580e1cbdf2f))
* littlefs inappropriate return value and errno ([452f364](https://gitee.com/openharmony/kernel_liteos_m/commits/452f36403dd4376572d8b52352d0d8129a4617e4)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* littlefs三方源码采用GN编译修改上库 ([bdb614b](https://gitee.com/openharmony/kernel_liteos_m/commits/bdb614bc2b82011d77c7c8ffb95e415d2640d19d))
* LOS_QueueInfoGet函数统计等待读写任务有误 ([215a1f6](https://gitee.com/openharmony/kernel_liteos_m/commits/215a1f6dc06cf2348c5875f7b05193b26ec17dde)), closes [#I4C6P2](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C6P2)
* los_swtmr.h不满足自包含要求对los_config.h存在依赖但未包含los_config.h ([ad8e96a](https://gitee.com/openharmony/kernel_liteos_m/commits/ad8e96a00f2fcaebe57feae4e3f23f99d7f1d066)), closes [#I40](https://gitee.com/openharmony/kernel_liteos_m/issues/I40)
* **mbedtls:** mbedtls l0 support ([761b860](https://gitee.com/openharmony/kernel_liteos_m/commits/761b86096c3cf5642c95e556c11a45a3d5f413e4)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* misspell ([30578a6](https://gitee.com/openharmony/kernel_liteos_m/commits/30578a6a68a0d3a203b9a00e7bd1a946356d13d2))
* modify event API description ([9481f1d](https://gitee.com/openharmony/kernel_liteos_m/commits/9481f1d8406960b8b859cc5a84b3831eadaf040c))
* modify the return type of LOS_IntLock from UINTPTR to UINT32. ([bcc34e2](https://gitee.com/openharmony/kernel_liteos_m/commits/bcc34e22ede5aeccea63aba9f9ce3cb9aa92cbeb))
* modify type INLNIE ([294a6d2](https://gitee.com/openharmony/kernel_liteos_m/commits/294a6d246b6a1f7cba8ce1bc4eeb9ae11f17a003))
* Mutex锁释放后无任务持有的情况下owner未清空 ([c136cfd](https://gitee.com/openharmony/kernel_liteos_m/commits/c136cfdf973ae0068154606afa3a23858822c347)), closes [#I40OC8](https://gitee.com/openharmony/kernel_liteos_m/issues/I40OC8)
* M核littlefs当文件open失败时需要回收fd否则会有fd泄露 ([b458e12](https://gitee.com/openharmony/kernel_liteos_m/commits/b458e12ed54905db6667f9d5db1410f94a3d6c71)), closes [#I3XU6](https://gitee.com/openharmony/kernel_liteos_m/issues/I3XU6)
* m核上littlefs新增错误码功能 ([a062378](https://gitee.com/openharmony/kernel_liteos_m/commits/a06237863121816fa6421aed233446a3fa4e2665)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* net compile fix ([299813c](https://gitee.com/openharmony/kernel_liteos_m/commits/299813cdb43ae1e24200f0a6b006e04e4d4fcb05))
* open shell & fix qemu compile ([911a767](https://gitee.com/openharmony/kernel_liteos_m/commits/911a767992ee540a96ee9f67e0b87195656c3eab))
* ping cmd compile fail ([ae05de3](https://gitee.com/openharmony/kernel_liteos_m/commits/ae05de3ffda86d312d33b2e38f237dd76daf4949))
* protect from accssing NULL pointer, access g_handle after fslock ([bc7a914](https://gitee.com/openharmony/kernel_liteos_m/commits/bc7a914bce1b227a4f57265d5ecc3f82d78533e7)), closes [#I3UCX3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3UCX3)
* remove changelog in README ([37ef8ca](https://gitee.com/openharmony/kernel_liteos_m/commits/37ef8ca7ae73bf78f56dfef36c48bcd790afb6ff)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* remove libsec_kernel ([1144b75](https://gitee.com/openharmony/kernel_liteos_m/commits/1144b75f3ff9ce9e8fa114cf614d3deade8ac7c2))
* remove project files ([4ad01ce](https://gitee.com/openharmony/kernel_liteos_m/commits/4ad01ced93684e5c7ba144ca267f8fcc2fe03105))
* remove targets project files ([f39da5a](https://gitee.com/openharmony/kernel_liteos_m/commits/f39da5a6da59a3b1291c6b9ef7c50e6185df5ea1))
* risc-v 锁中断在调度后失效 ([70f3aa1](https://gitee.com/openharmony/kernel_liteos_m/commits/70f3aa1c112e949d9af8e0245af5879140adefba)), closes [#I42](https://gitee.com/openharmony/kernel_liteos_m/issues/I42)
* riscv_nuclei 编译失败 ([d3fb23c](https://gitee.com/openharmony/kernel_liteos_m/commits/d3fb23cca06580b6e447a9476a9c16643c4ea8fe)), closes [#I41](https://gitee.com/openharmony/kernel_liteos_m/issues/I41)
* rollback resources when opendir failed ([82fad6c](https://gitee.com/openharmony/kernel_liteos_m/commits/82fad6c36f183de93d936dd2007b899c2932bcee)), closes [#I3Y577](https://gitee.com/openharmony/kernel_liteos_m/issues/I3Y577)
* Scheduling module code to join GN compilation. ([8bf166b](https://gitee.com/openharmony/kernel_liteos_m/commits/8bf166b418ce1a6c027dc304d45fc9431923764c)), closes [#I3OA95](https://gitee.com/openharmony/kernel_liteos_m/issues/I3OA95)
* The hook module fails to compile under the c99 compilation standard. ([a078c30](https://gitee.com/openharmony/kernel_liteos_m/commits/a078c3086fa47e05e3ffdc4e94ca202284a1487b)), closes [#I3S4](https://gitee.com/openharmony/kernel_liteos_m/issues/I3S4)
* tick 动态化计算优化,减小中断执行时间对系统总体时间的影响,保证软件定时器的响应精度。 ([2118c84](https://gitee.com/openharmony/kernel_liteos_m/commits/2118c84616cce5b5d4569d5a82a4d5de02af1e1c)), closes [#I3YGP1](https://gitee.com/openharmony/kernel_liteos_m/issues/I3YGP1)
* timer qemu 头文件缺失 ([12fed74](https://gitee.com/openharmony/kernel_liteos_m/commits/12fed747226c377c656b8acb8346154627845b6f))
* update according to review comments ([4dc0d31](https://gitee.com/openharmony/kernel_liteos_m/commits/4dc0d313d1b4a39ebb62156d0bb6429ebb8b996d))
* update arch_spec.md ([cf43988](https://gitee.com/openharmony/kernel_liteos_m/commits/cf439885234e0955bab09834b3b876d627c81605))
* update doc usage ([5c19fd4](https://gitee.com/openharmony/kernel_liteos_m/commits/5c19fd4beca15a8b7faad847a13943a9abfe3c8c))
* update document description ([954c2fc](https://gitee.com/openharmony/kernel_liteos_m/commits/954c2fcfb531d0da1dcc6354a0c0b14335566ed7))
* update macro to config item ([be57ece](https://gitee.com/openharmony/kernel_liteos_m/commits/be57ece9ce6200c8868164bc0bb2f26e3062cd37))
* 以g_sysSchedStartTime是否为0判断时间轴是否生效存在极限场景导致调度时间不生效 ([509cf59](https://gitee.com/openharmony/kernel_liteos_m/commits/509cf59befb40839a376be31958d615f066c66fd)), closes [#I45HP5](https://gitee.com/openharmony/kernel_liteos_m/issues/I45HP5)
* 修复littlefs的多分区挂载时对pathname的处理逻辑异常 ([b55cfc1](https://gitee.com/openharmony/kernel_liteos_m/commits/b55cfc1ba7fc470b876c555ac7d3be0aa1d3d363)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* 修复littlefs编译fs.c缺少头文件件依赖配置+若干musl库的缺失问题+多分区规格宏配置问题 ([7259289](https://gitee.com/openharmony/kernel_liteos_m/commits/7259289bd98a743f596060bc607f77ab8f149129)), closes [#I3VT11](https://gitee.com/openharmony/kernel_liteos_m/issues/I3VT11)
* 修复M核littlefs GN编译的若干错误 ([d77828e](https://gitee.com/openharmony/kernel_liteos_m/commits/d77828e206f3324424c3b1372332828a0afb84c2))
* 修复M核上musl库缺失strdup,c的问题 ([139f83a](https://gitee.com/openharmony/kernel_liteos_m/commits/139f83af391a4f5e64ab0fccbd783dd651b87e6a)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* 修复QUEUE_INFO_S中waitReadTask无法保存大于32的任务编号 ([704cca9](https://gitee.com/openharmony/kernel_liteos_m/commits/704cca97b17972d1640fd33b1fa0b5917bb92b19)), closes [#I41N78](https://gitee.com/openharmony/kernel_liteos_m/issues/I41N78)
* 修复task命令格式错误增加copyright ([ad15bbd](https://gitee.com/openharmony/kernel_liteos_m/commits/ad15bbd6a4d298aabc05b26d7838de6425dbc5c5))
* 修复timer_settime只设置第一次到期时间时到期时间不准的缺陷 ([a5f4e37](https://gitee.com/openharmony/kernel_liteos_m/commits/a5f4e37e535bff39a333c469e2f1bf1817216fe8)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* 修复timer_settime只设置第一次到期时间时到期时间不准的缺陷 ([e4b5d4e](https://gitee.com/openharmony/kernel_liteos_m/commits/e4b5d4ebe9677d49d490fe74e5ac33c4a29435a2)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* 修复不规范的copyright ([2d9bbd2](https://gitee.com/openharmony/kernel_liteos_m/commits/2d9bbd2769e71e7b464bd22fc335999dd8000682)), closes [#I3SPJ1](https://gitee.com/openharmony/kernel_liteos_m/issues/I3SPJ1)
* 修复中断操作接口头文件位置变更,导致的编译错误 ([013a953](https://gitee.com/openharmony/kernel_liteos_m/commits/013a953926ca7cefd8a2f7c74d23c36c49765b59)), closes [#I4665](https://gitee.com/openharmony/kernel_liteos_m/issues/I4665)
* 修复文档链接失效问题 ([5d53c84](https://gitee.com/openharmony/kernel_liteos_m/commits/5d53c848124319a95f509b56ba001357c6dd8b05)), closes [#I4529](https://gitee.com/openharmony/kernel_liteos_m/issues/I4529)
* 内核模块编译增加-Werror编译选项且清除内核编译告警 ([3798091](https://gitee.com/openharmony/kernel_liteos_m/commits/3798091d87441ea445ec642de57e036dbbc8370e)), closes [#I46E6](https://gitee.com/openharmony/kernel_liteos_m/issues/I46E6)
* 删除MQ内冗余的重复宏定义 ([6d72916](https://gitee.com/openharmony/kernel_liteos_m/commits/6d7291660ad04682f05850876f81dfd0cba8ea6b)), closes [#I3U5](https://gitee.com/openharmony/kernel_liteos_m/issues/I3U5)
* 删除延时节点后,存在时间无法有效刷新的场景 ([0a87c04](https://gitee.com/openharmony/kernel_liteos_m/commits/0a87c04d58d11da2082470698de0760d72259533)), closes [#I45I9](https://gitee.com/openharmony/kernel_liteos_m/issues/I45I9)
* 在内核初始化前期启动tick timer ([b3841ed](https://gitee.com/openharmony/kernel_liteos_m/commits/b3841ed1ddbfb3359c7a0ceca04fc0f645d440c3)), closes [#I410F0](https://gitee.com/openharmony/kernel_liteos_m/issues/I410F0)
* 增加MPU功能的开关宏默认关闭 ([9709d29](https://gitee.com/openharmony/kernel_liteos_m/commits/9709d29b87a3888412ffda586e16eba86adccfe7)), closes [#I3WE0](https://gitee.com/openharmony/kernel_liteos_m/issues/I3WE0)
* 宏LOSCFG_SUPPORT_FATFS在fs.c中存在使用问题导致无fatfs的情况下编译出错 ([c1614ce](https://gitee.com/openharmony/kernel_liteos_m/commits/c1614ce2b4d4dfcda9532cbeeff25ad7a6558196)), closes [#I44](https://gitee.com/openharmony/kernel_liteos_m/issues/I44)
* 延时队列为NULL时返回的响应时间为64位最大值导致无法更新tick timer的响应周期 ([bcec32e](https://gitee.com/openharmony/kernel_liteos_m/commits/bcec32e389634097102a203ee7e937ed3193c984)), closes [#I3W1](https://gitee.com/openharmony/kernel_liteos_m/issues/I3W1)
* 支持smoke 测试用例 ([3ad5942](https://gitee.com/openharmony/kernel_liteos_m/commits/3ad5942301a1094a2c6b6ffee280cf09cfdb2a88)), closes [#I424](https://gitee.com/openharmony/kernel_liteos_m/issues/I424)
* 新增函数regcomp,regfree和regexec支持 ([86d5544](https://gitee.com/openharmony/kernel_liteos_m/commits/86d5544a3fd5f41f7f2abe3b143e9f1dc9b430f8)), closes [#I3U9](https://gitee.com/openharmony/kernel_liteos_m/issues/I3U9)
* 清理残留无效的trace代码 ([3c48951](https://gitee.com/openharmony/kernel_liteos_m/commits/3c489518576583ab6bf0d581810ef0a02b6ccd51)), closes [#I3ZMB4](https://gitee.com/openharmony/kernel_liteos_m/issues/I3ZMB4)
* 解决arm9编译冲突问题 ([c1a6245](https://gitee.com/openharmony/kernel_liteos_m/commits/c1a624536887fef44fed37134638bf40191b9aae)), closes [#I420](https://gitee.com/openharmony/kernel_liteos_m/issues/I420)
* 调度过程低概率触发OsSchedTaskEnQueue断言导致系统异常 ([e5e9289](https://gitee.com/openharmony/kernel_liteos_m/commits/e5e9289a08cf1db71c09647b71a864f5a1f8a4a2)), closes [#I3VX9](https://gitee.com/openharmony/kernel_liteos_m/issues/I3VX9)
* 调整hook类型和位置方便调试 ([369320d](https://gitee.com/openharmony/kernel_liteos_m/commits/369320de3710486f252c55c522e8c06e19541b77)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
### Features
* add cmsis ThreadFlags support ([cea551e](https://gitee.com/openharmony/kernel_liteos_m/commits/cea551e99ea0da8eefbaa826de2f68813252fb83))
* add deps to musl and securec ([bfa25fc](https://gitee.com/openharmony/kernel_liteos_m/commits/bfa25fcaa355c28a6139f683c4453f677e23abd7))
* add file type support for LfsStat ([ceaed2d](https://gitee.com/openharmony/kernel_liteos_m/commits/ceaed2dc86de2ed242aab4dd02c1f34e064583b3)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* add interface of dhcp_is_bound ([84a180d](https://gitee.com/openharmony/kernel_liteos_m/commits/84a180d585686cda693bf8c6ed6b86f7c5dd5eee)), closes [#I46W08](https://gitee.com/openharmony/kernel_liteos_m/issues/I46W08)
* add L0 shell function ([97283b7](https://gitee.com/openharmony/kernel_liteos_m/commits/97283b7c5dd44b266e94fcf0f5d21e63ee1ec7e0))
* add LOS_ListHeadInsert function ([430b186](https://gitee.com/openharmony/kernel_liteos_m/commits/430b186be7ec1554a29a6d509188eb877d796a7e)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* **kernel:** 补充获取最高、最低优先级接口 ([c24c38b](https://gitee.com/openharmony/kernel_liteos_m/commits/c24c38b084c13a2cdc5616f88bb5f63153600c28)), closes [#I42HM7](https://gitee.com/openharmony/kernel_liteos_m/issues/I42HM7)
* L0 armquem 剥离工具链 ([67d7455](https://gitee.com/openharmony/kernel_liteos_m/commits/67d74559d1bb3820bd51da2e2bf43e41e1224314))
* L0 支持Trace ([56c93a6](https://gitee.com/openharmony/kernel_liteos_m/commits/56c93a641b3c7a3d1ef9293ee3c95cccb559191f)), closes [#I41Y9](https://gitee.com/openharmony/kernel_liteos_m/issues/I41Y9)
* L0 支持低功耗框架 ([558ce14](https://gitee.com/openharmony/kernel_liteos_m/commits/558ce14becab05102497afca90a43d89abaf5531)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* L0 测试用例支持risc-v qemu 编译运行 ([2dd6c08](https://gitee.com/openharmony/kernel_liteos_m/commits/2dd6c080daab52eaf61e5eefe7b581190670e8a7)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* **liteos_m:** support backtrace for riscv ([ca1792a](https://gitee.com/openharmony/kernel_liteos_m/commits/ca1792aa4b5a85ca4ea6e41b265858c6b24a6897)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* los_memory.c代码重复率处理 ([475db62](https://gitee.com/openharmony/kernel_liteos_m/commits/475db62db1ac285fc6cab91f09af618870269580)), closes [#I44](https://gitee.com/openharmony/kernel_liteos_m/issues/I44)
* M33平台支持GCC环境的Trustzone ([d469da2](https://gitee.com/openharmony/kernel_liteos_m/commits/d469da29c6d316640eaa7865f98ad8d6e2eb6d44)), closes [#I3Y85](https://gitee.com/openharmony/kernel_liteos_m/issues/I3Y85)
* provide getifaddrs for liteos_m ([948501a](https://gitee.com/openharmony/kernel_liteos_m/commits/948501ac73e7887f4585eca156ad760acc2a3b1f)), closes [#I400S5](https://gitee.com/openharmony/kernel_liteos_m/issues/I400S5)
* risc-v gn 编译框架添加汇编编译选项 ([76dc343](https://gitee.com/openharmony/kernel_liteos_m/commits/76dc343c888ec4e65eba43feb49921111b144640)), closes [#I3YS5](https://gitee.com/openharmony/kernel_liteos_m/issues/I3YS5)
* Support arm9 ([6d7c9df](https://gitee.com/openharmony/kernel_liteos_m/commits/6d7c9dfe597affb260e8bd74fa606b6d68c2b49a)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* Support arm9 fiq swi mode and using system mode. ([97b5b08](https://gitee.com/openharmony/kernel_liteos_m/commits/97b5b0837be4b8df1381af29a6f650f243322840)), closes [#I3](https://gitee.com/openharmony/kernel_liteos_m/issues/I3)
* support non-continuous memory regions ([0facb0c](https://gitee.com/openharmony/kernel_liteos_m/commits/0facb0c0179f29a08b037655bbe691c98384dc84)), closes [#I43](https://gitee.com/openharmony/kernel_liteos_m/issues/I43)
* 完善m核qemu串口驱动支持shell输入 ([c4dc5ab](https://gitee.com/openharmony/kernel_liteos_m/commits/c4dc5ab0f8b5caae55efdbedf59ab07f5006f6c2)), closes [#I46N7](https://gitee.com/openharmony/kernel_liteos_m/issues/I46N7)
* 按任务统计已经alloc的内存大小 ([53117f9](https://gitee.com/openharmony/kernel_liteos_m/commits/53117f9f47a8dd3023e83dc0cc0de224eab9719f)), closes [#I44](https://gitee.com/openharmony/kernel_liteos_m/issues/I44)
* 支持native动态加载组件 ([d753834](https://gitee.com/openharmony/kernel_liteos_m/commits/d75383400efe5d9ca0ae4093e4f2e65fee03024b)), closes [#I418](https://gitee.com/openharmony/kernel_liteos_m/issues/I418)
* 新增LOSCFG_BASE_CORE_TSK_SWITCH_HOOK 宏定义配置 ([39efd6f](https://gitee.com/openharmony/kernel_liteos_m/commits/39efd6fb30ee7dc9159811f5d37dffcdfe81bae0)), closes [#I40Q9](https://gitee.com/openharmony/kernel_liteos_m/issues/I40Q9)
* 新增ROM/RAM分析工具 ([ee3403d](https://gitee.com/openharmony/kernel_liteos_m/commits/ee3403deaf24dc612b51354f31f795fb0b9a49b5))
* 补充fs相关函数用例 ([2a95af5](https://gitee.com/openharmony/kernel_liteos_m/commits/2a95af5bf1b412de27b4518d0abf7c335366d4d7)), closes [#I3UQ4](https://gitee.com/openharmony/kernel_liteos_m/issues/I3UQ4)
* 解决fclose等函数工具链重定义问题 ([b244ad4](https://gitee.com/openharmony/kernel_liteos_m/commits/b244ad4ad0da8d151b69071fdd6db808c91f85a5)), closes [#I3UG6](https://gitee.com/openharmony/kernel_liteos_m/issues/I3UG6)
### BREAKING CHANGES
* 新增4个对外接口声明在los_dynlink.h文件中分别为
(1) LOS_DynlinkInit: 动态加载模块初始化。
(2) LOS_SoLoad: 加载指定路径的共享库。
(3) LOS_FindSym: 根据共享库句柄查找指定符号。
(4) LOS_SoUnload: 卸载共享库。
* 1.新增一系列trace的对外API位于los_trace.h中.
LOS_TRACE_EASY简易插桩
LOS_TRACE标准插桩
LOS_TraceInit配置Trace缓冲区的地址和大小
LOS_TraceStart开启事件记录
LOS_TraceStop停止事件记录
LOS_TraceRecordDump输出Trace缓冲区数据
LOS_TraceRecordGet获取Trace缓冲区的首地址
LOS_TraceReset清除Trace缓冲区中的事件
LOS_TraceEventMaskSet设置事件掩码仅记录某些模块的事件
LOS_TraceHwiFilterHookReg注册过滤特定中断号事件的钩子函数
* 1.原调度中基于tick timer的低功耗扩展和当前的pm模块合并删除原对外接口LOS_SchedSleepInit,
 变为pm模块统一提供的LOS_PmRegistered接口.
2.原来在arch los_timer.h下提供的低功耗模式为枚举LOS_SysSleepEnum其中OS_SYS_NORMAL_SLEEP
和OS_SYS_DEEP_SLEEP不符合对外定义统一修改为LOS_SYS_NORMAL_SLEEP和LOS_SYS_DEEP_SLEEP,
并移至los_pm.h中.
3.VOID HalEnterSleep(LOS_SysSleepEnum sleep) 变更为UINT32 HalEnterSleep(VOID).

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/master/zh-cn/device-dev/quick-start/Readme-CN.md)。开发者需要根据环境搭建文档完成环境搭建。
在搭建各个开发板环境前需要完成OpenHarmony系统基础环境搭建。系统基础环境主要是指OpenHarmony的编译环境和开发环境详细介绍请参考官方站点[开发环境准备](https://gitee.com/openharmony/docs/blob/HEAD/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md)。开发者需要根据环境搭建文档完成环境搭建。
### 获取OpenHarmony源码

View File

@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2023 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,12 +63,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
return msp;
}
STATIC INLINE UINTPTR ArchLRGet(VOID)
{
UINTPTR lr;
__asm("mov %0, lr" : "=r" (lr));
return lr;
}
#define ARCH_LR_GET() \
({ \
UINTPTR lr; \
__asm("mov %0, lr" : "=r" (lr)); \
(lr); \
})
#define ArchLRGet ARCH_LR_GET
#elif defined(__CLANG_ARM) || defined(__GNUC__)
STATIC INLINE UINTPTR ArchSpGet(VOID)
{
@@ -91,12 +92,13 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
return msp;
}
STATIC INLINE UINTPTR ArchLRGet(VOID)
{
UINTPTR lr;
__asm volatile("mov %0, lr" : "=r" (lr));
return lr;
}
#define ARCH_LR_GET() \
({ \
UINTPTR lr; \
__asm volatile("mov %0, lr" : "=r" (lr)); \
(lr); \
})
#define ArchLRGet ARCH_LR_GET
#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-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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,9 +63,6 @@
#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
@@ -75,6 +72,7 @@
#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-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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_common.h"
#include "soc.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-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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_common.h"
#include "soc.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-2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 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_common.h"
#include "soc.h"
.macro PUSH_CALLER_REG
addi sp, sp, -(32 * REGBYTES)
@@ -139,7 +139,8 @@ HalTrapEntry:
sw a0, 0 * REGBYTES(sp)
csrr t0, mtval
sw t0, 1 * REGBYTES(sp)
sw zero, 2 * REGBYTES(sp)
csrr t0, medeleg
sw t0, 2 * REGBYTES(sp)
sw gp, 3 * REGBYTES(sp)
mv a0, sp
csrw mscratch, sp

View File

@@ -170,7 +170,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit()
return LOS_OK;
}
/* The calculation time unit is changed to us to decouple the influence of
/* The calculation time unit is changed to us to decouple the influence of
* system frequency modulation on CPUP
*/
STATIC UINT64 CpupTimeUsGet(VOID)

View File

@@ -60,7 +60,6 @@
#endif /* FS_LOCK_TIMEOUT_SEC */
static UINT8 g_workBuffer[FF_MAX_SS];
static pthread_mutex_t g_fatfsMutex = PTHREAD_MUTEX_INITIALIZER;
static char *g_volPath[FF_VOLUMES] = {FF_VOLUME_STRS};
PARTITION VolToPart[] = {
@@ -70,31 +69,6 @@ PARTITION VolToPart[] = {
{ 0, 0, 4, 0, 0 }
};
static int FsLock(void)
{
int ret = 0;
struct timespec absTimeout = {0};
if (!OsCheckKernelRunning()) {
return ret;
}
ret = clock_gettime(CLOCK_REALTIME, &absTimeout);
if (ret != 0) {
PRINT_ERR("clock gettime err 0x%x!\r\n", errno);
return errno;
}
absTimeout.tv_sec += FS_LOCK_TIMEOUT_SEC;
ret = pthread_mutex_timedlock(&g_fatfsMutex, &absTimeout);
return ret;
}
static void FsUnlock(void)
{
if (!OsCheckKernelRunning()) {
return;
}
(void)pthread_mutex_unlock(&g_fatfsMutex);
}
static int FsChangeDrive(const char *path)
{
INT32 res;
@@ -275,95 +249,69 @@ int FatfsMount(struct MountPoint *mp, unsigned long mountflags,
{
FRESULT res;
FATFS *fs = NULL;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (mountflags & MS_REMOUNT) {
ret = Remount(mp, mountflags);
FsUnlock();
return ret;
return Remount(mp, mountflags);
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = (int)LOS_NOK;
goto ERROUT;
return (int)LOS_NOK;
}
fs = (FATFS *)LOSCFG_FS_MALLOC_HOOK(sizeof(FATFS));
if (fs == NULL) {
errno = ENOMEM;
ret = (int)LOS_NOK;
goto ERROUT;
PutLdPath(ldPath);
return (int)LOS_NOK;
}
(void)memset_s(fs, sizeof(FATFS), 0, sizeof(FATFS));
res = f_mount(fs, ldPath, 1);
if (res != FR_OK) {
LOSCFG_FS_FREE_HOOK(fs);
PutLdPath(ldPath);
errno = FatfsErrno(res);
return (int)LOS_NOK;
}
mp->mData = (void *)fs;
res = f_mount((FATFS *)mp->mData, ldPath, 1);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto ERROUT;
}
PutLdPath(ldPath);
FsUnlock();
return (int)LOS_OK;
ERROUT:
LOSCFG_FS_FREE_HOOK(fs);
mp->mData = NULL;
PutLdPath(ldPath);
FsUnlock();
return ret;
}
int FatfsUmount(struct MountPoint *mp)
{
int ret;
int volId;
FRESULT res;
char *ldPath = NULL;
FATFS *fatfs = (FATFS *)mp->mData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = (int)LOS_NOK;
goto OUT;
}
/* The volume is not mounted */
if (fatfs->fs_type == 0) {
errno = EINVAL;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
volId = GetPartIdByPartName(mp->mDev);
/* umount is not allowed when a file or directory is opened. */
if (f_checkopenlock(volId) != FR_OK) {
errno = EBUSY;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
return (int)LOS_NOK;
}
res = f_mount((FATFS *)NULL, ldPath, 0);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
PutLdPath(ldPath);
return (int)LOS_NOK;
}
if (fatfs->win != NULL) {
@@ -373,19 +321,15 @@ int FatfsUmount(struct MountPoint *mp)
LOSCFG_FS_FREE_HOOK(mp->mData);
mp->mData = NULL;
ret = (int)LOS_OK;
OUT:
PutLdPath(ldPath);
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsUmount2(struct MountPoint *mp, int flag)
{
int ret;
UINT32 flags;
FRESULT res;
char *ldPath = NULL;
FATFS *fatfs = (FATFS *)mp->mData;
flags = MNT_FORCE | MNT_DETACH | MNT_EXPIRE | UMOUNT_NOFOLLOW;
@@ -394,31 +338,23 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
char *ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
ret = (int)LOS_NOK;
goto OUT;
}
/* The volume is not mounted */
if (fatfs->fs_type == 0) {
errno = EINVAL;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ldPath = GetLdPath(mp->mDev);
if (ldPath == NULL) {
errno = EFAULT;
return (int)LOS_NOK;
}
res = f_mount((FATFS *)NULL, ldPath, 0);
if (res != FR_OK) {
PutLdPath(ldPath);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
if (fatfs->win != NULL) {
@@ -428,12 +364,8 @@ int FatfsUmount2(struct MountPoint *mp, int flag)
LOSCFG_FS_FREE_HOOK(mp->mData);
mp->mData = NULL;
ret = (int)LOS_OK;
OUT:
PutLdPath(ldPath);
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsOpen(struct File *file, const char *path, int oflag)
@@ -456,20 +388,12 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
LOSCFG_FS_FREE_HOOK(fp);
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT open ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = (int)LOS_NOK;
LOSCFG_FS_FREE_HOOK(fp);
goto OUT;
return (int)LOS_NOK;
}
res = f_open(fp, path, fmode);
@@ -477,31 +401,20 @@ int FatfsOpen(struct File *file, const char *path, int oflag)
PRINT_ERR("FAT open err 0x%x!\r\n", res);
LOSCFG_FS_FREE_HOOK(fp);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
file->fData = (void *)fp;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsClose(struct File *file)
{
FRESULT res;
FIL *fp = (FIL *)file->fData;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
FsUnlock();
errno = ENOENT;
return (int)LOS_NOK;
}
@@ -509,7 +422,6 @@ int FatfsClose(struct File *file)
res = f_close(fp);
if (res != FR_OK) {
PRINT_ERR("FAT close err 0x%x!\r\n", res);
FsUnlock();
errno = FatfsErrno(res);
return (int)LOS_NOK;
}
@@ -521,7 +433,6 @@ int FatfsClose(struct File *file)
#endif
LOSCFG_FS_FREE_HOOK(file->fData);
file->fData = NULL;
FsUnlock();
return (int)LOS_OK;
}
@@ -531,31 +442,22 @@ ssize_t FatfsRead(struct File *file, char *buf, size_t nbyte)
FRESULT res;
UINT32 lenRead;
FIL *fp = (FIL *)file->fData;
int ret;
if (buf == NULL) {
errno = EFAULT;
return (ssize_t)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (ssize_t)LOS_NOK;
}
if (fp == NULL) {
FsUnlock();
errno = ENOENT;
return (ssize_t)LOS_NOK;
}
res = f_read(fp, buf, nbyte, &lenRead);
if (res != FR_OK) {
FsUnlock();
errno = FatfsErrno(res);
return (ssize_t)LOS_NOK;
}
FsUnlock();
return (ssize_t)lenRead;
}
@@ -566,22 +468,15 @@ ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
UINT32 lenWrite;
static BOOL overFlow = FALSE;
FIL *fp = (FIL *)file->fData;
int ret;
if (buf == NULL) {
errno = EFAULT;
return (ssize_t)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (ssize_t)LOS_NOK;
}
if ((fp ==NULL) || (fp->obj.fs == NULL)) {
if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT;
goto ERROUT;
return (ssize_t)LOS_NOK;
}
res = f_write(fp, buf, nbyte, &lenWrite);
@@ -592,15 +487,10 @@ ssize_t FatfsWrite(struct File *file, const char *buf, size_t nbyte)
if ((res != FR_OK) || (nbyte != lenWrite)) {
errno = FatfsErrno(res);
goto ERROUT;
return (ssize_t)LOS_NOK;
}
FsUnlock();
return (ssize_t)lenWrite;
ERROUT:
FsUnlock();
return (ssize_t)LOS_NOK;
}
off_t FatfsLseek(struct File *file, off_t offset, int whence)
@@ -608,17 +498,10 @@ off_t FatfsLseek(struct File *file, off_t offset, int whence)
FRESULT res;
off_t pos;
FIL *fp = (FIL *)file->fData;
int ret;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (off_t)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT;
goto ERROUT;
return (off_t)LOS_NOK;
}
if (whence == SEEK_SET) {
@@ -629,22 +512,17 @@ off_t FatfsLseek(struct File *file, off_t offset, int whence)
pos = f_size(fp);
} else {
errno = EINVAL;
goto ERROUT;
return (off_t)LOS_NOK;
}
res = f_lseek(fp, offset + pos);
if (res != FR_OK) {
errno = FatfsErrno(res);
goto ERROUT;
return (off_t)LOS_NOK;
}
pos = f_tell(fp);
FsUnlock();
return pos;
ERROUT:
FsUnlock();
return (off_t)LOS_NOK;
}
/* Remove the specified FILE */
@@ -658,39 +536,26 @@ int FatfsUnlink(struct MountPoint *mp, const char *path)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT unlink ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_unlink(path);
if (res != FR_OK) {
PRINT_ERR("FAT unlink err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
@@ -704,26 +569,18 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT stat ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_stat(path, &fileInfo);
if (res != FR_OK) {
PRINT_ERR("FAT stat err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
buf->st_size = fileInfo.fsize;
@@ -740,43 +597,27 @@ int FatfsStat(struct MountPoint *mp, const char *path, struct stat *buf)
buf->st_mode |= S_IFDIR;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
/* Synchronize all changes to Flash */
int FatfsSync(struct File *file)
{
int ret;
FRESULT res;
FIL *fp = (FIL *)file->fData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_sync(fp);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsMkdir(struct MountPoint *mp, const char *path)
@@ -789,38 +630,26 @@ int FatfsMkdir(struct MountPoint *mp, const char *path)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT mkdir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_mkdir(path);
if (res != FR_OK) {
PRINT_ERR("FAT mkdir err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsOpendir(struct Dir *dir, const char *dirName)
@@ -831,47 +660,34 @@ int FatfsOpendir(struct Dir *dir, const char *dirName)
if (dirName == NULL) {
errno = EFAULT;
goto ERROUT;
}
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
if (dp == NULL) {
errno = ENOENT;
goto ERROUT;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
goto ERROUT;
return (int)LOS_NOK;
}
ret = FsChangeDrive(dirName);
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT opendir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
goto ERROUT;
return (int)LOS_NOK;
}
dp = (DIR *)LOSCFG_FS_MALLOC_HOOK(sizeof(DIR));
if (dp == NULL) {
errno = ENOENT;
return (int)LOS_NOK;
}
res = f_opendir(dp, dirName);
if (res != FR_OK) {
PRINT_ERR("FAT opendir err 0x%x!\r\n", res);
LOSCFG_FS_FREE_HOOK(dp);
errno = FatfsErrno(res);
goto ERROUT;
return (int)LOS_NOK;
}
dir->dData = dp;
dir->dOffset = 0;
FsUnlock();
return (int)LOS_OK;
ERROUT:
if (dp != NULL) {
LOSCFG_FS_FREE_HOOK(dp);
}
FsUnlock();
return (int)LOS_NOK;
}
int FatfsReaddir(struct Dir *dir, struct dirent *dent)
@@ -879,7 +695,6 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
FRESULT res;
FILINFO fileInfo = {0};
DIR *dp = NULL;
int ret;
if ((dir == NULL) || (dir->dData == NULL)) {
errno = EBADF;
@@ -887,18 +702,11 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
}
dp = (DIR *)dir->dData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
res = f_readdir(dp, &fileInfo);
/* if res not ok or fname is NULL , return NULL */
if ((res != FR_OK) || (fileInfo.fname[0] == 0x0)) {
PRINT_ERR("FAT readdir err 0x%x!\r\n", res);
errno = FatfsErrno(res);
FsUnlock();
return (int)LOS_NOK;
}
@@ -909,7 +717,6 @@ int FatfsReaddir(struct Dir *dir, struct dirent *dent)
} else {
dent->d_type = DT_REG;
}
FsUnlock();
return (int)LOS_OK;
}
@@ -918,7 +725,6 @@ int FatfsClosedir(struct Dir *dir)
{
FRESULT res;
DIR *dp = NULL;
int ret;
if ((dir == NULL) || (dir->dData == NULL)) {
errno = EBADF;
@@ -926,23 +732,15 @@ int FatfsClosedir(struct Dir *dir)
}
dp = dir->dData;
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
res = f_closedir(dp);
if (res != FR_OK) {
PRINT_ERR("FAT closedir err 0x%x!\r\n", res);
FsUnlock();
errno = FatfsErrno(res);
return (int)LOS_NOK;
}
LOSCFG_FS_FREE_HOOK(dir->dData);
dir->dData = NULL;
FsUnlock();
return (int)LOS_OK;
}
@@ -957,38 +755,26 @@ int FatfsRmdir(struct MountPoint *mp, const char *path)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT rmdir ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_rmdir(path);
if (res != FR_OK) {
PRINT_ERR("FAT rmdir err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
@@ -1001,38 +787,26 @@ int FatfsRename(struct MountPoint *mp, const char *oldName, const char *newName)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if (!mp->mWriteEnable) {
errno = EACCES;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = FsChangeDrive(oldName);
if (ret != (int)LOS_OK) {
PRINT_ERR("FAT f_getfree ChangeDrive err 0x%x!\r\n", ret);
errno = ENOENT;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_rename(oldName, newName);
if (res != FR_OK) {
PRINT_ERR("FAT frename err 0x%x!\r\n", res);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsStatfs(const char *path, struct statfs *buf)
@@ -1047,26 +821,18 @@ int FatfsStatfs(const char *path, struct statfs *buf)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
ret = FsChangeDrive(path);
if (ret != FR_OK) {
PRINT_ERR("FAT f_getfree ChangeDrive err %d.", ret);
errno = FatfsErrno(FR_INVALID_PARAMETER);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_getfree(path, &freeClust, &fs);
if (res != FR_OK) {
PRINT_ERR("FAT f_getfree err 0x%x.", res);
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
buf->f_bfree = freeClust;
buf->f_bavail = freeClust;
@@ -1078,11 +844,7 @@ int FatfsStatfs(const char *path, struct statfs *buf)
buf->f_bsize = FF_MIN_SS * fs->csize;
#endif
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
static int DoTruncate(struct File *file, off_t length, UINT32 count)
@@ -1090,7 +852,6 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
FRESULT res = FR_OK;
DWORD csz;
FIL *fp = (FIL *)file->fData;
int ret = (int)LOS_OK;
csz = (DWORD)(fp->obj.fs)->csize * SS(fp->obj.fs); /* Cluster size */
if (length > csz * count) {
@@ -1098,8 +859,7 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
res = f_expand(fp, 0, (FSIZE_t)(length), FALLOC_FL_KEEP_SIZE);
#else
errno = ENOSYS;
ret = (int)LOS_NOK;
return ret;
return (int)LOS_NOK;
#endif
} else if (length < csz * count) {
res = f_truncate(fp, (FSIZE_t)length);
@@ -1107,14 +867,13 @@ static int DoTruncate(struct File *file, off_t length, UINT32 count)
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
return ret;
return (int)LOS_NOK;
}
fp->obj.objsize = length; /* Set file size to length */
fp->flag |= 0x40; /* Set modified flag */
return ret;
return (int)LOS_OK;
}
int FatfsTruncate(struct File *file, off_t length)
@@ -1123,49 +882,30 @@ int FatfsTruncate(struct File *file, off_t length)
UINT count;
DWORD fclust;
FIL *fp = (FIL *)file->fData;
int ret;
if ((length < 0) || (length > UINT_MAX)) {
errno = EINVAL;
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
return (int)LOS_NOK;
}
if ((fp == NULL) || (fp->obj.fs == NULL)) {
errno = ENOENT;
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
res = f_getclustinfo(fp, &fclust, &count);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = DoTruncate(file, length, count);
if (ret != FR_OK) {
goto OUT;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return DoTruncate(file, length, count);
}
int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
{
int pdrv;
FRESULT res;
int ret;
if ((dev == NULL) || (partTbl == NULL)) {
errno = EFAULT;
@@ -1178,25 +918,13 @@ int FatfsFdisk(const char *dev, int *partTbl, int arrayNum)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
ret = (int)LOS_NOK;
goto OUT;
}
res = f_fdisk(pdrv, (DWORD const *)partTbl, g_workBuffer);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
return (int)LOS_NOK;
}
ret = (int)LOS_OK;
OUT:
FsUnlock();
return ret;
return (int)LOS_OK;
}
int FatfsFormat(const char *partName, void *privData)
@@ -1205,7 +933,6 @@ int FatfsFormat(const char *partName, void *privData)
MKFS_PARM opt = {0};
int option = *(int *)privData;
char *dev = NULL; /* logical driver */
int ret;
if (partName == NULL) {
errno = EFAULT;
@@ -1218,29 +945,17 @@ int FatfsFormat(const char *partName, void *privData)
return (int)LOS_NOK;
}
ret = FsLock();
if (ret != 0) {
errno = ret;
PutLdPath(dev);
return (int)LOS_NOK;
}
opt.fmt = option;
opt.n_sect = 0; /* use default allocation unit size depends on the volume
size. */
res = f_mkfs(dev, &opt, g_workBuffer, FF_MAX_SS);
if (res != FR_OK) {
errno = FatfsErrno(res);
ret = (int)LOS_NOK;
goto OUT;
PutLdPath(dev);
return (int)LOS_NOK;
}
ret = (int)LOS_OK;
OUT:
PutLdPath(dev);
FsUnlock();
return ret;
return (int)LOS_OK;
}
static struct MountOps g_fatfsMnt = {

View File

@@ -41,8 +41,6 @@
#include "securec.h"
#include "los_fs.h"
static pthread_mutex_t g_fsLocalMutex = PTHREAD_MUTEX_INITIALIZER;
static struct PartitionCfg g_partitionCfg;
static struct DeviceDesc *g_lfsDevice = NULL;
@@ -378,7 +376,6 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
if (ret == TRUE) {
pthread_mutex_lock(&g_fsLocalMutex);
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
if (lfsInfo.type == LFS_TYPE_DIR) {
dent->d_type = DT_DIR;
@@ -387,7 +384,6 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
}
dent->d_reclen = lfsInfo.size;
pthread_mutex_unlock(&g_fsLocalMutex);
return LOS_OK;
}
@@ -567,10 +563,7 @@ int LfsClose(struct File *file)
return (int)LOS_NOK;
}
pthread_mutex_lock(&g_fsLocalMutex);
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
pthread_mutex_unlock(&g_fsLocalMutex);
if (ret != 0) {
errno = LittlefsErrno(ret);
ret = (int)LOS_NOK;

View File

@@ -34,3 +34,19 @@ config FS_VFS
help
Answer Y to enable LiteOS support VFS.
if FS_VFS
config FS_LOCK_TIMEOUT
int "Filesystem global lock timeout value in tick. -1 for waiting forever"
default -1
help
The timeout value of getting filesystem lock in tick. -1 for waiting forever
config FS_SUPPORT_MOUNT_TARGET_RECURSIVE
bool "Mount target can be recursive"
default n
depends on FS_VFS
help
Answer Y to enable LiteOS support VFS mount recursively. For example, "/system/bin".
endif

View File

@@ -139,6 +139,17 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data);
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
/*
* @brief Lock the whole filesystem to forbid filesystem access.
*
* @return Return LOS_NOK if error. Return LOS_OK if seccess.
*/
int LOS_FsLock(void);
/*
* @brief Unlock the whole filesystem to allow filesystem access.
*/
void LOS_FsUnlock(void);
#ifdef __cplusplus
#if __cplusplus

View File

@@ -100,20 +100,20 @@ int PollQueryFd(int fd, struct PollTable *table)
UINT32 g_fsMutex;
static UINT32 g_dirNum = 0;
int VfsLock(void)
int LOS_FsLock(void)
{
if (!OsCheckKernelRunning()) {
return LOS_OK;
}
if (LOS_MuxPend(g_fsMutex, LOS_WAIT_FOREVER) != LOS_OK) {
PRINT_ERR("VfsLock failed!");
if (LOS_MuxPend(g_fsMutex, (UINT32)LOSCFG_FS_LOCK_TIMEOUT) != LOS_OK) {
PRINT_ERR("LOS_FsLock failed!");
return (int)LOS_NOK;
}
return LOS_OK;
}
void VfsUnlock(void)
void LOS_FsUnlock(void)
{
if (!OsCheckKernelRunning()) {
return;
@@ -211,6 +211,28 @@ static size_t GetCanonicalPath(const char *cwd, const char *path, char *buf, siz
}
#endif
static int VfsPathCheck(const char *path, bool isFile)
{
size_t len;
if ((path == NULL) || (path[0] == '\0')) {
VFS_ERRNO_SET(EINVAL);
return (int)LOS_NOK;
}
len = strlen(path);
if (len >= PATH_MAX) {
VFS_ERRNO_SET(ENAMETOOLONG);
return (int)LOS_NOK;
}
if (isFile && path[len - 1] == '/') {
VFS_ERRNO_SET(EINVAL);
return (int)LOS_NOK;
}
return LOS_OK;
}
static int VfsOpen(const char *path, int flags)
{
size_t len;
@@ -219,12 +241,11 @@ static int VfsOpen(const char *path, int flags)
const char *pathInMp = NULL;
struct MountPoint *mp = NULL;
if ((path == NULL) || (path[strlen(path) - 1] == '/')) {
VFS_ERRNO_SET(EINVAL);
if (VfsPathCheck(path, TRUE) != LOS_OK) {
return fd;
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return fd;
}
@@ -234,7 +255,7 @@ static int VfsOpen(const char *path, int flags)
(mp->mFs->fsFops == NULL) || (mp->mFs->fsFops->open == NULL)) {
/* path is not in any mountpoint */
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
LOS_FsUnlock();
return fd;
}
@@ -242,14 +263,14 @@ static int VfsOpen(const char *path, int flags)
(flags & (O_CREAT | O_WRONLY | O_RDWR))) {
/* can't create file in read only mp */
VFS_ERRNO_SET(EACCES);
VfsUnlock();
LOS_FsUnlock();
return fd;
}
file = VfsFileGet();
if (file == NULL) {
VFS_ERRNO_SET(ENFILE);
VfsUnlock();
LOS_FsUnlock();
return fd;
}
@@ -258,7 +279,7 @@ static int VfsOpen(const char *path, int flags)
if (file->fullPath == NULL) {
VFS_ERRNO_SET(ENOMEM);
VfsFilePut(file);
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}
(void)strcpy_s((char *)file->fullPath, len, path);
@@ -279,7 +300,7 @@ static int VfsOpen(const char *path, int flags)
VfsFilePut(file);
}
VfsUnlock();
LOS_FsUnlock();
return fd;
}
@@ -294,7 +315,7 @@ static struct File *VfsAttachFile(int fd, UINT32 status)
return NULL;
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EFAULT);
return NULL;
}
@@ -302,13 +323,13 @@ static struct File *VfsAttachFile(int fd, UINT32 status)
file = FdToFile(fd);
if ((file == NULL) || (file->fMp == NULL)) {
VFS_ERRNO_SET(EBADF);
VfsUnlock();
LOS_FsUnlock();
return NULL;
}
if (file->fStatus != FILE_STATUS_READY) {
VFS_ERRNO_SET(EBADF);
VfsUnlock();
LOS_FsUnlock();
return NULL;
}
@@ -329,7 +350,7 @@ static struct File *VfsAttachFileWithStatus(int fd, int status)
static void VfsDetachFile(const struct File *file)
{
(void)file;
VfsUnlock();
LOS_FsUnlock();
}
static int VfsClose(int fd)
@@ -539,7 +560,7 @@ int open(const char *path, int flags, ...)
#endif
int ret = VfsOpen(path, flags);
return MapToPosixRet(ret);
return MapToPosixRet(ret);
}
FUNC_ALIAS(open, _open, (const char *path, int flags, ...), int);
@@ -608,7 +629,7 @@ ssize_t read(int fd, void *buff, size_t bytes)
ret = VfsRead(fd, buff, bytes);
}
return MapToPosixRet(ret);
return MapToPosixRet(ret);
}
FUNC_ALIAS(read, _read, (int fd, void *buff, size_t bytes), ssize_t);
@@ -669,12 +690,16 @@ int stat(const char *path, struct stat *stat)
const char *pathInMp = NULL;
int ret = (int)LOS_NOK;
if ((path == NULL) || (stat == NULL)) {
if (VfsPathCheck(path, FALSE) != LOS_OK) {
return MapToPosixRet(ret);
}
if (stat == NULL) {
VFS_ERRNO_SET(EINVAL);
return MapToPosixRet(ret);
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet(ret);
}
@@ -682,7 +707,7 @@ int stat(const char *path, struct stat *stat)
mp = VfsMpFind(path, &pathInMp);
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
@@ -692,7 +717,7 @@ int stat(const char *path, struct stat *stat)
VFS_ERRNO_SET(ENOTSUP);
}
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
FUNC_ALIAS(stat, _stat, (const char *path, struct stat *stat), int);
@@ -703,12 +728,16 @@ int statfs(const char *path, struct statfs *buf)
const char *pathInMp = NULL;
int ret = (int)LOS_NOK;
if ((path == NULL) || (buf == NULL)) {
if (VfsPathCheck(path, FALSE) != LOS_OK) {
return MapToPosixRet(ret);
}
if (buf == NULL) {
VFS_ERRNO_SET(EINVAL);
return MapToPosixRet(ret);
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet(ret);
}
@@ -716,17 +745,17 @@ int statfs(const char *path, struct statfs *buf)
mp = VfsMpFind(path, &pathInMp);
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
if (mp->mFs->fsFops->stat != NULL) {
if (mp->mFs->fsMops->statfs != NULL) {
ret = mp->mFs->fsMops->statfs(pathInMp, buf);
} else {
VFS_ERRNO_SET(ENOTSUP);
}
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
@@ -736,12 +765,11 @@ int unlink(const char *path)
const char *pathInMp = NULL;
int ret = (int)LOS_NOK;
if (path == NULL) {
VFS_ERRNO_SET(EINVAL);
if (VfsPathCheck(path, FALSE) != LOS_OK) {
return MapToPosixRet(ret);
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet(ret);
}
@@ -750,13 +778,13 @@ int unlink(const char *path)
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0') ||
(mp->mFs->fsFops->unlink == NULL)) {
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
ret = mp->mFs->fsFops->unlink(mp, pathInMp);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
FUNC_ALIAS(unlink, _unlink, (const char *path), int);
@@ -769,12 +797,14 @@ int rename(const char *oldpath, const char *newpath)
const char *pathInMpNew = NULL;
int ret = (int)LOS_NOK;
if ((oldpath == NULL) || (newpath == NULL)) {
VFS_ERRNO_SET(EINVAL);
if (VfsPathCheck(oldpath, FALSE) != LOS_OK) {
return MapToPosixRet(ret);
}
if (VfsPathCheck(newpath, FALSE) != LOS_OK) {
return MapToPosixRet(ret);
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet(ret);
}
@@ -783,27 +813,27 @@ int rename(const char *oldpath, const char *newpath)
if (pathInMpOld == NULL) {
VFS_ERRNO_SET(EINVAL);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
if ((mpOld == NULL) || (*pathInMpOld == '\0') ||
(mpOld->mFs->fsFops->unlink == NULL)) {
VFS_ERRNO_SET(EINVAL);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
mpNew = VfsMpFind(newpath, &pathInMpNew);
if ((mpNew == NULL) || (pathInMpNew == NULL) || (*pathInMpNew == '\0') || (mpNew->mFs->fsFops->unlink == NULL)) {
VFS_ERRNO_SET(EINVAL);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
if (mpOld != mpNew) {
VFS_ERRNO_SET(EXDEV);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
@@ -813,7 +843,7 @@ int rename(const char *oldpath, const char *newpath)
VFS_ERRNO_SET(ENOTSUP);
}
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
@@ -850,8 +880,7 @@ DIR *opendir(const char *path)
struct Dir *dir = NULL;
UINT32 ret;
if (path == NULL) {
VFS_ERRNO_SET(EINVAL);
if (VfsPathCheck(path, FALSE) != LOS_OK) {
return NULL;
}
@@ -861,7 +890,7 @@ DIR *opendir(const char *path)
return NULL;
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
@@ -869,7 +898,7 @@ DIR *opendir(const char *path)
if (g_dirNum >= LOSCFG_MAX_OPEN_DIRS) {
VFS_ERRNO_SET(ENFILE);
VfsUnlock();
LOS_FsUnlock();
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
}
@@ -877,14 +906,14 @@ DIR *opendir(const char *path)
mp = VfsMpFind(path, &pathInMp);
if ((mp == NULL) || (pathInMp == NULL)) {
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
LOS_FsUnlock();
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
}
if (mp->mFs->fsFops->opendir == NULL) {
VFS_ERRNO_SET(ENOTSUP);
VfsUnlock();
LOS_FsUnlock();
LOSCFG_FS_FREE_HOOK(dir);
return NULL;
}
@@ -901,7 +930,7 @@ DIR *opendir(const char *path)
dir = NULL;
}
VfsUnlock();
LOS_FsUnlock();
return (DIR *)dir;
}
@@ -915,7 +944,7 @@ struct dirent *readdir(DIR *dir)
return NULL;
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return NULL;
}
@@ -929,7 +958,7 @@ struct dirent *readdir(DIR *dir)
VFS_ERRNO_SET(ENOTSUP);
}
VfsUnlock();
LOS_FsUnlock();
return ret;
}
@@ -947,7 +976,7 @@ int closedir(DIR *dir)
mp = d->dMp;
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet(ret);
}
@@ -966,7 +995,7 @@ int closedir(DIR *dir)
VFS_ERRNO_SET(EBADF);
}
VfsUnlock();
LOS_FsUnlock();
LOSCFG_FS_FREE_HOOK(d);
d = NULL;
return MapToPosixRet(ret);
@@ -979,12 +1008,11 @@ int mkdir(const char *path, mode_t mode)
int ret = (int)LOS_NOK;
(void)mode;
if (path == NULL) {
VFS_ERRNO_SET(EINVAL);
if (VfsPathCheck(path, FALSE) != LOS_OK) {
return MapToPosixRet(ret);
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet(ret);
}
@@ -992,7 +1020,7 @@ int mkdir(const char *path, mode_t mode)
mp = VfsMpFind(path, &pathInMp);
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0')) {
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
@@ -1002,7 +1030,7 @@ int mkdir(const char *path, mode_t mode)
VFS_ERRNO_SET(ENOTSUP);
}
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
@@ -1017,7 +1045,7 @@ int rmdir(const char *path)
return MapToPosixRet(ret);
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet(ret);
}
@@ -1026,13 +1054,13 @@ int rmdir(const char *path)
if ((mp == NULL) || (pathInMp == NULL) || (*pathInMp == '\0') ||
(mp->mFs->fsFops->rmdir == NULL)) {
VFS_ERRNO_SET(ENOENT);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
ret = mp->mFs->fsFops->rmdir(mp, pathInMp);
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet(ret);
}
@@ -1064,7 +1092,7 @@ int fcntl(int fd, int cmd, ...)
va_start(ap, cmd);
if (fd < CONFIG_NFILE_DESCRIPTORS) {
filep = VfsAttachFileReady(fd);
ret = VfsVfcntl(filep, cmd, ap);
ret = VfsVfcntl(filep, cmd, ap);
VfsDetachFile(filep);
} else {
#ifndef LOSCFG_NET_LWIP_SACK
@@ -1312,31 +1340,31 @@ ssize_t pread(int fd, void *buff, size_t bytes, off_t off)
return 0;
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet((int)ret);
}
savepos = lseek(fd, 0, SEEK_CUR);
if (savepos == (off_t)-1) {
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)ret);
}
pos = lseek(fd, off, SEEK_SET);
if (pos == (off_t)-1) {
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)ret);
}
ret = read(fd, buff, bytes);
pos = lseek(fd, savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) {
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)LOS_NOK);
}
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)ret);
}
@@ -1359,31 +1387,31 @@ ssize_t pwrite(int fd, const void *buff, size_t bytes, off_t off)
return 0;
}
if (VfsLock() != LOS_OK) {
if (LOS_FsLock() != LOS_OK) {
VFS_ERRNO_SET(EAGAIN);
return MapToPosixRet((int)ret);
}
savepos = lseek(fd, 0, SEEK_CUR);
if (savepos == (off_t)-1) {
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)ret);
}
pos = lseek(fd, off, SEEK_SET);
if (pos == (off_t)-1) {
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)ret);
}
ret = write(fd, buff, bytes);
pos = lseek(fd, savepos, SEEK_SET);
if ((pos == (off_t)-1) && (ret >= 0)) {
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)LOS_NOK);
}
VfsUnlock();
LOS_FsUnlock();
return MapToPosixRet((int)ret);
}

View File

@@ -41,17 +41,17 @@ struct FsMap *VfsFsMapGet(const char *fsType)
{
struct FsMap *curr = g_fsMap;
(void)VfsLock();
(void)LOS_FsLock();
while (curr != NULL) {
if ((curr->fsType != NULL) && (fsType != NULL) &&
(strcmp(curr->fsType, fsType) == 0)) {
(void)VfsUnlock();
LOS_FsUnlock();
return curr;
}
curr = curr->next;
}
VfsUnlock();
LOS_FsUnlock();
return NULL;
}
@@ -86,11 +86,11 @@ int OsFsRegister(const char *fsType, const struct MountOps *fsMops,
newfs->fsMgt = fsMgt;
newfs->fsRefs = 0;
(void)VfsLock();
(void)LOS_FsLock();
newfs->next = g_fsMap;
g_fsMap = newfs;
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
}

View File

@@ -33,6 +33,7 @@
#include "vfs_config.h"
#include "stdlib.h"
#include "string.h"
#include "limits.h"
#include "errno.h"
#include "securec.h"
#include "vfs_operations.h"
@@ -62,14 +63,13 @@ static void MpDeleteFromList(struct MountPoint *mp)
}
}
#if (LOSCFG_FS_SUPPORT_MOUNT_TARGET_RECURSIVE == 1)
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
{
struct MountPoint *mp = g_mountPoints;
struct MountPoint *bestMp = NULL;
int bestMatches = 0;
if (path == NULL) {
return NULL;
}
if (pathInMp != NULL) {
*pathInMp = NULL;
}
@@ -121,29 +121,85 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
next:
mp = mp->mNext;
}
return bestMp;
}
#else
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
{
struct MountPoint *mp = g_mountPoints;
const char *iPath = path;
const char *mPath = NULL;
const char *target = NULL;
STATIC struct MountPoint *VfsMountPointInit(const char *target, const char *fsType, unsigned long mountflags)
if (pathInMp != NULL) {
*pathInMp = NULL;
}
while (*iPath == '/') {
++iPath;
}
while ((mp != NULL) && (mp->mPath != NULL)) {
mPath = mp->mPath;
target = iPath;
while (*mPath == '/') {
++mPath;
}
while ((*mPath != '\0') && (*mPath != '/') &&
(*target != '\0') && (*target != '/')) {
if (*mPath != *target) {
break;
}
++mPath;
++target;
}
if (((*mPath == '\0') || (*mPath == '/')) &&
((*target == '\0') || (*target == '/'))) {
if (pathInMp != NULL) {
*pathInMp = path;
}
return mp;
}
mp = mp->mNext;
}
return NULL;
}
#endif
STATIC struct MountPoint *VfsMountPointInit(const char *source, const char *target,
const char *fsType, unsigned long mountflags)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
struct FsMap *mFs = NULL;
size_t ssize = 0;
size_t tsize;
/* find mp by target, to see if it was mounted */
mp = VfsMpFind(target, &pathInMp);
if (mp != NULL && pathInMp != NULL) {
errno = EINVAL;
return NULL;
}
/* Find fsMap coresponding to the fsType */
mFs = VfsFsMapGet(fsType);
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
errno = ENODEV;
return NULL;
}
mp = (struct MountPoint *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct MountPoint));
if (source != NULL) {
ssize = strlen(source) + 1;
}
tsize = strlen(target) + 1;
mp = (struct MountPoint *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct MountPoint) + ssize + tsize);
if (mp == NULL) {
errno = ENOMEM;
return NULL;
}
@@ -152,7 +208,20 @@ STATIC struct MountPoint *VfsMountPointInit(const char *target, const char *fsTy
mp->mRefs = 0;
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
mp->mFs->fsRefs++;
mp->mNext = g_mountPoints;
if (source != NULL && strcpy_s((char *)mp + sizeof(struct MountPoint), ssize, source) != EOK) {
LOSCFG_FS_FREE_HOOK(mp);
errno = ENOMEM;
return NULL;
}
if (strcpy_s((char *)mp + sizeof(struct MountPoint) + ssize, tsize, target) != EOK) {
LOSCFG_FS_FREE_HOOK(mp);
errno = ENOMEM;
return NULL;
}
mp->mDev = source ? (char *)mp + sizeof(struct MountPoint) : NULL;
mp->mPath = (char *)mp + sizeof(struct MountPoint) + ssize;
return mp;
}
@@ -178,51 +247,47 @@ STATIC int VfsRemount(const char *source, const char *target,
return mp->mFs->fsMops->mount(mp, mountflags, data);
}
STATIC int VfsMountPathCheck(const char *target)
{
/* target must begin with '/', for example /system, /data, etc. */
if ((target == NULL) || (target[0] != '/')) {
errno = EINVAL;
return (int)LOS_NOK;
}
if (strlen(target) >= PATH_MAX) {
errno = ENAMETOOLONG;
return (int)LOS_NOK;
}
return LOS_OK;
}
int mount(const char *source, const char *target,
const char *fsType, unsigned long mountflags,
const void *data)
{
size_t len;
int ret;
struct MountPoint *mp = NULL;
/* target must begin with '/', for example /system, /data, etc. */
if ((target == NULL) || (target[0] != '/')) {
if (VfsMountPathCheck(target) != LOS_OK) {
return (int)LOS_NOK;
}
(void)VfsLock();
(void)LOS_FsLock();
if (mountflags & MS_REMOUNT) {
ret = VfsRemount(source, target, fsType, mountflags, data);
VfsUnlock();
LOS_FsUnlock();
return ret;
}
mp = VfsMountPointInit(target, fsType, mountflags);
mp = VfsMountPointInit(source, target, fsType, mountflags);
if (mp == NULL) {
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}
if (source != NULL) {
len = strlen(source) + 1;
mp->mDev = LOSCFG_FS_MALLOC_HOOK(len);
if (mp->mDev == NULL) {
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
return (int)LOS_NOK;
}
(void)strcpy_s((char *)mp->mDev, len, source);
}
len = strlen(target) + 1;
mp->mPath = LOSCFG_FS_MALLOC_HOOK(len);
if (mp->mPath == NULL) {
goto errout;
}
(void)strcpy_s((char *)mp->mPath, len, target);
ret = mp->mFs->fsMops->mount(mp, mountflags, data);
if (ret != 0) {
/* errno is set */
@@ -230,30 +295,28 @@ int mount(const char *source, const char *target,
goto errout;
}
mp->mNext = g_mountPoints;
g_mountPoints = mp;
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
errout:
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}
int umount(const char *target)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = (int)LOS_NOK;
(void)VfsLock();
if (target == NULL) {
(void)LOS_FsLock();
if (VfsMountPathCheck(target) != LOS_OK) {
goto errout;
}
mp = VfsMpFind(target, &pathInMp);
mp = VfsMpFind(target, NULL);
if ((mp == NULL) || (mp->mRefs != 0)) {
goto errout;
}
@@ -272,16 +335,14 @@ int umount(const char *target)
/* delete mp from mount list */
MpDeleteFromList(mp);
mp->mFs->fsRefs--;
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}
@@ -303,15 +364,14 @@ static void CloseFdsInMp(const struct MountPoint *mp)
int umount2(const char *target, int flag)
{
struct MountPoint *mp = NULL;
const char *pathInMp = NULL;
int ret = (int)LOS_NOK;
(void)VfsLock();
if (target == NULL) {
(void)LOS_FsLock();
if (VfsMountPathCheck(target) != LOS_OK) {
goto errout;
}
mp = VfsMpFind(target, &pathInMp);
mp = VfsMpFind(target, NULL);
if ((mp == NULL) || (mp->mRefs != 0) ||
(mp->mFs == NULL) || (mp->mFs->fsMops == NULL) ||
(mp->mFs->fsMops->umount2 == NULL)) {
@@ -332,15 +392,13 @@ int umount2(const char *target, int flag)
/* delete mp from mount list */
MpDeleteFromList(mp);
mp->mFs->fsRefs--;
LOSCFG_FS_FREE_HOOK((void *)mp->mPath);
LOSCFG_FS_FREE_HOOK((void *)mp->mDev);
LOSCFG_FS_FREE_HOOK(mp);
VfsUnlock();
LOS_FsUnlock();
return LOS_OK;
errout:
PRINT_ERR("umount2 failed, target %s.\n", target);
VfsUnlock();
LOS_FsUnlock();
return (int)LOS_NOK;
}

View File

@@ -52,8 +52,6 @@ extern "C" {
extern UINT32 g_fsMutex;
int OsVfsInit(void);
int VfsLock(void);
void VfsUnlock(void);
#ifdef __cplusplus
#if __cplusplus

View File

@@ -125,7 +125,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
int squash_pos = ipv6_blocks;
int i;
const unsigned char *sc = (const unsigned char *)cp;
const char *ss = cp-1;
const unsigned char *ss = (const unsigned char *)(cp - 1);
for (; ; sc++) {
if (current_block_index >= ipv6_blocks) {
@@ -142,7 +142,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
break;
} else if (*sc == ':') {
if (sc - ss == 1) {
if (sc != cp || sc[1] != ':') {
if (sc != (const unsigned char *)cp || sc[1] != ':') {
return 0; // address begins with a single ':' or contains ":::"
} // else address begins with one valid "::"
} else {
@@ -163,7 +163,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
#if LWIP_IPV4
} else if (*sc == '.' && current_block_index < ipv6_blocks - 1) {
ip4_addr_t ip4;
int ret = ip4addr_aton(ss+1, &ip4);
int ret = ip4addr_aton((const char *)(ss + 1), &ip4);
if (!ret) {
return 0;
}

View File

@@ -373,11 +373,9 @@ 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) {
perror("Ping: sending ICMP echo request failed\n");

View File

@@ -101,27 +101,21 @@ STATIC VOID OsPmTickTimerStart(LosPmCB *pm)
}
#if (LOSCFG_BASE_CORE_TICK_WTIMER == 0)
if (tickTimer->timerStop != NULL) {
if (pm->enterSleepTime != 0) {
/* Restore the main CPU frequency */
sleepTime = tickTimer->timerCycleGet();
tickTimer->timerStop();
if ((tickTimer->timerStop != NULL) && (pm->enterSleepTime != 0)) {
/* Restore the main CPU frequency */
sleepTime = tickTimer->timerCycleGet();
tickTimer->timerStop();
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, g_sysClock);
currTime = pm->enterSleepTime + realSleepTime;
pm->enterSleepTime = 0;
realSleepTime = OS_SYS_CYCLE_TO_NS(sleepTime, tickTimer->freq);
realSleepTime = OS_SYS_NS_TO_CYCLE(realSleepTime, g_sysClock);
currTime = pm->enterSleepTime + realSleepTime;
pm->enterSleepTime = 0;
OsTickTimerBaseReset(currTime);
OsSchedResetSchedResponseTime(0);
/* Restart the system tick timer */
tickTimer->tickUnlock();
}
return;
OsTickTimerBaseReset(currTime);
OsSchedResetSchedResponseTime(0);
}
#endif
/* Restore the system tick timer */
tickTimer->tickUnlock();
return;
}
@@ -148,21 +142,14 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
sleepCycle = OS_SYS_CYCLE_TO_NS(realSleepTime, g_sysClock);
sleepCycle = OS_SYS_NS_TO_CYCLE(sleepCycle, tickTimer->freq);
if (sleepCycle == 0) {
pm->sysMode = LOS_SYS_NORMAL_SLEEP;
return FALSE;
}
/* The main CPU reduces the frequency */
pm->enterSleepTime = LOS_SysCycleGet();
/* Turn off the system tick timer and clear the count value to zero */
tickTimer->tickLock();
tickTimer->timerStart(sleepCycle);
return TRUE;
}
#endif
/* Pause the system tick timer */
tickTimer->tickLock();
return TRUE;
}
@@ -180,7 +167,7 @@ STATIC VOID OsPmCpuResume(LosPmCB *pm)
STATIC VOID OsPmCpuSuspend(LosPmCB *pm)
{
/* cpu enter low-power mode */
/* cpu enter low power mode */
if (pm->sysMode == LOS_SYS_NORMAL_SLEEP) {
pm->sysctrl->normalSuspend();

View File

@@ -39,7 +39,7 @@
/**
* @ingroup los_pm
* Pm error code: Invalid low-power mode.
* Pm error code: Invalid low power mode.
*
* Value: 0x02002001
*
@@ -141,33 +141,21 @@ typedef enum {
} LOS_PmNodeType;
typedef struct {
UINT32 (*suspend)(UINT32 mode); /* The device enters low-power consumption, Unlocked task scheduling. */
VOID (*resume)(UINT32 mode); /* The device exits from low-power consumption, Unlocked task scheduling. */
UINT32 (*suspend)(UINT32 mode); /* The device enters low power consumption, Unlocked task scheduling. */
VOID (*resume)(UINT32 mode); /* The device exits from low power consumption, Unlocked task scheduling. */
} LosPmDevice;
typedef struct {
/* Low-power timer related implementation functions.
* The function is not NULL, the low-power timer is enabled.
*/
UINT32 freq; /* The frequency of the low-power timer */
VOID (*timerStart)(UINT64); /* Start the low-power timer and set the response period */
VOID (*timerStop)(VOID); /* Turn off the low-power timer */
UINT64 (*timerCycleGet)(VOID); /* Gets the time the system sleeps */
/* When the low-power timer is enabled, the function of tickLock is to turn off the system tick timer and
* clear the timer's count value to zero.
* When the low-power timer is disabled, the function of tickLock is to pause the system timer.
*/
VOID (*tickLock)(VOID);
/* When the low-power timer is enabled, the function of tickUnlock is to restart the system tick timer.
* When the low-power timer is disabled, the function of tickUnlock is to restore the system tick timer.
*/
VOID (*tickUnlock)(VOID);
UINT32 freq; /* The frequency of the low power timer */
VOID (*timerStart)(UINT64); /* Start the low power timer */
VOID (*timerStop)(VOID); /* Stop the low power timer */
UINT64 (*timerCycleGet)(VOID); /* Gets the running time of the low power timer in unit cycle */
VOID (*tickLock)(VOID); /* Pause the system tick timer */
VOID (*tickUnlock)(VOID); /* Restore the system tick timer */
} LosPmTickTimer;
typedef struct {
/* Preparations before the CPU enters low-power consumption.
/* Preparations before the CPU enters low power consumption.
* All modes except normal mode are invoked.
* Unlocked task scheduling.
*/
@@ -215,10 +203,10 @@ typedef struct {
/**
* @ingroup los_pm
* @brief Initialize system low-power frame.
* @brief Initialize system low power frame.
*
* @par Description:
* This API is used to initialize the system low-power frame.
* This API is used to initialize the system low power frame.
*
* @attention None.
*
@@ -233,10 +221,10 @@ UINT32 OsPmInit(VOID);
/**
* @ingroup los_pm
* @brief Whether the low-power consumption condition is met.
* @brief Whether the low power consumption condition is met.
*
* @par Description:
* This API is used to check whether low-power consumption is met.
* This API is used to check whether low power consumption is met.
*
* @attention None.
*
@@ -314,10 +302,10 @@ VOID LOS_PmWakeSet(VOID);
/**
* @ingroup los_pm
* @brief Get the low-power mode of the current system.
* @brief Get the low power mode of the current system.
*
* @par Description:
* This API is used to get the low-power mode of the current system.
* This API is used to get the low power mode of the current system.
*
* @attention None.
*
@@ -332,14 +320,14 @@ LOS_SysSleepEnum LOS_PmModeGet(VOID);
/**
* @ingroup los_pm
* @brief Set low-power mode.
* @brief Set low power mode.
*
* @par Description:
* This API is used to set low-power mode.
* This API is used to set low power mode.
*
* @attention None.
*
* @param mode [IN] low-power mode.
* @param mode [IN] low power mode.
*
* @retval error code, LOS_OK means success.
* @par Dependency:

View File

@@ -181,6 +181,7 @@ VOID OsLs(const CHAR *pathname)
d = opendir(path);
if (d == NULL) {
PRINT_ERR("No such directory = %s\n", path);
free(path);
} else {
PRINTK("Directory %s:\n", path);
do {
@@ -625,24 +626,6 @@ 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)
@@ -654,7 +637,7 @@ STATIC INT32 OsWildcardDeleteFileOrDir(const CHAR *fullpath, wildcard_type mark)
ret = OsShellCmdDoRmdir(fullpath);
break;
case RM_FILE:
ret = OsRmFileOnly(fullpath);
ret = unlink(fullpath);
break;
case RM_DIR:
ret = rmdir(fullpath);
@@ -667,6 +650,8 @@ STATIC INT32 OsWildcardDeleteFileOrDir(const CHAR *fullpath, wildcard_type mark)
perror("rm/rmdir error!");
return ret;
}
PRINTK("%s match successful!delete!\n", fullpath);
return 0;
}
@@ -744,10 +729,6 @@ 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;
@@ -930,7 +911,7 @@ INT32 OsShellCmdRm(INT32 argc, const CHAR **argv)
if (OsIsContainersWildcard(fullpath)) {
ret = OsWildcardExtractDirectory(fullpath, NULL, RM_FILE);
} else {
ret = OsRmFileOnly(fullpath);
ret = unlink(fullpath);
}
}
if (ret == -1) {

View File

@@ -235,9 +235,7 @@ 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: 101 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

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

View File

@@ -28,10 +28,11 @@
if LIBC_ICCARM
config LIBC_ICCARM_MALLOC
bool "Enable POSIX malloc/free API support"
config LIBC_ICCARM_FS
bool "Enable POSIX file system API support"
default y
depends on FS_VFS
help
This enables POSIX malloc/free related APIs.
This enables POSIX style file system related APIs.
endif # LIBC_ICCARM

View File

@@ -29,10 +29,11 @@
if LIBC_NEWLIB
config LIBC_NEWLIB_MALLOC
bool "Enable POSIX malloc/free API support"
config LIBC_NEWLIB_FS
bool "Enable POSIX file system API support"
default y
depends on FS_VFS
help
This enables POSIX malloc/free related APIs.
This enables POSIX style file system related APIs.
endif # LIBC_NEWLIB

View File

@@ -34,7 +34,6 @@
#include "los_memory.h"
#include <malloc.h>
#ifdef LOSCFG_LIBC_NEWLIB_MALLOC
void *zalloc(size_t size)
{
void *ptr = NULL;
@@ -112,4 +111,3 @@ void *__wrap__calloc_r(struct _reent *reent, size_t nitems, size_t size)
}
return ptr;
}
#endif

View File

@@ -35,6 +35,7 @@ kernel_module(module_name) {
sources = [
"src/errno.c",
"src/libc.c",
"src/map_error.c",
]
configs += [ "$LITEOSTOPDIR:warn_config" ]

100
kal/posix/src/map_error.c Normal file
View File

@@ -0,0 +1,100 @@
/*
* Copyright (c) 2023-2023 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 "los_mux.h"
#include "los_queue.h"
#include "los_sem.h"
#include "los_task.h"
#include <errno.h>
INT32 map_errno(UINT32 err)
{
if (err == LOS_OK) {
return 0;
}
switch (err) {
case LOS_ERRNO_QUEUE_INVALID:
case LOS_ERRNO_QUEUE_WRITE_PTR_NULL:
case LOS_ERRNO_QUEUE_WRITESIZE_ISZERO:
case LOS_ERRNO_QUEUE_SIZE_TOO_BIG:
case LOS_ERRNO_QUEUE_CREAT_PTR_NULL:
case LOS_ERRNO_QUEUE_PARA_ISZERO:
case LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG:
case LOS_ERRNO_TSK_ID_INVALID:
case LOS_ERRNO_TSK_PTR_NULL:
case LOS_ERRNO_TSK_NAME_EMPTY:
case LOS_ERRNO_TSK_ENTRY_NULL:
case LOS_ERRNO_TSK_PRIOR_ERROR:
case LOS_ERRNO_TSK_STKSZ_TOO_LARGE:
case LOS_ERRNO_TSK_STKSZ_TOO_SMALL:
case LOS_ERRNO_TSK_NOT_CREATED:
case OS_ERROR:
case LOS_ERRNO_SEM_INVALID:
case LOS_ERRNO_SEM_UNAVAILABLE:
errno = EINVAL;
break;
case LOS_ERRNO_QUEUE_ISFULL:
case LOS_ERRNO_QUEUE_ISEMPTY:
errno = EAGAIN;
break;
case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY:
case LOS_ERRNO_TSK_TCB_UNAVAILABLE:
case LOS_ERRNO_SEM_ALL_BUSY:
errno = ENOSPC;
break;
case LOS_ERRNO_QUEUE_TIMEOUT:
case LOS_ERRNO_SEM_TIMEOUT:
errno = ETIMEDOUT;
break;
case LOS_ERRNO_QUEUE_CB_UNAVAILABLE:
errno = ENFILE;
break;
case LOS_ERRNO_QUEUE_READ_IN_INTERRUPT:
case LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT:
case LOS_ERRNO_SEM_PEND_INTERR:
errno = EINTR;
break;
case LOS_ERRNO_TSK_NO_MEMORY:
case LOS_ERRNO_SEM_OVERFLOW:
errno = ENOMEM;
break;
case LOS_ERRNO_SEM_PENDED:
errno = EBUSY;
break;
case LOS_ERRNO_SEM_PEND_IN_LOCK:
errno = EPERM;
break;
default:
errno = EINVAL;
break;
}
return errno;
}

View File

@@ -1,19 +1,19 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2023-2023 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.
* 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.
* 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.
* 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,
@@ -27,27 +27,22 @@
* 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);
#ifndef _POSIX_MAP_ERROR_H
#define _POSIX_MAP_ERROR_H
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif /* __cplusplus */
#endif /* __cplusplus */
return LOS_OK;
INT32 map_errno(UINT32 err);
#ifdef __cplusplus
#if __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */
/**
* @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);
}
#endif

View File

@@ -694,7 +694,7 @@ UINT32 OsPipeInit(VOID)
ret = LOS_MuxCreate(&g_devFdMutex);
if (ret != LOS_OK) {
(VOID)LOS_MuxDelete(g_devListMutex);
LOS_MuxDelete(g_devListMutex);
return ret;
}

View File

@@ -40,6 +40,7 @@
#include "los_config.h"
#include "los_task.h"
#include "los_debug.h"
#include "map_error.h"
#define PTHREAD_DEFAULT_NAME "pthread"
#define PTHREAD_DEFAULT_NAME_LEN 8
@@ -207,9 +208,10 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
return ret;
}
if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) {
ret = LOS_TaskCreateOnly(&taskID, &taskInitParam);
if (ret != LOS_OK) {
free((VOID *)(UINTPTR)taskInitParam.uwArg);
return EINVAL;
return map_errno(ret);
}
PthreadData *pthreadData = (PthreadData *)taskInitParam.uwArg;
@@ -221,10 +223,10 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
LOS_ListAdd(&g_pthreadListHead, &pthreadData->threadList);
LOS_IntRestore(intSave);
(void)LOS_TaskResume(taskID);
*thread = (pthread_t)taskID;
(void)LOS_TaskResume(taskID);
return 0;
}

View File

@@ -664,7 +664,7 @@ static time_t ConvertUtc2Secs(struct tm *tm)
seconds += (tm->tm_mday - 1) * SECS_PER_DAY;
seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec;
seconds -= tm->__tm_gmtoff; // sub time zone to get UTC time
seconds += g_timezone;
return seconds;
}
@@ -690,7 +690,7 @@ time_t mktime(struct tm *tmptr)
}
timeInSeconds = ConvertUtc2Secs(tmptr);
/* normalize tm_wday and tm_yday */
ConvertSecs2Utc(timeInSeconds, tmptr->__tm_gmtoff, tmptr);
ConvertSecs2Utc(timeInSeconds, -g_timezone, tmptr);
return timeInSeconds;
}

View File

@@ -114,6 +114,7 @@ LITE_OS_SEC_TEXT_INIT VOID LOS_Panic(const CHAR *fmt, ...)
va_start(ap, fmt);
PRINT_ERR(fmt, ap);
va_end(ap);
OsDoExcHook(EXC_PANIC);
#if (LOSCFG_BACKTRACE_TYPE != 0)
LOS_BackTrace();
#endif

View File

@@ -451,10 +451,6 @@ 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);
}
@@ -489,10 +485,6 @@ 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

@@ -64,7 +64,7 @@ LITE_OS_SEC_TEXT STATIC VOID OsUpdateSysTimeBase(VOID)
LITE_OS_SEC_TEXT VOID OsTickTimerBaseReset(UINT64 currTime)
{
LOS_ASSERT(currTime >= g_tickTimerBase);
LOS_ASSERT(currTime > g_tickTimerBase);
g_tickTimerBase = currTime;
}

View File

@@ -91,6 +91,7 @@ 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;
@@ -111,20 +112,19 @@ 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 = (CHAR *)osMessageQueueGetName(msgQueueId);
name = osMessageQueueGetName(msgQueueId);
ret = strcmp(name, "q1");
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = osMessageQueueDelete(msgQueueId);
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
name = (CHAR *)osMessageQueueGetName(msgQueueId);
name = 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_VOID(ret, osOK, ret);
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
status = osMessageQueueGet(g_msgQueueId2, &data, NULL, QUEUE_WAIT_TIMEOUT);
ICUNIT_ASSERT_EQUAL_VOID(status, osOK, status);
ICUNIT_ASSERT_EQUAL(status, osOK, status);
ret = strcmp(data, "world");
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(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_VOID(status, osOK, status);
ICUNIT_ASSERT_EQUAL(status, osOK, status);
ret = strcmp(data, "hello");
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
ret = osMessageQueuePut(g_msgQueueId2, &g_strbuff2, 0U, 0U);
ICUNIT_ASSERT_EQUAL_VOID(ret, osOK, ret);
ICUNIT_ASSERT_EQUAL(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((osThreadFunc_t)CmsisQueueTestThread1, NULL, NULL);
threadId1 = osThreadNew(CmsisQueueTestThread1, NULL, NULL);
ICUNIT_ASSERT_NOT_EQUAL(threadId1, NULL, threadId1);
threadId2 = osThreadNew((osThreadFunc_t)CmsisQueueTestThread2, NULL, NULL);
threadId2 = osThreadNew(CmsisQueueTestThread2, NULL, NULL);
ICUNIT_ASSERT_NOT_EQUAL(threadId2, NULL, threadId2);
osThreadJoin(threadId1);
@@ -239,6 +239,8 @@ 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;
@@ -270,8 +272,6 @@ 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,6 +311,8 @@ 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;
@@ -333,8 +335,6 @@ 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,6 +373,8 @@ 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 */
@@ -384,8 +386,6 @@ 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,6 +417,8 @@ 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;
@@ -432,8 +434,6 @@ 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,53 +449,6 @@ 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)
{
@@ -512,7 +465,5 @@ 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_ASSERT_EQUAL(g_testCount, 1, g_testCount);
ICUNIT_ASSERT_EQUAL(g_testAtomicID05, TEST_LOOP, g_testAtomicID05);
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
ICUNIT_GOTO_EQUAL(g_testAtomicID05, TEST_LOOP, g_testAtomicID05, EXIT);
EXIT:
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_ASSERT_EQUAL(g_testCount, 1, g_testCount);
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
EXIT:
return LOS_OK;
}

View File

@@ -36,6 +36,7 @@ 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,6 +36,7 @@ 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_ASSERT_EQUAL(ret, LOS_OK, ret);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert that g_testCount is equal to 3.
g_testCount++;
@@ -84,6 +84,7 @@ 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_ASSERT_EQUAL(ret, LOS_OK, ret);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
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);
(VOID)LOS_TaskResume(g_testTaskID01);
ret = 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

@@ -85,10 +85,13 @@ static UINT32 Testcase(VOID)
LOS_EventInit(&g_pevent);
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
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,13 +129,14 @@ static UINT32 Testcase(VOID)
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT2); // 3, Here, assert that g_testCount is equal to 3.
(VOID)LOS_EventWrite(&g_pevent, 0xF);
ret = LOS_EventWrite(&g_pevent, 0xF);
LOS_TaskDelay(1);
ICUNIT_ASSERT_EQUAL(g_testCount, 6, g_testCount); // 6, Here, assert that g_testCount is equal to 6.
ICUNIT_GOTO_EQUAL(g_testCount, 6, g_testCount, EXIT3); // 6, Here, assert that g_testCount is equal to 6.
(VOID)LOS_EventClear(&g_pevent, 0);
EXIT3:
ret = LOS_EventClear(&g_pevent, 0);
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
ret = LOS_EventDestroy(&g_pevent);

View File

@@ -77,9 +77,10 @@ static UINT32 Testcase(VOID)
LOS_EventClear(&g_pevent, (~(0x11)));
(VOID)LOS_TaskResume(g_testTaskID01);
ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4, Here, assert that g_testCount is equal to 4.
ret = LOS_TaskResume(g_testTaskID01);
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

@@ -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__);
(VOID)strcpy_s(buf, 100, src); /* Check LMS detection information when the strcpy_s dest max set 100 overflows. */
ret = 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;
(VOID)LOS_TaskCreate(&g_testTaskID01, &task);
ret = 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;
(VOID)LOS_TaskCreate(&g_testTaskID01, &task);
ret = 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;
(VOID)LOS_TaskCreate(&g_testTaskID01, &task);
ret = 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,19 +35,17 @@
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, (UINT8 *)buff3, 0, QUEUE_BASE_MSGSIZE);
ret = LOS_QueueCreateStatic("Q1", QUEUE_BASE_NUM, &g_testQueueID01, buff3, 0, QUEUE_BASE_MSGSIZE);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, (UINT32)QUEUE_BASE_MSGSIZE, 0);
ret = LOS_QueueWriteCopy(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, &msgSize, 0);
ret = LOS_QueueReadCopy(g_testQueueID01, &buff2, QUEUE_BASE_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:
(VOID)LOS_TaskDelete(g_testTaskID01);
ret = LOS_TaskDelete(g_testTaskID01);
EXIT2:
ret = LOS_SemDelete(g_usSemID);

View File

@@ -61,7 +61,7 @@ static UINT32 Testcase(VOID)
ret = LOS_SwtmrStart(swTmrID);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
(VOID)LOS_TaskDelay(10); // 10, set delay time.
ret = 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);
(VOID)LOS_TaskDelay(10); // 10, set delay time.
ret = LOS_TaskDelay(10); // 10, set delay time.
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
return LOS_OK;

View File

@@ -49,6 +49,8 @@ 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,6 +50,7 @@ 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();
@@ -63,6 +64,7 @@ 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,8 +46,10 @@ 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 };
@@ -64,7 +66,7 @@ static UINT32 TestCase(VOID)
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
(VOID)GetfreeMemSize(m_aucSysMem0);
freeMem1 = GetfreeMemSize(m_aucSysMem0);
LOS_TaskDelay(10); // 10, task delay times.

View File

@@ -52,6 +52,7 @@ 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,109 +28,6 @@
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

@@ -1,107 +0,0 @@
/*
* 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

@@ -1,160 +0,0 @@
/*
* 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

@@ -1,76 +0,0 @@
/*
* 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

@@ -1,84 +0,0 @@
/*
* 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

@@ -1,80 +0,0 @@
/*
* 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

@@ -1,64 +0,0 @@
/*
* 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

@@ -1,78 +0,0 @@
/*
* 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

@@ -1,96 +0,0 @@
/*
* 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

@@ -1,86 +0,0 @@
/*
* 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

@@ -1,78 +0,0 @@
/*
* 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

@@ -1,85 +0,0 @@
/*
* 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

@@ -1,76 +0,0 @@
/*
* 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

@@ -1,74 +0,0 @@
/*
* 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

@@ -1,95 +0,0 @@
/*
* 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

@@ -1,72 +0,0 @@
/*
* 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

@@ -1,64 +0,0 @@
/*
* 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

@@ -1,72 +0,0 @@
/*
* 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

@@ -1,64 +0,0 @@
/*
* 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

@@ -1,71 +0,0 @@
/*
* 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

@@ -1,92 +0,0 @@
/*
* 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

@@ -1,87 +0,0 @@
/*
* 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

@@ -1,71 +0,0 @@
/*
* 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

@@ -1,84 +0,0 @@
/*
* 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

@@ -1,78 +0,0 @@
/*
* 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

@@ -1,75 +0,0 @@
/*
* 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

@@ -1,151 +0,0 @@
/*
* 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

@@ -1,155 +0,0 @@
/*
* 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

@@ -1,97 +0,0 @@
/*
* 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

@@ -1,85 +0,0 @@
/*
* 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

@@ -1,86 +0,0 @@
/*
* 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

@@ -1,77 +0,0 @@
/*
* 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

@@ -1,84 +0,0 @@
/*
* 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

@@ -1,85 +0,0 @@
/*
* 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

@@ -1,79 +0,0 @@
/*
* 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);
}

View File

@@ -1,83 +0,0 @@
/*
* 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, ret = 0;
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
const CHAR *msgptr = "01234567890123456789";
mqd_t mqueue;
INT32 messagesize[MQUEUE_PRIORITY_NUM_TEST] = {19, 2, 1}; // 19, 2, 1: three values of messagesize for test.
struct mq_attr attr = {0};
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq034_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
for (i = 0; i < MQUEUE_PRIORITY_NUM_TEST; i++) {
attr.mq_msgsize = messagesize[i];
attr.mq_maxmsg = messagesize[i];
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, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EMSGSIZE, 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: ItPosixQueue034
* @tc.desc: Test interface mq_send
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue034(VOID)
{
TEST_ADD_CASE("ItPosixQueue034", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -1,83 +0,0 @@
/*
* 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 mq_attr attr;
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq035_%d", LOS_CurTaskIDGet());
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH + 1;
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH + 1;
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, msgrv, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
ICUNIT_GOTO_EQUAL(errno, EMSGSIZE, 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: ItPosixQueue035
* @tc.desc: Test interface mq_receive
* @tc.type: FUNC
* @tc.require: issueI6148G
*/
VOID ItPosixQueue035(VOID)
{
TEST_ADD_CASE("ItPosixQueue035", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
}

View File

@@ -1,148 +0,0 @@
/*
* 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 ret;
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
g_testCount = 1;
TestAssertWaitDelay(&g_testCount, 3); // 3, Here, assert the g_testCount.
ret = mq_send(g_gqueue, msgptr, strlen(msgptr), 0);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
g_testCount = 2; // 2, Init test count value.
return NULL;
EXIT:
mq_close(g_gqueue);
mq_unlink(g_gqname);
g_testCount = 0;
return NULL;
}
static VOID *PthreadF02(VOID *argument)
{
INT32 ret;
CHAR msgrv[MQUEUE_STANDARD_NAME_LENGTH] = {0};
g_testCount = 3; // 3, Init test count value.
ret = mq_receive(g_gqueue, msgrv, MQUEUE_STANDARD_NAME_LENGTH, NULL);
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT);
ret = MqueueTaskDelay(1);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
ret = mq_close(g_gqueue);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
ret = mq_unlink(g_gqname);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
g_testCount = 4; // 4, Init test count value.
return NULL;
EXIT:
mq_close(g_gqueue);
EXIT1:
mq_unlink(g_gqname);
EXIT2:
g_testCount = 0;
return NULL;
}
static UINT32 Testcase(VOID)
{
INT32 ret;
struct mq_attr attr = {0};
pthread_attr_t attr1;
pthread_t newTh1, newTh2;
(void)snprintf_s(g_gqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
"/mq036_%d", LOS_CurTaskIDGet());
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
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, EXIT3);
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);
TestAssertWaitDelay(&g_testCount, 1);
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(10); // 10, Set delay time.
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
TestAssertWaitDelay(&g_testCount, 4); // 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: ItPosixQueue036
* @tc.desc: Test interface mq_receive
* @tc.type: FUNC
* @tc.require: issueI61YO0
*/
VOID ItPosixQueue036(VOID)
{
TEST_ADD_CASE("ItPosixQueue036", 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