Compare commits

..

9 Commits

Author SHA1 Message Date
openharmony_ci
7fb54d9c15 !1013 fix: 同步修复shell_lk.c告警清零带来的逻辑修改
Merge pull request !1013 from 夏不白/cherry-pick-1664185256
2022-09-27 06:39:02 +00:00
openharmony_ci
91cea8aae0 !1010 fix: 修复内核告警
Merge pull request !1010 from zhangdengyu/cherry-pick-1664183802
2022-09-26 12:52:33 +00:00
xiacong
cbea1a0bad fixed a83f916 from https://gitee.com/xia-bubai/kernel_liteos_a/pulls/1011
<fix>
恢复告警清零带来的逻辑改变

Signed-off-by: xiacong <xiacong4@huawei.com>
Change-Id: I8d34d2b9c43ea54e5474cbddcde0048658cbb891
Signed-off-by: xiacong <xiacong4@huawei.com>
2022-09-26 09:40:56 +00:00
zhangdengyu
5ce18115fe fixed 8dbfd38 from https://gitee.com/zhangdengyu/kernel_liteos_a/pulls/1008
fix: 修复告警

Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-09-26 09:16:42 +00:00
openharmony_ci
1c94be9464 !1002 fix:修复函数返回错误告警
Merge pull request !1002 from zhangdengyu/cherry-pick-1664026127
2022-09-25 08:17:01 +00:00
zhangdengyu
dd8d48a2bf fix:修复函数返回错误等问题
Signed-off-by: zhangdengyu <zhangdengyu2@huawei.com>
2022-09-25 12:33:18 +08:00
openharmony_ci
eb51ba63bd !999 Fix : 将内核告警清理挑单到3.2-Beta3
Merge pull request !999 from yinjiaming/cherry-pick-1663836937
2022-09-22 11:44:36 +00:00
yinjiaming
586d479570 fixed 204d7a4 from https://gitee.com/hgbveiu743/kernel_liteos_a/pulls/997
fix: 内核告警清理
【背景】
内核中经扫描有可以修改的告警之处

【修改方案】
优化了代码的格式

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

re #I5SHM2

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I89be86a8317637f9eb54257131712b5b79f1e454
2022-09-22 08:55:43 +00:00
openharmony_ci
6ed09bf19a !993 Fix : 内核告警清理挑单
Merge pull request !993 from yinjiaming/cherry-pick-1663656326
2022-09-22 06:11:51 +00:00
41 changed files with 223 additions and 142 deletions

View File

@@ -49,7 +49,7 @@ ShellCB *OsGetShellCb()
return g_shellCB; return g_shellCB;
} }
static void ShellDeinit(ShellCB *shellCB) void ShellDeinit(ShellCB *shellCB)
{ {
(void)pthread_mutex_destroy(&shellCB->historyMutex); (void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex); (void)pthread_mutex_destroy(&shellCB->keyMutex);
@@ -65,23 +65,27 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param); ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) { if (ret != SH_OK) {
return ret; goto OUT;
} }
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT; param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param); ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) { if (ret != SH_OK) {
return ret; goto OUT;
} }
ret = ShellTaskInit(shellCB); ret = ShellTaskInit(shellCB);
if (ret != SH_OK) { if (ret != SH_OK) {
return ret; goto OUT;
} }
shellCB->shellEntryHandle = pthread_self(); shellCB->shellEntryHandle = pthread_self();
return 0; return 0;
OUT:
ShellDeinit(shellCB);
return ret;
} }
static int DoShellExec(char **argv) static int DoShellExec(char **argv)
@@ -144,7 +148,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB)); shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) { if (shellCB == NULL) {
return SH_NOK; goto ERR_OUT1;
} }
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB)); ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) { if (ret != SH_OK) {
@@ -172,9 +176,7 @@ int main(int argc, char **argv)
g_shellCB = shellCB; g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB); ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) { if (ret != SH_OK) {
ShellDeinit(shellCB); goto ERR_OUT3;
g_shellCB = NULL;
return ret;
} }
ShellEntry(shellCB); ShellEntry(shellCB);

View File

@@ -1465,7 +1465,7 @@ INT32 los_disk_init(const CHAR *diskName, const struct block_operations *bops,
ret = VnodeLookup(diskName, &blkDriver, 0); ret = VnodeLookup(diskName, &blkDriver, 0);
if (ret < 0) { if (ret < 0) {
VnodeDrop(); VnodeDrop();
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret); ret = ENOENT;
goto DISK_FIND_ERROR; goto DISK_FIND_ERROR;
} }
struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops; struct block_operations *bops2 = (struct block_operations *)((struct drv_data *)blkDriver->data)->ops;

View File

@@ -2311,7 +2311,7 @@ diff -Nupr old/fs/jffs2/erase.c new/fs/jffs2/erase.c
diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
--- old/fs/jffs2/file.c 2022-05-09 17:22:53.000000000 +0800 --- old/fs/jffs2/file.c 2022-05-09 17:22:53.000000000 +0800
+++ new/fs/jffs2/file.c 2022-05-10 09:43:14.250000000 +0800 +++ new/fs/jffs2/file.c 2022-05-10 09:43:14.250000000 +0800
@@ -9,335 +9,30 @@ @@ -9,325 +9,34 @@
* For licensing information, see the file 'LICENCE' in this directory. * For licensing information, see the file 'LICENCE' in this directory.
* *
*/ */
@@ -2336,35 +2336,32 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- loff_t pos, unsigned len, unsigned flags, - loff_t pos, unsigned len, unsigned flags,
- struct page **pagep, void **fsdata); - struct page **pagep, void **fsdata);
-static int jffs2_readpage (struct file *filp, struct page *pg); -static int jffs2_readpage (struct file *filp, struct page *pg);
-
-int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
-{
- struct inode *inode = filp->f_mapping->host;
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- int ret;
-
- ret = file_write_and_wait_range(filp, start, end);
- if (ret)
- return ret;
- inode_lock(inode);
- /* Trigger GC to flush any pending writes for this inode */
- jffs2_flush_wbuf_gc(c, inode->i_ino);
- inode_unlock(inode);
+static unsigned char gc_buffer[PAGE_SIZE]; //avoids malloc when user may be under memory pressure +static unsigned char gc_buffer[PAGE_SIZE]; //avoids malloc when user may be under memory pressure
-int jffs2_fsync(struct file *filp, loff_t start, loff_t end, int datasync) - return 0;
-}
-const struct file_operations jffs2_file_operations =
+unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c, +unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
+ struct jffs2_inode_info *f, + struct jffs2_inode_info *f,
+ unsigned long offset, + unsigned long offset,
+ unsigned long *priv) + unsigned long *priv)
{ {
- struct inode *inode = filp->f_mapping->host;
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
+ /* FIXME: This works only with one file system mounted at a time */
int ret;
-
- ret = file_write_and_wait_range(filp, start, end);
+ ret = jffs2_read_inode_range(c, f, gc_buffer,
+ offset & ~(PAGE_SIZE-1), PAGE_SIZE);
if (ret)
- return ret;
-
- inode_lock(inode);
- /* Trigger GC to flush any pending writes for this inode */
- jffs2_flush_wbuf_gc(c, inode->i_ino);
- inode_unlock(inode);
-
- return 0;
-}
-
-const struct file_operations jffs2_file_operations =
-{
- .llseek = generic_file_llseek, - .llseek = generic_file_llseek,
- .open = generic_file_open, - .open = generic_file_open,
- .read_iter = generic_file_read_iter, - .read_iter = generic_file_read_iter,
@@ -2398,8 +2395,9 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); - struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb); - struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- unsigned char *pg_buf; - unsigned char *pg_buf;
- int ret; + /* FIXME: This works only with one file system mounted at a time */
- int ret;
- jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n", - jffs2_dbg(2, "%s(): ino #%lu, page at offset 0x%lx\n",
- __func__, inode->i_ino, pg->index << PAGE_SHIFT); - __func__, inode->i_ino, pg->index << PAGE_SHIFT);
- -
@@ -2438,15 +2436,18 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
-{ -{
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host); - struct jffs2_inode_info *f = JFFS2_INODE_INFO(pg->mapping->host);
- int ret; - int ret;
- + ret = jffs2_read_inode_range(c, f, gc_buffer,
+ offset & ~(PAGE_SIZE-1), PAGE_SIZE);
+ if (ret)
+ return ERR_PTR(ret);
- mutex_lock(&f->sem); - mutex_lock(&f->sem);
- ret = jffs2_do_readpage_unlock(pg->mapping->host, pg); - ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
- mutex_unlock(&f->sem); - mutex_unlock(&f->sem);
- return ret; - return ret;
+ return ERR_PTR(ret);
+ return gc_buffer; + return gc_buffer;
} }
-
-static int jffs2_write_begin(struct file *filp, struct address_space *mapping, -static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned flags, - loff_t pos, unsigned len, unsigned flags,
- struct page **pagep, void **fsdata) - struct page **pagep, void **fsdata)
@@ -2457,15 +2458,20 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- struct page *pg; - struct page *pg;
- struct inode *inode = mapping->host; - struct inode *inode = mapping->host;
- struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); - struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- pgoff_t index = pos >> PAGE_SHIFT; - pgoff_t index = pos >> PAGE_SHIFT;
- uint32_t pageofs = index << PAGE_SHIFT; - uint32_t pageofs = index << PAGE_SHIFT;
- int ret = 0; - int ret = 0;
- -
- pg = grab_cache_page_write_begin(mapping, index, flags);
- if (!pg)
- return -ENOMEM;
- *pagep = pg;
-
- jffs2_dbg(1, "%s()\n", __func__); - jffs2_dbg(1, "%s()\n", __func__);
- -
- if (pageofs > inode->i_size) { - if (pageofs > inode->i_size) {
- /* Make new hole frag from old EOF to new page */ - /* Make new hole frag from old EOF to new page */
- struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- struct jffs2_raw_inode ri; - struct jffs2_raw_inode ri;
- struct jffs2_full_dnode *fn; - struct jffs2_full_dnode *fn;
- uint32_t alloc_len; - uint32_t alloc_len;
@@ -2476,7 +2482,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len, - ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
- ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE); - ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
- if (ret) - if (ret)
- goto out_err; - goto out_page;
- -
- mutex_lock(&f->sem); - mutex_lock(&f->sem);
- memset(&ri, 0, sizeof(ri)); - memset(&ri, 0, sizeof(ri));
@@ -2506,7 +2512,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- ret = PTR_ERR(fn); - ret = PTR_ERR(fn);
- jffs2_complete_reservation(c); - jffs2_complete_reservation(c);
- mutex_unlock(&f->sem); - mutex_unlock(&f->sem);
- goto out_err; - goto out_page;
- } - }
- ret = jffs2_add_full_dnode_to_inode(c, f, fn); - ret = jffs2_add_full_dnode_to_inode(c, f, fn);
- if (f->metadata) { - if (f->metadata) {
@@ -2521,7 +2527,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- jffs2_free_full_dnode(fn); - jffs2_free_full_dnode(fn);
- jffs2_complete_reservation(c); - jffs2_complete_reservation(c);
- mutex_unlock(&f->sem); - mutex_unlock(&f->sem);
- goto out_err; - goto out_page;
- } - }
- jffs2_complete_reservation(c); - jffs2_complete_reservation(c);
- inode->i_size = pageofs; - inode->i_size = pageofs;
@@ -2529,19 +2535,6 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- } - }
- -
- /* - /*
- * While getting a page and reading data in, lock c->alloc_sem until
- * the page is Uptodate. Otherwise GC task may attempt to read the same
- * page in read_cache_page(), which causes a deadlock.
- */
- mutex_lock(&c->alloc_sem);
- pg = grab_cache_page_write_begin(mapping, index, flags);
- if (!pg) {
- ret = -ENOMEM;
- goto release_sem;
- }
- *pagep = pg;
-
- /*
- * Read in the page if it wasn't already present. Cannot optimize away - * Read in the page if it wasn't already present. Cannot optimize away
- * the whole page write case until jffs2_write_end can handle the - * the whole page write case until jffs2_write_end can handle the
- * case of a short-copy. - * case of a short-copy.
@@ -2550,20 +2543,19 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- mutex_lock(&f->sem); - mutex_lock(&f->sem);
- ret = jffs2_do_readpage_nolock(inode, pg); - ret = jffs2_do_readpage_nolock(inode, pg);
- mutex_unlock(&f->sem); - mutex_unlock(&f->sem);
- if (ret) { - if (ret)
- unlock_page(pg); - goto out_page;
- put_page(pg);
- goto release_sem;
- }
- } - }
- jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags); - jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
-
-release_sem:
- mutex_unlock(&c->alloc_sem);
-out_err:
- return ret; - return ret;
-}
- -
-out_page:
- unlock_page(pg);
- put_page(pg);
- return ret;
+ /* Do nothing */
}
-static int jffs2_write_end(struct file *filp, struct address_space *mapping, -static int jffs2_write_end(struct file *filp, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned copied, - loff_t pos, unsigned len, unsigned copied,
- struct page *pg, void *fsdata) - struct page *pg, void *fsdata)
@@ -2661,8 +2653,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- unlock_page(pg); - unlock_page(pg);
- put_page(pg); - put_page(pg);
- return writtenlen > 0 ? writtenlen : ret; - return writtenlen > 0 ? writtenlen : ret;
+ /* Do nothing */ -}
}
diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c diff -Nupr old/fs/jffs2/fs.c new/fs/jffs2/fs.c
--- old/fs/jffs2/fs.c 2022-05-09 17:22:53.000000000 +0800 --- old/fs/jffs2/fs.c 2022-05-09 17:22:53.000000000 +0800
+++ new/fs/jffs2/fs.c 2022-05-10 16:13:37.830000000 +0800 +++ new/fs/jffs2/fs.c 2022-05-10 16:13:37.830000000 +0800

View File

@@ -780,6 +780,7 @@ ssize_t VfsJffs2Readlink(struct Vnode *vnode, char *buffer, size_t bufLen)
cnt = (bufLen - 1) < targetLen ? (bufLen - 1) : targetLen; cnt = (bufLen - 1) < targetLen ? (bufLen - 1) : targetLen;
if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) { if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) {
cnt = 0;
LOS_MuxUnlock(&g_jffs2FsLock); LOS_MuxUnlock(&g_jffs2FsLock);
return -EFAULT; return -EFAULT;
} }

View File

@@ -353,7 +353,7 @@ static struct file_operations_vfs g_errorFileOps = {
.unlink = ErrorFopUnlink, .unlink = ErrorFopUnlink,
}; };
static struct Mount* GetDevMountPoint(const struct Vnode *dev) static struct Mount* GetDevMountPoint(struct Vnode *dev)
{ {
struct Mount *mnt = NULL; struct Mount *mnt = NULL;
LIST_HEAD *mntList = GetMountList(); LIST_HEAD *mntList = GetMountList();
@@ -394,7 +394,7 @@ static void FilePreClose(struct file *filep, const struct file_operations_vfs *o
} }
} }
static void FileDisableAndClean(const struct Mount *mnt) static void FileDisableAndClean(struct Mount *mnt)
{ {
struct filelist *flist = &tg_filelist; struct filelist *flist = &tg_filelist;
struct file *filep = NULL; struct file *filep = NULL;
@@ -435,7 +435,7 @@ static void VnodeTryFree(struct Vnode *vnode)
vnode->fop = &g_errorFileOps; vnode->fop = &g_errorFileOps;
} }
static void VnodeTryFreeAll(const struct Mount *mount) static void VnodeTryFreeAll(struct Mount *mount)
{ {
struct Vnode *vnode = NULL; struct Vnode *vnode = NULL;
struct Vnode *nextVnode = NULL; struct Vnode *nextVnode = NULL;

View File

@@ -66,6 +66,7 @@ static int iov_trans_to_buf(char *buf, ssize_t totallen, const struct iovec *iov
} else { } else {
writepart = bytestowrite - ret; writepart = bytestowrite - ret;
curbuf += writepart; curbuf += writepart;
totallen -= writepart;
break; break;
} }
} }

View File

@@ -70,7 +70,7 @@ VOID OsVmPhysDump(VOID);
VOID OsVmPhysUsedInfoGet(UINT32 *usedCount, UINT32 *totalCount); VOID OsVmPhysUsedInfoGet(UINT32 *usedCount, UINT32 *totalCount);
INT32 OsRegionOverlapCheck(LosVmSpace *space, LosVmMapRegion *region); INT32 OsRegionOverlapCheck(LosVmSpace *space, LosVmMapRegion *region);
VOID OsDumpPte(VADDR_T vaddr); VOID OsDumpPte(VADDR_T vaddr);
LosProcessCB *OsGetPIDByAspace(const LosVmSpace *space); LosProcessCB *OsGetPIDByAspace(LosVmSpace *space);
CHAR *OsArchFlagsToStr(const UINT32 archFlags); CHAR *OsArchFlagsToStr(const UINT32 archFlags);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -193,7 +193,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB);
LosFilePage *OsPageCacheAlloc(struct page_mapping *mapping, VM_OFFSET_T pgoff); LosFilePage *OsPageCacheAlloc(struct page_mapping *mapping, VM_OFFSET_T pgoff);
LosFilePage *OsFindGetEntry(struct page_mapping *mapping, VM_OFFSET_T pgoff); LosFilePage *OsFindGetEntry(struct page_mapping *mapping, VM_OFFSET_T pgoff);
LosMapInfo *OsGetMapInfo(const LosFilePage *page, const LosArchMmu *archMmu, VADDR_T vaddr); LosMapInfo *OsGetMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr);
VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr); VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr);
VOID OsDelMapInfo(LosVmMapRegion *region, LosVmPgFault *pgFault, BOOL cleanDirty); VOID OsDelMapInfo(LosVmMapRegion *region, LosVmPgFault *pgFault, BOOL cleanDirty);
VOID OsFileCacheFlush(struct page_mapping *mapping); VOID OsFileCacheFlush(struct page_mapping *mapping);
@@ -208,7 +208,7 @@ VOID OsDeletePageCacheLru(LosFilePage *page);
VOID OsPageRefDecNoLock(LosFilePage *page); VOID OsPageRefDecNoLock(LosFilePage *page);
VOID OsPageRefIncLocked(LosFilePage *page); VOID OsPageRefIncLocked(LosFilePage *page);
int OsTryShrinkMemory(size_t nPage); int OsTryShrinkMemory(size_t nPage);
VOID OsMarkPageDirty(LosFilePage *fpage, const LosVmMapRegion *region, int off, int len); VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, int off, int len);
#ifdef LOSCFG_DEBUG_VERSION #ifdef LOSCFG_DEBUG_VERSION
VOID ResetPageCacheHitInfo(int *try, int *hit); VOID ResetPageCacheHitInfo(int *try, int *hit);

View File

@@ -96,7 +96,7 @@ UINT32 LOS_RwlockDestroy(LosRwlock *rwlock)
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 OsRwlockCheck(const LosRwlock *rwlock) STATIC UINT32 OsRwlockCheck(LosRwlock *rwlock)
{ {
if (rwlock == NULL) { if (rwlock == NULL) {
return LOS_EINVAL; return LOS_EINVAL;

View File

@@ -78,6 +78,7 @@ STATIC VOID OsMoveTmpInfoToUnbInfo(sig_cb *sigcb, INT32 signo)
/* delete tmpinfo from tmpList. */ /* delete tmpinfo from tmpList. */
*prevHook = tmpInfoNode->next; *prevHook = tmpInfoNode->next;
(VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode); (VOID)LOS_MemFree(m_aucSysMem0, tmpInfoNode);
tmpInfoNode = *prevHook;
break; break;
} }
prevHook = &tmpInfoNode->next; prevHook = &tmpInfoNode->next;

View File

@@ -918,7 +918,7 @@ STATIC UINT32 OsMemPoolAdd(VOID *pool, UINT32 size)
return LOS_OK; return LOS_OK;
} }
STATIC UINT32 OsMemPoolDelete(const VOID *pool) STATIC UINT32 OsMemPoolDelete(VOID *pool)
{ {
UINT32 ret = LOS_NOK; UINT32 ret = LOS_NOK;
VOID *nextPool = NULL; VOID *nextPool = NULL;

View File

@@ -146,6 +146,7 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
LosVmSpace *space = NULL; LosVmSpace *space = NULL;
LOS_DL_LIST *spaceList = NULL; LOS_DL_LIST *spaceList = NULL;
UINT32 UProcessUsed = 0; UINT32 UProcessUsed = 0;
UINT32 pmTmp;
if (actualPm == NULL) { if (actualPm == NULL) {
return 0; return 0;
@@ -166,7 +167,8 @@ UINT32 OsKProcessPmUsage(LosVmSpace *kSpace, UINT32 *actualPm)
if (space == LOS_GetKVmSpace()) { if (space == LOS_GetKVmSpace()) {
continue; continue;
} }
UProcessUsed += OsUProcessPmUsage(space, NULL, NULL); (VOID)OsUProcessPmUsage(space, NULL, &pmTmp);
UProcessUsed += pmTmp;
} }
(VOID)LOS_MuxRelease(vmSpaceListMux); (VOID)LOS_MuxRelease(vmSpaceListMux);
@@ -251,7 +253,7 @@ UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm)
return pmSize; return pmSize;
} }
LosProcessCB *OsGetPIDByAspace(const LosVmSpace *space) LosProcessCB *OsGetPIDByAspace(LosVmSpace *space)
{ {
UINT32 pid; UINT32 pid;
UINT32 intSave; UINT32 intSave;

View File

@@ -125,10 +125,10 @@ VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
page->n_maps++; page->n_maps++;
} }
LosMapInfo *OsGetMapInfo(const LosFilePage *page, const LosArchMmu *archMmu, VADDR_T vaddr) LosMapInfo *OsGetMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
{ {
LosMapInfo *info = NULL; LosMapInfo *info = NULL;
const LOS_DL_LIST *immap = &page->i_mmap; LOS_DL_LIST *immap = &page->i_mmap;
LOS_DL_LIST_FOR_EACH_ENTRY(info, immap, LosMapInfo, node) { LOS_DL_LIST_FOR_EACH_ENTRY(info, immap, LosMapInfo, node) {
if ((info->archMmu == archMmu) && (info->vaddr == vaddr) && (info->page == page)) { if ((info->archMmu == archMmu) && (info->vaddr == vaddr) && (info->page == page)) {
@@ -214,7 +214,7 @@ VOID OsVmmFileRemove(LosVmMapRegion *region, LosArchMmu *archMmu, VM_OFFSET_T pg
return; return;
} }
VOID OsMarkPageDirty(LosFilePage *fpage, const LosVmMapRegion *region, INT32 off, INT32 len) VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, INT32 off, INT32 len)
{ {
if (region != NULL) { if (region != NULL) {
OsSetPageDirty(fpage->vmPage); OsSetPageDirty(fpage->vmPage);

View File

@@ -233,7 +233,7 @@ LosVmSpace *OsCreateUserVmSpace(VOID)
return space; return space;
} }
STATIC BOOL OsVmSpaceParamCheck(const LosVmSpace *vmSpace) STATIC BOOL OsVmSpaceParamCheck(LosVmSpace *vmSpace)
{ {
if (vmSpace == NULL) { if (vmSpace == NULL) {
return FALSE; return FALSE;

View File

@@ -233,8 +233,14 @@ static int HiLogWriteRingBuffer(unsigned char *buffer, size_t bufLen)
static void HiLogHeadInit(struct HiLogEntry *header, size_t len) static void HiLogHeadInit(struct HiLogEntry *header, size_t len)
{ {
struct timespec now = {0}; struct timespec now;
(void)clock_gettime(CLOCK_REALTIME, &now); int ret;
ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
PRINTK("In %s line %d,clock_gettime fail\n", __FUNCTION__, __LINE__);
return;
}
header->len = len; header->len = len;
header->pid = LOS_GetCurrProcessID(); header->pid = LOS_GetCurrProcessID();

View File

@@ -289,7 +289,7 @@ STATIC UINT32 OsPerfCollectData(Event *event, PerfSampleData *data, PerfRegs *re
* return TRUE if user haven't specified any taskId(which is supposed * return TRUE if user haven't specified any taskId(which is supposed
* to instrument the whole system) * to instrument the whole system)
*/ */
STATIC INLINE BOOL OsFilterId(UINT32 id, const UINT32 *ids, UINT8 idsNr) STATIC INLINE BOOL OsFilterId(UINT32 id, UINT32 *ids, UINT8 idsNr)
{ {
UINT32 i; UINT32 i;
if (!idsNr) { if (!idsNr) {

View File

@@ -300,7 +300,7 @@ UINT32 LOS_PmRegister(LOS_PmNodeType type, VOID *node)
return LOS_EINVAL; return LOS_EINVAL;
} }
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, const LosPmDevice *device) STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, LosPmDevice *device)
{ {
LOS_SpinLock(&g_pmSpin); LOS_SpinLock(&g_pmSpin);
if (pm->device == device) { if (pm->device == device) {

View File

@@ -2175,6 +2175,8 @@ u32_t osShellPing6(int argc, const char **argv)
/* Setting the start time of the entire ping task for statistics */ /* Setting the start time of the entire ping task for statistics */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &first); (void)clock_gettime(CLOCK_MONOTONIC_RAW, &first);
nsent = 0;
for (nsent = 0; nsent < ping6_params.pingcount; nsent++) { for (nsent = 0; nsent < ping6_params.pingcount; nsent++) {
/* capture the start tick to calculate rtt */ /* capture the start tick to calculate rtt */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &start); (void)clock_gettime(CLOCK_MONOTONIC_RAW, &start);
@@ -3168,6 +3170,7 @@ void netstat_internal(void *ctx)
} }
/* For listen PCBs */ /* For listen PCBs */
recvQlen = 0;
sendQlen = 0; sendQlen = 0;
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
@@ -3667,7 +3670,7 @@ u32_t netdebug_sock(int argc, const char **argv)
int idx; int idx;
u32_t ret = LOS_NOK; u32_t ret = LOS_NOK;
if (argc == 2) { /* 2: Number of command parameters */ if (argc == 2) {
if (!strcmp("-i", argv[1])) { if (!strcmp("-i", argv[1])) {
/* netdebug sock -i */ /* netdebug sock -i */
for (idx = 0; idx < (int)LWIP_CONFIG_NUM_SOCKETS; idx++) { for (idx = 0; idx < (int)LWIP_CONFIG_NUM_SOCKETS; idx++) {
@@ -3675,9 +3678,10 @@ u32_t netdebug_sock(int argc, const char **argv)
} }
ret = LOS_OK; ret = LOS_OK;
} }
} else if (argc == 3) { /* 3: Number of command parameters */ } else if (argc == 3) {
if (!strcmp("-d", argv[1])) { if (!strcmp("-d", argv[1])) {
idx = atoi(argv[2]); /* 2: netdebug sock -d <idx> */ /* netdebug sock -d <idx> */
idx = atoi(argv[2]);
if (idx >= 0) { if (idx >= 0) {
debug_socket_info(idx, 1, 1); debug_socket_info(idx, 1, 1);
ret = LOS_OK; ret = LOS_OK;

View File

@@ -116,8 +116,8 @@ static UINT16 GetFreeVid(VOID)
for (i = 0; i < mapMaxNum; i++) { for (i = 0; i < mapMaxNum; i++) {
num = idMap->bitMap[i]; num = idMap->bitMap[i];
for (j = 0; j < INT_BIT_COUNT; j++) { for (j = 0; j < INT_BIT_COUNT; j++) {
if ((num & (1U << j)) == 0) { if ((num & (1 << j)) == 0) {
num |= 1U << j; num |= 1 << j;
idMap->bitMap[i] = num; idMap->bitMap[i] = num;
return (INT_BIT_COUNT * i + j); return (INT_BIT_COUNT * i + j);
} }

View File

@@ -109,7 +109,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
{ {
int ret; int ret;
struct itimerval svalue; struct itimerval svalue;
struct itimerval sovalue = { 0 }; struct itimerval sovalue;
if (value == NULL) { if (value == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -137,7 +137,7 @@ int SysSetiTimer(int which, const struct itimerval *value, struct itimerval *ova
int SysGetiTimer(int which, struct itimerval *value) int SysGetiTimer(int which, struct itimerval *value)
{ {
int ret; int ret;
struct itimerval svalue = { 0 }; struct itimerval svalue;
if (value == NULL) { if (value == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -189,7 +189,7 @@ int SysTimerCreate(clockid_t clockID, struct ksigevent *evp, timer_t *timerID)
int SysTimerGettime(timer_t timerID, struct itimerspec *value) int SysTimerGettime(timer_t timerID, struct itimerspec *value)
{ {
int ret; int ret;
struct itimerspec svalue = { 0 }; struct itimerspec svalue;
if (value == NULL) { if (value == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -213,7 +213,7 @@ int SysTimerSettime(timer_t timerID, int flags, const struct itimerspec *value,
{ {
int ret; int ret;
struct itimerspec svalue; struct itimerspec svalue;
struct itimerspec soldValue = { 0 }; struct itimerspec soldValue;
if (value == NULL) { if (value == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -285,7 +285,7 @@ int SysClockSettime(clockid_t clockID, const struct timespec *tp)
int SysClockGettime(clockid_t clockID, struct timespec *tp) int SysClockGettime(clockid_t clockID, struct timespec *tp)
{ {
int ret; int ret;
struct timespec stp = { 0 }; struct timespec stp;
if (tp == NULL) { if (tp == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -308,7 +308,7 @@ int SysClockGettime(clockid_t clockID, struct timespec *tp)
int SysClockGetres(clockid_t clockID, struct timespec *tp) int SysClockGetres(clockid_t clockID, struct timespec *tp)
{ {
int ret; int ret;
struct timespec stp = { 0 }; struct timespec stp;
if (tp == NULL) { if (tp == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -356,7 +356,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
{ {
int ret; int ret;
struct timespec srqtp; struct timespec srqtp;
struct timespec srmtp = { 0 }; struct timespec srmtp;
if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) { if (!rqtp || LOS_ArchCopyFromUser(&srqtp, rqtp, sizeof(struct timespec))) {
errno = EFAULT; errno = EFAULT;
@@ -384,7 +384,7 @@ int SysNanoSleep(const struct timespec *rqtp, struct timespec *rmtp)
clock_t SysTimes(struct tms *buf) clock_t SysTimes(struct tms *buf)
{ {
clock_t ret; clock_t ret;
struct tms sbuf = { 0 }; struct tms sbuf;
if (buf == NULL) { if (buf == NULL) {
errno = EFAULT; errno = EFAULT;
@@ -436,7 +436,7 @@ int SysClockGettime64(clockid_t clockID, struct timespec64 *tp)
{ {
int ret; int ret;
struct timespec t; struct timespec t;
struct timespec64 stp = { 0 }; struct timespec64 stp;
if (tp == NULL) { if (tp == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -463,7 +463,7 @@ int SysClockGetres64(clockid_t clockID, struct timespec64 *tp)
{ {
int ret; int ret;
struct timespec t; struct timespec t;
struct timespec64 stp = { 0 }; struct timespec64 stp;
if (tp == NULL) { if (tp == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -525,7 +525,7 @@ int SysTimerGettime64(timer_t timerID, struct itimerspec64 *value)
{ {
int ret; int ret;
struct itimerspec val; struct itimerspec val;
struct itimerspec64 svalue = { 0 }; struct itimerspec64 svalue;
if (value == NULL) { if (value == NULL) {
errno = EINVAL; errno = EINVAL;
@@ -584,7 +584,6 @@ int SysTimerSettime64(timer_t timerID, int flags, const struct itimerspec64 *val
} }
if (oldValue != NULL) { if (oldValue != NULL) {
(void)memset_s(&soldValue, sizeof(struct itimerspec64), 0, sizeof(struct itimerspec64));
soldValue.it_interval.tv_sec = oldVal.it_interval.tv_sec; soldValue.it_interval.tv_sec = oldVal.it_interval.tv_sec;
soldValue.it_interval.tv_nsec = oldVal.it_interval.tv_nsec; soldValue.it_interval.tv_nsec = oldVal.it_interval.tv_nsec;
soldValue.it_value.tv_sec = oldVal.it_value.tv_sec; soldValue.it_value.tv_sec = oldVal.it_value.tv_sec;

View File

@@ -49,13 +49,13 @@ static VOID NestingPrioHigh(INT32 irq, VOID *data)
UINT64 curTime; UINT64 curTime;
curTime = LOS_CurrNanosec(); curTime = LOS_CurrNanosec();
g_recordTime[g_saveIndex] = curTime - g_intPendTime; g_recordTime[g_saveIndex] = curTime - g_intPendTime;
if (g_saveIndex == MAX_RECORD_SIZE) {
g_saveIndex = 0;
}
dprintf("curTime = %lld, pendTime = %lld \n", curTime, g_intPendTime); dprintf("curTime = %lld, pendTime = %lld \n", curTime, g_intPendTime);
dprintf("%lld\n", curTime - g_intPendTime); dprintf("%lld\n", curTime - g_intPendTime);
dprintf("[swtmr] hwi response time : ##%lld \n", g_recordTime[g_saveIndex]); dprintf("[swtmr] hwi response time : ##%lld \n", g_recordTime[g_saveIndex]);
g_saveIndex++; g_saveIndex++;
if (g_saveIndex == MAX_RECORD_SIZE) {
g_saveIndex = 0;
}
} }
static VOID DumpResult() static VOID DumpResult()

View File

@@ -39,7 +39,8 @@ extern "C" {
static UINT32 TaskF02(VOID) static UINT32 TaskF02(VOID)
{ {
UINT32 ret = OS_ERROR, cpupUse; UINT32 ret = OS_ERROR;
UINT32 cpupUse;
g_cpupTestCount++; g_cpupTestCount++;
// 2, Here, assert that g_cpupTestCount is equal to the expected value. // 2, Here, assert that g_cpupTestCount is equal to the expected value.

View File

@@ -76,7 +76,7 @@ static void Task01(void)
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2); ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT2);
ret = memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S)); ret = memset_s((void *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2); ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2;
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task04; taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)Task04;
taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE; taskInitParam.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
taskInitParam.pcName = "SmpCpup005_task04"; taskInitParam.pcName = "SmpCpup005_task04";

View File

@@ -34,11 +34,9 @@ static int TestCase(void)
{ {
int ret; int ret;
int status = 0; int status = 0;
int *test = NULL; // for trggering an exception
pid_t pid = fork(); pid_t pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid); ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) { if (pid == 0) {
*test = 0x1; // Deliberately trigger an exceptioin
exit(0); exit(0);
} }
@@ -54,7 +52,6 @@ static int TestCase(void)
pid = fork(); pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid); ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) { if (pid == 0) {
*test = 0x1; // Deliberately trigger an exceptioin
exit(0); exit(0);
} }

View File

@@ -36,16 +36,13 @@
static int TestThread(void) static int TestThread(void)
{ {
int ret; int ret;
int *test = nullptr; // For triggering an exceptioin
pid_t pid = fork(); pid_t pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid); ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) { if (pid == 0) {
*test = 0x1; // Deliberately trigger an exceptioin
while (1) { while (1) {
} }
} }
*test = 0x1; // Deliberately trigger an exceptioin
ret = waitpid(pid, NULL, 0); ret = waitpid(pid, NULL, 0);
ICUNIT_ASSERT_EQUAL(ret, pid, ret); ICUNIT_ASSERT_EQUAL(ret, pid, ret);

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@@ -31,46 +31,39 @@
#include "it_test_shm.h" #include "it_test_shm.h"
#define SHMID_MAX 192 #define SHMID_MAX 192
#define SHM_FLAG 0777
static int Testcase(VOID) static int Testcase(VOID)
{ {
int shmid[SHMID_MAX + 1] = {-1}; int shmid[SHMID_MAX + 1] = {-1};
int ret; int ret;
int i; int i;
struct shm_info shmInfo;
int leftShmIds;
ret = shmctl(0, SHM_INFO, reinterpret_cast<struct shmid_ds *>(&shmInfo)); shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(ret, SHMID_MAX, ret);
leftShmIds = SHMID_MAX - shmInfo.used_ids;
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, SHM_FLAG | IPC_CREAT); // 0x1234: a key used to create shared memory
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]); ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL); ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT); shmid[0] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]); ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL); ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
for (i = 0; i < leftShmIds; i++) { for (i = 0; i < SHMID_MAX; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT); shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]); ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]);
} }
shmid[leftShmIds] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT); shmid[SHMID_MAX] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(shmid[leftShmIds], -1, shmid[leftShmIds]); ICUNIT_ASSERT_EQUAL(shmid[SHMID_MAX], -1, shmid[SHMID_MAX]);
for (i = 0; i < leftShmIds; i++) { for (i = 0; i < SHMID_MAX; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL); ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
} }
for (i = 0; i < leftShmIds; i++) { for (i = 0; i < SHMID_MAX; i++) {
ret = shmctl(shmid[i], IPC_RMID, NULL); ret = shmctl(shmid[i], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, -1, ret); ICUNIT_ASSERT_EQUAL(ret, -1, ret);
} }

View File

@@ -55,6 +55,7 @@ static int Testcase(VOID)
ICUNIT_GOTO_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid, ERROR_OUT); ICUNIT_GOTO_EQUAL(ds.shm_perm.uid, getuid(), ds.shm_perm.uid, ERROR_OUT);
ret = shmctl(shmid, SHM_STAT, &ds); ret = shmctl(shmid, SHM_STAT, &ds);
// ICUNIT_GOTO_EQUAL(ret, 0x10000, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROR_OUT); ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, ERROR_OUT);
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, ERROR_OUT); ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, ERROR_OUT);
@@ -69,7 +70,7 @@ static int Testcase(VOID)
ICUNIT_GOTO_EQUAL(info.shmmax, 0x1000000, info.shmmax, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmmax, 0x1000000, info.shmmax, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmin, 1, info.shmmin, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmmin, 1, info.shmmin, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmmni, 192, info.shmmni, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmmni, 192, info.shmmni, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT); // 128: expected value of shmseg ICUNIT_GOTO_EQUAL(info.shmseg, 128, info.shmseg, ERROR_OUT);
ICUNIT_GOTO_EQUAL(info.shmall, 0x1000, info.shmall, ERROR_OUT); ICUNIT_GOTO_EQUAL(info.shmall, 0x1000, info.shmall, ERROR_OUT);
ret = shmdt(shm); ret = shmdt(shm);

View File

@@ -63,11 +63,13 @@ static int LiteIpcTest(void)
/* testing mmap liteipc mem pool with different size and flag */ /* testing mmap liteipc mem pool with different size and flag */
retptr = mmap(nullptr, 1024 * 4096, PROT_READ, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, 1024 * 4096, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
//retptr = mmap(nullptr, 0, PROT_READ, MAP_PRIVATE, fd, 0);
//ICUNIT_ASSERT_EQUAL((int)(intptr_t)retptr, -1, retptr);
retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, -1, PROT_READ, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, 4096, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0); // 4096: length of mapped memory retptr = mmap(nullptr, 4096, PROT_READ, MAP_SHARED, fd, 0);
ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr); ICUNIT_ASSERT_EQUAL(static_cast<int>(static_cast<intptr_t>(retptr)), -1, retptr);
retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0); retptr = mmap(nullptr, 1, PROT_READ, MAP_PRIVATE, fd, 0);
@@ -79,7 +81,7 @@ static int LiteIpcTest(void)
char buf[10] = {0}; char buf[10] = {0};
ret = read(fd, buf, 10); ret = read(fd, buf, 10);
ICUNIT_ASSERT_EQUAL(ret, -1, ret); ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ret = write(fd, buf, 10); // 10: size of buf ret = write(fd, buf, 10);
ICUNIT_ASSERT_EQUAL(ret, -1, ret); ICUNIT_ASSERT_EQUAL(ret, -1, ret);
/* before set cms, testing ioctl cmd */ /* before set cms, testing ioctl cmd */
@@ -94,7 +96,7 @@ static int LiteIpcTest(void)
sleep(2); sleep(2);
/* after set cms, testing set cms cmd */ /* after set cms, testing set cms cmd */
ret = ioctl(fd, IPC_SET_CMS, 200); // 200: use 200 for set cms cmd testing ret = ioctl(fd, IPC_SET_CMS, 200);
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
exit(0); exit(0);

View File

@@ -60,6 +60,17 @@ static int TestCase()
exit(0); exit(0);
} }
/* sig = SIGTERM;
ret = sigaction(sig, (struct sigaction *)1, &oldAct);
printf("ret == %d\n", ret);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno);
ret = sigaction(sig, &sigAct, (struct sigaction *)1);
printf("ret === %d\n", ret);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
ICUNIT_ASSERT_EQUAL(errno, EFAULT, errno); */
ret = waitpid(fpid, &status, 0); ret = waitpid(fpid, &status, 0);
ICUNIT_ASSERT_EQUAL(ret, fpid, ret); ICUNIT_ASSERT_EQUAL(ret, fpid, ret);
ICUNIT_ASSERT_EQUAL(WEXITSTATUS(status), 0, WEXITSTATUS(status)); ICUNIT_ASSERT_EQUAL(WEXITSTATUS(status), 0, WEXITSTATUS(status));

View File

@@ -37,6 +37,7 @@ static UINT32 testcase(VOID)
time_t currtime; time_t currtime;
struct tm *timer = {nullptr}; struct tm *timer = {nullptr};
char buffer[80]; char buffer[80];
//locale_t loc = malloc(sizeof(locale_t);
time(&currtime); time(&currtime);
timer = localtime(&currtime); timer = localtime(&currtime);
@@ -45,17 +46,17 @@ static UINT32 testcase(VOID)
printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH")); printf("getenv MUSL_LOCPATH=%s\n", getenv("MUSL_LOCPATH"));
printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8")); printf("Locale is: %s\n", setlocale(LC_TIME, "en_US.UTF-8"));
(void)strftime(buffer, sizeof(buffer), "%c", timer); strftime(buffer, 80, "%c", timer);
printf("Date is: %s\n", buffer); printf("Date is: %s\n", buffer);
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8")); printf("Locale is: %s\n", setlocale(LC_TIME, "zh_CN.UTF-8"));
(void)strftime(buffer, sizeof(buffer), "%c", timer); strftime(buffer, 80, "%c", timer);
printf("Date is: %s\n", buffer); printf("Date is: %s\n", buffer);
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
printf("Locale is: %s\n", setlocale(LC_TIME, "")); printf("Locale is: %s\n", setlocale(LC_TIME, ""));
(void)strftime(buffer, sizeof(buffer), "%c", timer); strftime(buffer, 80, "%c", timer);
printf("Date is: %s\n", buffer); printf("Date is: %s\n", buffer);
ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1); ICUNIT_ASSERT_NOT_EQUAL_NULL(buffer, NULL, -1);
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");

View File

@@ -145,6 +145,26 @@ HWTEST_F(MiscTest, ItTestMisc009, TestSize.Level0)
ItTestMisc009(); ItTestMisc009();
} }
/* *
* @tc.name: IT_TEST_MISC_010
* @tc.desc: function for MiscTest
* @tc.type: FUNC
*/
/*HWTEST_F(MiscTest, ItTestMisc010, TestSize.Level0)
{
ItTestMisc010();
}*/
/* *
* @tc.name: IT_TEST_MISC_011
* @tc.desc: function for MiscTest
* @tc.type: FUNC
*/
/*HWTEST_F(MiscTest, ItTestMisc011, TestSize.Level0)
{
ItTestMisc011();
}*/
/* * /* *
* @tc.name: IT_TEST_MISC_012 * @tc.name: IT_TEST_MISC_012
* @tc.desc: function for MiscTest * @tc.desc: function for MiscTest
@@ -154,6 +174,16 @@ HWTEST_F(MiscTest, ItTestMisc012, TestSize.Level0)
{ {
ItTestMisc012(); ItTestMisc012();
} }
/* *
* @tc.name: IT_TEST_MISC_013
* @tc.desc: function for MiscTest
* @tc.type: FUNC
*/
/*HWTEST_F(MiscTest, ItTestMisc013, TestSize.Level0)
{
ItTestMisc013();
}*/
#endif #endif
} // namespace OHOS } // namespace OHOS

View File

@@ -56,7 +56,7 @@
#define TEST_HwiTrigger(HWI_NUM_TEST) #define TEST_HwiTrigger(HWI_NUM_TEST)
#define LOS_TaskLock() #define LOS_TaskLock()
#define LOS_TaskUnlock() #define LOS_TaskUnlock()
#define LOS_MS2Tick(ms) ((ms) / 10) #define LOS_MS2Tick(ms) (ms / 10)
#define OS_TASK_PRIORITY_HIGHEST 0 #define OS_TASK_PRIORITY_HIGHEST 0
#define OS_TASK_PRIORITY_LOWEST 31 #define OS_TASK_PRIORITY_LOWEST 31
@@ -228,7 +228,12 @@ struct testdata {
}; };
extern struct testdata g_td; extern struct testdata g_td;
extern unsigned int sleep(unsigned int seconds);
extern unsigned int alarm(unsigned int seconds);
extern int map_errno(UINT32 err); extern int map_errno(UINT32 err);
extern long sysconf(int name);
extern void posix_signal_start(void); extern void posix_signal_start(void);
VOID ScenarInit(VOID); VOID ScenarInit(VOID);

View File

@@ -34,6 +34,7 @@ static void *pthread_f01(void *tmp)
{ {
int rc = 0; int rc = 0;
g_testCount++; g_testCount++;
// printf("www\n");
/* acquire the mutex */ /* acquire the mutex */
rc = pthread_mutex_lock(&g_pthreadMutexTest1); rc = pthread_mutex_lock(&g_pthreadMutexTest1);
@@ -68,7 +69,7 @@ static UINT32 Testcase(VOID)
/* Let the other thread run */ /* Let the other thread run */
LosTaskDelay(2); LosTaskDelay(2);
ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount); // 2: expected value of g_testCount ICUNIT_ASSERT_EQUAL(g_testCount, 2, g_testCount);
/* Try to destroy the cond var. This should return an error */ /* Try to destroy the cond var. This should return an error */
rc = pthread_cond_destroy(&g_pthreadCondTest1); rc = pthread_cond_destroy(&g_pthreadCondTest1);
@@ -78,7 +79,7 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(rc, 0, rc); ICUNIT_ASSERT_EQUAL(rc, 0, rc);
LosTaskDelay(2); LosTaskDelay(2);
ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount); // 4: expected value of g_testCount ICUNIT_ASSERT_EQUAL(g_testCount, 4, g_testCount);
rc = pthread_cond_destroy(&g_pthreadCondTest1); rc = pthread_cond_destroy(&g_pthreadCondTest1);
ICUNIT_ASSERT_EQUAL(rc, 0, rc); ICUNIT_ASSERT_EQUAL(rc, 0, rc);

View File

@@ -51,6 +51,10 @@ static UINT32 Testcase(VOID)
tmp = pthread_equal(a, b); tmp = pthread_equal(a, b);
// pthread_join(a, NULL);
// pthread_detach(a);
pthread_attr_init(&aa); pthread_attr_init(&aa);
pthread_attr_getdetachstate(&aa, &detachstate); pthread_attr_getdetachstate(&aa, &detachstate);
@@ -59,6 +63,19 @@ static UINT32 Testcase(VOID)
pthread_attr_destroy(&aa); pthread_attr_destroy(&aa);
// pthread_mutex_init(&c, NULL);
// pthread_mutex_destroy(&c);
// pthread_mutex_lock(&c);
// pthread_mutex_trylock(&c);
// pthread_mutex_unlock(&c);
// pthread_mutexattr_init(&c);
// pthread_mutexattr_destroy(&c);
ret = pthread_join(aThread, NULL); ret = pthread_join(aThread, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -36,6 +36,8 @@ static void *ThreadF01(void *arg)
/* Shouldn't reach here. If we do, then the pthread_cancel() /* Shouldn't reach here. If we do, then the pthread_cancel()
* function did not succeed. */ * function did not succeed. */
// uart_printf_func("Could not send cancel request correctly\n");
// ICUNIT_TRACK_EQUAL(1, 0, errno);
pthread_exit(nullptr); pthread_exit(nullptr);
return NULL; return NULL;
} }
@@ -60,6 +62,7 @@ static UINT32 Testcase(VOID)
ret = pthread_join(newTh, (void **)&temp); ret = pthread_join(newTh, (void **)&temp);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
// ICUNIT_ASSERT_EQUAL(temp, (UINTPTR)PTHREAD_CANCELED, temp);
return PTHREAD_NO_ERROR; return PTHREAD_NO_ERROR;
} }

View File

@@ -34,6 +34,7 @@ static void *ThreadF01(void *arg)
{ {
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
// while (1)
sleep(1); sleep(1);
pthread_exit(nullptr); pthread_exit(nullptr);
@@ -47,6 +48,7 @@ static UINT32 Testcase(VOID)
pthread_t a; pthread_t a;
/* SIGALRM will be sent in 5 seconds. */ /* SIGALRM will be sent in 5 seconds. */
// alarm(5);//alarm NOT SUPPORT
/* Create a new thread. */ /* Create a new thread. */
if (pthread_create(&a, NULL, ThreadF01, NULL) != 0) { if (pthread_create(&a, NULL, ThreadF01, NULL) != 0) {
@@ -59,6 +61,7 @@ static UINT32 Testcase(VOID)
/* If 'main' has reached here, then the test passed because it means /* If 'main' has reached here, then the test passed because it means
* that the thread is truly asynchronise, and main isn't waiting for * that the thread is truly asynchronise, and main isn't waiting for
* it to return in order to move on. */ * it to return in order to move on. */
// printf("Test PASSED\n");
ret = pthread_join(a, &temp); ret = pthread_join(a, &temp);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. * Copyright (c) 2013-2019 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, * Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met: * are permitted provided that the following conditions are met:
@@ -41,7 +41,7 @@
#define CLOCK_RES_NSEC 1000 #define CLOCK_RES_NSEC 1000
#define CLOCK_COARSE_RES_SEC 0 #define CLOCK_COARSE_RES_SEC 0
#define CLOCK_COARSE_RES_NSEC 1000000 #define CLOCK_COARSE_RES_NSEC 1000000
#define CLOCK_GET_CPU_CLOCKID(pid) ((-(pid) - 1) * 8U + 2) #define CLOCK_GET_CPU_CLOCKID(pid) ((-pid - 1) * 8U + 2)
void ClockTestSmoke(void); void ClockTestSmoke(void);
void ClockTest001(void); void ClockTest001(void);

View File

@@ -65,7 +65,7 @@ static int GetHostByAddrTest(void)
addr = gethostbyaddr(&ia, sizeof ia, AF_INET); addr = gethostbyaddr(&ia, sizeof ia, AF_INET);
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
RecoveryFileEnv(pathList, file_number);     RecoveryFileEnv(pathList, file_number);
return ICUNIT_SUCCESS; return ICUNIT_SUCCESS;
} }

View File

@@ -176,5 +176,16 @@ HWTEST_F(NetSocketTest, NetSocketTest012, TestSize.Level0)
NetSocketTest012(); NetSocketTest012();
} }
/* *
* @tc.name: NetSocketTest013
* @tc.desc: function for NetSocketTest
* @tc.type: FUNC
*/
/*
HWTEST_F(NetSocketTest, NetSocketTest013, TestSize.Level0)
{
//NetSocketTest013(); // broadcast to self to be supported.
}
*/
#endif #endif
} }

View File

@@ -131,6 +131,7 @@ def parse_user_pc_ulr(excinfo_file, rootfs_dir, string, addr2line_cmd, objdump_c
ret = commands.getoutput(cmd) ret = commands.getoutput(cmd)
print(ret) print(ret)
cmd = "%s%s%s %s" % (addr2line_cmd, rootfs_dir, strlist[4], strlist[6]) cmd = "%s%s%s %s" % (addr2line_cmd, rootfs_dir, strlist[4], strlist[6])
#print(cmd)
ret = commands.getoutput(cmd) ret = commands.getoutput(cmd)
ret = ret.split('\n') ret = ret.split('\n')
print("<%s>%s<%s><%s>\n" % (string, ret[0], strlist[6], strlist[4])) print("<%s>%s<%s><%s>\n" % (string, ret[0], strlist[6], strlist[4]))

View File

@@ -38,7 +38,7 @@ get_line()
{ {
SYM_ADDR=$(echo $1 | awk '{print $2}') SYM_ADDR=$(echo $1 | awk '{print $2}')
ELF_OFFSET=$(echo ${SYM_ADDR} | cut -d '[' -f2 | cut -d ']' -f1) ELF_OFFSET=$(echo ${SYM_ADDR} | cut -d '[' -f2 | cut -d ']' -f1)
FILE_LINE=$(${ADDR2LINE} -f -e $2 ${ELF_OFFSET} | awk 'NR==2') FILE_LINE=$(${ADDR2LINE} -f -e $2 ${ELF_OFFSET} | awk 'NR==2'`)
if [[ "${FILE_LINE}" == *"?"* ]]; then if [[ "${FILE_LINE}" == *"?"* ]]; then
typeset ELF_OFFSET=$((ELF_OFFSET+LOAD_BASE)) typeset ELF_OFFSET=$((ELF_OFFSET+LOAD_BASE))
ELF_OFFSET=$(echo "obase=16;${ELF_OFFSET}" | bc) ELF_OFFSET=$(echo "obase=16;${ELF_OFFSET}" | bc)