Compare commits

..

11 Commits

Author SHA1 Message Date
openharmony_ci
94eb83b74c !1062 【挑单】time相关系统调用内核栈信息泄露排查
Merge pull request !1062 from zhushengle/cherry-pick-1668148174
2022-11-15 12:08:38 +00:00
zhushengle
d8d3035084 fixed 0b05a46 from https://gitee.com/zhushengle/kernel_liteos_a/pulls/1061
task: time相关系统调用内核栈信息泄露排查

解决方案:
    在涉及从内核拷贝数据到用户态的场景时,先将内核的数据进行清零操作,再填充内核数据
Close #I60M1P

Signed-off-by: zhushengle <zhushengle@huawei.com>
Change-Id: Ia61d4e39b9e190accea477ff5b361e41d0eed2af
2022-11-11 06:29:34 +00:00
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
27 changed files with 115 additions and 119 deletions

View File

@@ -49,7 +49,7 @@ ShellCB *OsGetShellCb()
return g_shellCB;
}
static void ShellDeinit(ShellCB *shellCB)
void ShellDeinit(ShellCB *shellCB)
{
(void)pthread_mutex_destroy(&shellCB->historyMutex);
(void)pthread_mutex_destroy(&shellCB->keyMutex);
@@ -65,23 +65,27 @@ static int OsShellCreateTask(ShellCB *shellCB)
ret = sched_getparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
param.sched_priority = SHELL_PROCESS_PRIORITY_INIT;
ret = sched_setparam(getpid(), &param);
if (ret != SH_OK) {
return ret;
goto OUT;
}
ret = ShellTaskInit(shellCB);
if (ret != SH_OK) {
return ret;
goto OUT;
}
shellCB->shellEntryHandle = pthread_self();
return 0;
OUT:
ShellDeinit(shellCB);
return ret;
}
static int DoShellExec(char **argv)
@@ -144,7 +148,7 @@ int main(int argc, char **argv)
shellCB = (ShellCB *)malloc(sizeof(ShellCB));
if (shellCB == NULL) {
return SH_NOK;
goto ERR_OUT1;
}
ret = memset_s(shellCB, sizeof(ShellCB), 0, sizeof(ShellCB));
if (ret != SH_OK) {
@@ -172,9 +176,7 @@ int main(int argc, char **argv)
g_shellCB = shellCB;
ret = OsShellCreateTask(shellCB);
if (ret != SH_OK) {
ShellDeinit(shellCB);
g_shellCB = NULL;
return ret;
goto ERR_OUT3;
}
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);
if (ret < 0) {
VnodeDrop();
PRINT_ERR("disk_init : %s, failed to find the vnode, ERRNO=%d\n", diskName, ret);
ret = ENOENT;
goto DISK_FIND_ERROR;
}
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
--- 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
@@ -9,335 +9,30 @@
@@ -9,325 +9,34 @@
* 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,
- struct page **pagep, void **fsdata);
-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
-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,
+ struct jffs2_inode_info *f,
+ unsigned long offset,
+ 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,
- .open = generic_file_open,
- .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_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
- 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",
- __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);
- 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);
- ret = jffs2_do_readpage_unlock(pg->mapping->host, pg);
- mutex_unlock(&f->sem);
- return ret;
+ return ERR_PTR(ret);
+ return gc_buffer;
}
-
-static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned flags,
- 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 inode *inode = mapping->host;
- 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;
- uint32_t pageofs = index << PAGE_SHIFT;
- int ret = 0;
-
- pg = grab_cache_page_write_begin(mapping, index, flags);
- if (!pg)
- return -ENOMEM;
- *pagep = pg;
-
- jffs2_dbg(1, "%s()\n", __func__);
-
- if (pageofs > inode->i_size) {
- /* 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_full_dnode *fn;
- 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,
- ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
- if (ret)
- goto out_err;
- goto out_page;
-
- mutex_lock(&f->sem);
- 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);
- jffs2_complete_reservation(c);
- mutex_unlock(&f->sem);
- goto out_err;
- goto out_page;
- }
- ret = jffs2_add_full_dnode_to_inode(c, f, fn);
- 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_complete_reservation(c);
- mutex_unlock(&f->sem);
- goto out_err;
- goto out_page;
- }
- jffs2_complete_reservation(c);
- 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
- * the whole page write case until jffs2_write_end can handle the
- * 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);
- ret = jffs2_do_readpage_nolock(inode, pg);
- mutex_unlock(&f->sem);
- if (ret) {
- unlock_page(pg);
- put_page(pg);
- goto release_sem;
- }
- if (ret)
- goto out_page;
- }
- jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
-
-release_sem:
- mutex_unlock(&c->alloc_sem);
-out_err:
- 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,
- loff_t pos, unsigned len, unsigned copied,
- struct page *pg, void *fsdata)
@@ -2661,8 +2653,7 @@ diff -Nupr old/fs/jffs2/file.c new/fs/jffs2/file.c
- unlock_page(pg);
- put_page(pg);
- return writtenlen > 0 ? writtenlen : ret;
+ /* Do nothing */
}
-}
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
+++ 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;
if (LOS_CopyFromKernel(buffer, bufLen, (const char *)f->target, cnt) != 0) {
cnt = 0;
LOS_MuxUnlock(&g_jffs2FsLock);
return -EFAULT;
}

View File

@@ -353,7 +353,7 @@ static struct file_operations_vfs g_errorFileOps = {
.unlink = ErrorFopUnlink,
};
static struct Mount* GetDevMountPoint(const struct Vnode *dev)
static struct Mount* GetDevMountPoint(struct Vnode *dev)
{
struct Mount *mnt = NULL;
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 file *filep = NULL;
@@ -435,7 +435,7 @@ static void VnodeTryFree(struct Vnode *vnode)
vnode->fop = &g_errorFileOps;
}
static void VnodeTryFreeAll(const struct Mount *mount)
static void VnodeTryFreeAll(struct Mount *mount)
{
struct Vnode *vnode = 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 {
writepart = bytestowrite - ret;
curbuf += writepart;
totallen -= writepart;
break;
}
}

View File

@@ -70,7 +70,7 @@ VOID OsVmPhysDump(VOID);
VOID OsVmPhysUsedInfoGet(UINT32 *usedCount, UINT32 *totalCount);
INT32 OsRegionOverlapCheck(LosVmSpace *space, LosVmMapRegion *region);
VOID OsDumpPte(VADDR_T vaddr);
LosProcessCB *OsGetPIDByAspace(const LosVmSpace *space);
LosProcessCB *OsGetPIDByAspace(LosVmSpace *space);
CHAR *OsArchFlagsToStr(const UINT32 archFlags);
#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 *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 OsDelMapInfo(LosVmMapRegion *region, LosVmPgFault *pgFault, BOOL cleanDirty);
VOID OsFileCacheFlush(struct page_mapping *mapping);
@@ -208,7 +208,7 @@ VOID OsDeletePageCacheLru(LosFilePage *page);
VOID OsPageRefDecNoLock(LosFilePage *page);
VOID OsPageRefIncLocked(LosFilePage *page);
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
VOID ResetPageCacheHitInfo(int *try, int *hit);

View File

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

View File

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

View File

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

View File

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

View File

@@ -125,10 +125,10 @@ VOID OsAddMapInfo(LosFilePage *page, LosArchMmu *archMmu, VADDR_T vaddr)
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;
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) {
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;
}
VOID OsMarkPageDirty(LosFilePage *fpage, const LosVmMapRegion *region, INT32 off, INT32 len)
VOID OsMarkPageDirty(LosFilePage *fpage, LosVmMapRegion *region, INT32 off, INT32 len)
{
if (region != NULL) {
OsSetPageDirty(fpage->vmPage);

View File

@@ -233,7 +233,7 @@ LosVmSpace *OsCreateUserVmSpace(VOID)
return space;
}
STATIC BOOL OsVmSpaceParamCheck(const LosVmSpace *vmSpace)
STATIC BOOL OsVmSpaceParamCheck(LosVmSpace *vmSpace)
{
if (vmSpace == NULL) {
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)
{
struct timespec now = {0};
(void)clock_gettime(CLOCK_REALTIME, &now);
struct timespec 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->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
* 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;
if (!idsNr) {

View File

@@ -300,7 +300,7 @@ UINT32 LOS_PmRegister(LOS_PmNodeType type, VOID *node)
return LOS_EINVAL;
}
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, const LosPmDevice *device)
STATIC UINT32 OsPmDeviceUnregister(LosPmCB *pm, LosPmDevice *device)
{
LOS_SpinLock(&g_pmSpin);
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 */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &first);
nsent = 0;
for (nsent = 0; nsent < ping6_params.pingcount; nsent++) {
/* capture the start tick to calculate rtt */
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &start);
@@ -3168,6 +3170,7 @@ void netstat_internal(void *ctx)
}
/* For listen PCBs */
recvQlen = 0;
sendQlen = 0;
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;
u32_t ret = LOS_NOK;
if (argc == 2) { /* 2: Number of command parameters */
if (argc == 2) {
if (!strcmp("-i", argv[1])) {
/* netdebug sock -i */
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;
}
} else if (argc == 3) { /* 3: Number of command parameters */
} else if (argc == 3) {
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) {
debug_socket_info(idx, 1, 1);
ret = LOS_OK;

View File

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

View File

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

View File

@@ -39,7 +39,8 @@ extern "C" {
static UINT32 TaskF02(VOID)
{
UINT32 ret = OS_ERROR, cpupUse;
UINT32 ret = OS_ERROR;
UINT32 cpupUse;
g_cpupTestCount++;
// 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);
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.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
taskInitParam.pcName = "SmpCpup005_task04";

View File

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

View File

@@ -36,16 +36,13 @@
static int TestThread(void)
{
int ret;
int *test = nullptr; // For triggering an exceptioin
pid_t pid = fork();
ICUNIT_ASSERT_WITHIN_EQUAL(pid, 0, INVALID_PROCESS_ID, pid);
if (pid == 0) {
*test = 0x1; // Deliberately trigger an exceptioin
while (1) {
}
}
*test = 0x1; // Deliberately trigger an exceptioin
ret = waitpid(pid, NULL, 0);
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) 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,46 +31,39 @@
#include "it_test_shm.h"
#define SHMID_MAX 192
#define SHM_FLAG 0777
static int Testcase(VOID)
{
int shmid[SHMID_MAX + 1] = {-1};
int ret;
int i;
struct shm_info shmInfo;
int leftShmIds;
ret = shmctl(0, SHM_INFO, reinterpret_cast<struct shmid_ds *>(&shmInfo));
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
shmid[0] = shmget((key_t)0x1234, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[0], -1, shmid[0]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
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]);
ret = shmctl(shmid[0], IPC_RMID, NULL);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
for (i = 0; i < leftShmIds; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
for (i = 0; i < SHMID_MAX; i++) {
shmid[i] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
ICUNIT_ASSERT_NOT_EQUAL(shmid[i], -1, shmid[i]);
}
shmid[leftShmIds] = shmget(IPC_PRIVATE, PAGE_SIZE, SHM_FLAG | IPC_CREAT);
ICUNIT_ASSERT_EQUAL(shmid[leftShmIds], -1, shmid[leftShmIds]);
shmid[SHMID_MAX] = shmget(IPC_PRIVATE, PAGE_SIZE, 0777 | IPC_CREAT);
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);
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);
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
}

View File

@@ -1,6 +1,6 @@
/*
* 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,
* are permitted provided that the following conditions are met:
@@ -41,7 +41,7 @@
#define CLOCK_RES_NSEC 1000
#define CLOCK_COARSE_RES_SEC 0
#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 ClockTest001(void);

View File

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