Compare commits

...

10 Commits

Author SHA1 Message Date
openharmony_ci
b1a7711e15 !1025 Werror开启产生的告警
Merge pull request !1025 from 乔克叔叔/werrror
2023-02-21 06:58:16 +00:00
liuwenxin
3e83ce79c2 fix:告警清理包含三方库屏蔽
【修改说明】此次开启Werror,解决告警产生的报错,以及屏蔽三方库告警

 close #I6ELI9
Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-02-21 10:35:56 +08:00
openharmony_ci
2cadd65301 !1023 fix: pthread_create时序调整
Merge pull request !1023 from Zhaotianyu/20230210pthread_create
2023-02-10 10:31:43 +00:00
arvinzzz
f038492dbc fix: pthread_create内部逻辑时序调整
在线程创建成功后,pthread_create内部先将函数返回值设置好,再进行TaskResume就绪调度状态

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I795c115da612123b67f34cdc57e85eac955bbc08
2023-02-10 17:42:17 +08:00
openharmony_ci
e74deedba3 !1005 Werror开启告警清理
Merge pull request !1005 from 乔克叔叔/second
2023-02-07 03:08:26 +00:00
openharmony_ci
24f52e0259 !987 LMS特性安全合规整改
Merge pull request !987 from JerryH/lms
2023-02-02 01:42:12 +00:00
huangjieliang
d4df4d1e54 feat:LMS模块及堆内存模块非安全函数安全合规整改
Close #I68LEO

Signed-off-by: huangjieliang <huangjieliang@huawei.com>
Change-Id: I38b859dcd1856f27d4577f5311c920d2d8b96385
2023-02-01 16:49:44 +08:00
openharmony_ci
2d1e7e8c29 !1012 Fix : 内核告警清理
Merge pull request !1012 from yinjiaming/warning
2023-02-01 06:33:49 +00:00
liuwenxin
a96f535cd3 fix:Werror开启告警清理
清理Werror开启产生的告警

close:#I68YDW

Signed-off-by: liuwenxin <liuwenxin11@huawei.com>
2023-01-30 10:10:07 +08:00
yinjiaming
db32ad90bf Fix:内核告警清理
清除内核代码中的敏感词

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I734525c036fcfe481d0781d459bc273ef8224791
2023-01-16 16:17:09 +08:00
29 changed files with 100 additions and 71 deletions

View File

@@ -43,7 +43,7 @@
judgment condition to support multiple code sections. */
WEAK BOOL OsStackDataIsCodeAddr(UINTPTR value)
{
if ((value >= CODE_START_ADDR) && (value < CODE_END_ADDR)) {
if ((value > CODE_START_ADDR) && (value < CODE_END_ADDR)) {
return TRUE;
}
return FALSE;

View File

@@ -93,20 +93,25 @@ EXIT:
STATIC LmsMemListNode *OsLmsGetPoolNodeFromAddr(UINTPTR addr)
{
LmsMemListNode *current = NULL;
LmsMemListNode *previous = NULL;
LOS_DL_LIST *listHead = &g_lmsCheckPoolList;
if (LOS_ListEmpty(&g_lmsCheckPoolList)) {
goto EXIT;
return NULL;
}
LOS_DL_LIST_FOR_EACH_ENTRY(current, listHead, LmsMemListNode, node) {
if ((addr >= current->poolAddr) && (addr < current->poolAddr + current->poolSize)) {
return current;
if ((addr < current->poolAddr) || (addr >= (current->poolAddr + current->poolSize))) {
continue;
}
if ((previous == NULL) ||
((previous->poolAddr <= current->poolAddr) &&
((current->poolAddr + current->poolSize) <= (previous->poolAddr + previous->poolSize)))) {
previous = current;
}
}
EXIT:
return NULL;
return previous;
}
STATIC LmsMemListNode *OsLmsCheckPoolCreate(VOID)
@@ -136,18 +141,12 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
LMS_LOCK(intSave);
lmsPoolNode = OsLmsGetPoolNodeFromAddr((UINTPTR)pool);
if (lmsPoolNode != NULL) { /* if pool range already on checklist */
if (lmsPoolNode->poolAddr != (UINTPTR)pool) { /* pool is a subset of lmsPoolNode->poolAddr */
/* do not add it again, just return */
PRINT_DEBUG("[LMS]pool %p already on lms checklist !\n", pool);
LMS_UNLOCK(intSave);
return size; /* return size indicate the shadow memory init successful */
} else { /* Re-initialize the same pool, maybe with different size */
/* delete the old node, then add a new one */
lmsPoolNode->used = LMS_POOL_UNUSED;
LOS_ListDelete(&(lmsPoolNode->node));
}
lmsPoolNode = OsLmsGetPoolNode(pool);
if (lmsPoolNode != NULL) { /* if pool already on checklist */
/* Re-initialize the same pool, maybe with different size */
/* delete the old node, then add a new one */
lmsPoolNode->used = LMS_POOL_UNUSED;
LOS_ListDelete(&(lmsPoolNode->node));
}
lmsPoolNode = OsLmsCheckPoolCreate();
@@ -163,7 +162,7 @@ UINT32 LOS_LmsCheckPoolAdd(const VOID *pool, UINT32 size)
lmsPoolNode->shadowStart = (UINTPTR)poolAddr + realSize;
lmsPoolNode->shadowSize = poolAddr + size - lmsPoolNode->shadowStart;
/* init shadow value */
(VOID)memset((VOID *)lmsPoolNode->shadowStart, LMS_SHADOW_AFTERFREE_U8, lmsPoolNode->shadowSize);
(VOID)memset_s((VOID *)lmsPoolNode->shadowStart, lmsPoolNode->shadowSize, LMS_SHADOW_AFTERFREE_U8, lmsPoolNode->shadowSize);
LOS_ListAdd(&g_lmsCheckPoolList, &(lmsPoolNode->node));
@@ -193,10 +192,11 @@ RELEASE:
VOID OsLmsInit(VOID)
{
(VOID)memset(g_lmsCheckPoolArray, 0, sizeof(g_lmsCheckPoolArray));
(VOID)memset_s(g_lmsCheckPoolArray, sizeof(g_lmsCheckPoolArray), 0, sizeof(g_lmsCheckPoolArray));
LOS_ListInit(&g_lmsCheckPoolList);
static LmsHook hook = {
.init = LOS_LmsCheckPoolAdd,
.deInit = LOS_LmsCheckPoolDel,
.mallocMark = OsLmsLosMallocMark,
.freeMark = OsLmsLosFreeMark,
.simpleMark = OsLmsSimpleMark,
@@ -609,7 +609,7 @@ VOID OsLmsReportError(UINTPTR p, UINT32 size, UINT32 errMod)
LMS_LOCK(intSave);
g_checkDepth += 1;
(VOID)memset(&info, 0, sizeof(LmsAddrInfo));
(VOID)memset_s(&info, sizeof(LmsAddrInfo), 0, sizeof(LmsAddrInfo));
PRINT_ERR("***** Kernel Address Sanitizer Error Detected Start *****\n");

View File

@@ -95,6 +95,7 @@ typedef struct {
typedef struct {
UINT32 (*init)(const VOID *pool, UINT32 size);
VOID (*deInit)(const VOID *pool);
VOID (*mallocMark)(const VOID *curNodeStart, const VOID *nextNodeStart, UINT32 nodeHeadSize);
VOID (*freeMark)(const VOID *curNodeStart, const VOID *nextNodeStart, UINT32 nodeHeadSize);
VOID (*simpleMark)(UINTPTR startAddr, UINTPTR endAddr, UINT32 value);
@@ -133,4 +134,4 @@ extern SANITIZER_INTERFACE_ATTRIBUTE VOID __asan_handle_no_return(VOID);
#endif /* __cplusplus */
#endif /* __cplusplus */
#endif /* _LOS_LMS_PRI_H */
#endif /* _LOS_LMS_PRI_H */

View File

@@ -221,10 +221,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

@@ -453,7 +453,7 @@ extern UINT32 LOS_QueueCreateStatic(const CHAR *queueName,
* first.</li>
* <li>bufferAddr stores the obtained data.</li>
* <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The argument timeOut is a relative time.</li>
* </ul>
*
@@ -498,7 +498,7 @@ extern UINT32 LOS_QueueReadCopy(UINT32 queueID,
* <ul>
* <li>The specific queue should be created firstly.</li>
* <li>Do not read or write a queue in unblocking modes such as interrupt.</li>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The data to be written is of the size specified by bufferSize and is stored at the address specified by
* BufferAddr.</li>
* <li>The argument timeOut is a relative time.</li>
@@ -547,7 +547,7 @@ extern UINT32 LOS_QueueWriteCopy(UINT32 queueID,
* read first.</li>
* <li>bufferAddr stores the obtained data address.</li>
* <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The argument timeOut is a relative time.</li>
* <li>The bufferSize is not really used in LOS_QueueRead, because the interface is only used to
* obtain the address of data.</li>
@@ -592,7 +592,7 @@ extern UINT32 LOS_QueueRead(UINT32 queueID,
* <ul>
* <li>The specific queue should be created firstly.</li>
* <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
* BufferAddr is to be written.</li>
* <li>The argument timeOut is a relative time.</li>
@@ -639,7 +639,7 @@ extern UINT32 LOS_QueueWrite(UINT32 queueID,
* @attention
* <ul>
* <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
* BufferAddr is to be written.</li>
* <li>The argument timeOut is a relative time.</li>
@@ -686,7 +686,7 @@ extern UINT32 LOS_QueueWriteHead(UINT32 queueID,
* @attention
* <ul>
* <li>Do not read or write a queue in unblocking modes such as an interrupt.</li>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The address of the data of the size specified by bufferSize and stored at the address specified by
* BufferAddr is to be written.</li>
* <li>The argument timeOut is a relative time.</li>
@@ -889,7 +889,7 @@ extern LosQueueCB *g_allQueue;
* @attention
* <ul>
* <li>Do not alloc memory in unblocking modes such as interrupt.</li>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* <li>The argument timeOut is a relative time.</li>
* </ul>
*
@@ -913,7 +913,7 @@ extern VOID *OsQueueMailAlloc(UINT32 queueID, VOID *mailPool, UINT32 timeOut);
* This API is used to free a stationary memory for a mail according to queueID.
* @attention
* <ul>
* <li>This API cannot be called before the Huawei LiteOS is initialized.</li>
* <li>This API cannot be called before the kernel is initialized.</li>
* </ul>
*
* @param queueID [IN] Queue ID. The value range is [1,LOSCFG_BASE_IPC_QUEUE_LIMIT].

View File

@@ -474,7 +474,7 @@ RETRY:
OsMemFreeNodeAdd(pool, (struct OsMemFreeNodeHead *)newNode);
endNode = OS_MEM_END_NODE(newNode, size);
(VOID)memset(endNode, 0, sizeof(*endNode));
(VOID)memset_s(endNode, sizeof(*endNode), 0, sizeof(*endNode));
endNode->ptr.next = NULL;
OS_MEM_SET_MAGIC(endNode);
OsMemSentinelNodeSet(endNode, NULL, 0);
@@ -584,7 +584,8 @@ STATIC INLINE VOID OsMemLeakCheckInfoRecord(struct OsMemNodeHead *node)
STATIC INLINE VOID OsMemLeakCheckInit(VOID)
{
(VOID)memset(g_leakCheckRecord, 0, sizeof(struct OsMemLeakCheckInfo) * LOSCFG_MEM_LEAKCHECK_RECORD_MAX_NUM);
(VOID)memset_s(g_leakCheckRecord, sizeof(struct OsMemLeakCheckInfo) * LOSCFG_MEM_LEAKCHECK_RECORD_MAX_NUM,
0, sizeof(struct OsMemLeakCheckInfo) * LOSCFG_MEM_LEAKCHECK_RECORD_MAX_NUM);
g_leakCheckRecordCnt = 0;
}
@@ -858,6 +859,9 @@ STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
struct OsMemPoolHead *poolHead = (struct OsMemPoolHead *)pool;
struct OsMemNodeHead *newNode = NULL;
struct OsMemNodeHead *endNode = NULL;
(VOID)memset_s(poolHead, size, 0, sizeof(struct OsMemPoolHead));
#ifdef LOSCFG_KERNEL_LMS
UINT32 resize = 0;
if (g_lms != NULL) {
@@ -869,7 +873,6 @@ STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
size = (resize == 0) ? size : resize;
}
#endif
(VOID)memset(poolHead, 0, sizeof(struct OsMemPoolHead));
poolHead->info.pool = pool;
poolHead->info.totalSize = size;
@@ -907,9 +910,14 @@ STATIC UINT32 OsMemPoolInit(VOID *pool, UINT32 size)
}
#if (LOSCFG_MEM_MUL_POOL == 1)
STATIC VOID OsMemPoolDeinit(VOID *pool)
STATIC VOID OsMemPoolDeInit(VOID *pool, UINT32 size)
{
(VOID)memset(pool, 0, sizeof(struct OsMemPoolHead));
#ifdef LOSCFG_KERNEL_LMS
if (g_lms != NULL) {
g_lms->deInit(pool);
}
#endif
(VOID)memset_s(pool, size, 0, sizeof(struct OsMemPoolHead));
}
STATIC UINT32 OsMemPoolAdd(VOID *pool, UINT32 size)
@@ -988,7 +996,7 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
#if (LOSCFG_MEM_MUL_POOL == 1)
if (OsMemPoolAdd(pool, size)) {
(VOID)OsMemPoolDeinit(pool);
(VOID)OsMemPoolDeInit(pool, size);
return LOS_NOK;
}
#endif
@@ -1001,17 +1009,23 @@ UINT32 LOS_MemInit(VOID *pool, UINT32 size)
#if (LOSCFG_MEM_MUL_POOL == 1)
UINT32 LOS_MemDeInit(VOID *pool)
{
if (pool == NULL) {
struct OsMemPoolHead *tmpPool = (struct OsMemPoolHead *)pool;
if (tmpPool == NULL) {
return LOS_NOK;
}
if (OsMemPoolDelete(pool)) {
if ((tmpPool->info.pool != pool) || (tmpPool->info.totalSize <= OS_MEM_MIN_POOL_SIZE)) {
return LOS_NOK;
}
OsMemPoolDeinit(pool);
if (OsMemPoolDelete(tmpPool)) {
return LOS_NOK;
}
OsHookCall(LOS_HOOK_TYPE_MEM_DEINIT, pool);
OsMemPoolDeInit(tmpPool, tmpPool->info.totalSize);
OsHookCall(LOS_HOOK_TYPE_MEM_DEINIT, tmpPool);
return LOS_OK;
}
@@ -1950,7 +1964,7 @@ UINT32 LOS_MemInfoGet(VOID *pool, LOS_MEM_POOL_STATUS *poolStatus)
return LOS_NOK;
}
(VOID)memset(poolStatus, 0, sizeof(LOS_MEM_POOL_STATUS));
(VOID)memset_s(poolStatus, sizeof(LOS_MEM_POOL_STATUS), 0, sizeof(LOS_MEM_POOL_STATUS));
OsAllMemNodeDoHandle(pool, OsMemNodeInfoGetHandle, (VOID *)poolStatus);
@@ -2232,7 +2246,7 @@ STATIC VOID OsMemExcInfoGetSub(struct OsMemPoolHead *pool, MemInfoCB *memExcInfo
UINT32 taskID = OS_TASK_ERRORID;
UINT32 intSave = 0;
(VOID)memset(memExcInfo, 0, sizeof(MemInfoCB));
(VOID)memset_s(memExcInfo, sizeof(MemInfoCB), 0, sizeof(MemInfoCB));
MEM_LOCK(pool, intSave);
memExcInfo->type = MEM_MANG_MEMORY;

View File

@@ -27,6 +27,7 @@
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import("//kernel/liteos_m/config.gni")
import("//kernel/liteos_m/liteos.gni")
config("include") {
@@ -36,6 +37,8 @@ config("include") {
if (defined(LOSCFG_KERNEL_TEST_FULL)) {
defines += [ "LOS_KERNEL_TEST_FULL=1" ]
}
cflags = warn_config_cflags
asmflags = warn_config_asmflags
}
module_switch = defined(LOSCFG_TEST)

View File

@@ -42,7 +42,7 @@ static UINT32 Testcase(VOID)
g_testQueueID01 = LOSCFG_BASE_IPC_QUEUE_LIMIT - 1;
ret = LOS_QueueCreateStatic("Q1", QUEUE_OVERSIZE_NUM, &g_testQueueID01, buff3, 0, 0xFFFF);
ret = LOS_QueueCreateStatic("Q1", QUEUE_OVERSIZE_NUM, &g_testQueueID01, (UINT8 *)buff3, 0, 0xFFFF);
ICUNIT_GOTO_EQUAL(ret, LOS_ERRNO_QUEUE_SIZE_TOO_BIG, ret, EXIT);
ret = LOS_QueueWrite(g_testQueueID01, &buff1, QUEUE_BASE_MSGSIZE, 0);

View File

@@ -62,10 +62,10 @@ static UINT32 Testcase(VOID)
OS_SWTMR_ROUSES_IGNORE, OS_SWTMR_ALIGN_SENSITIVE
#endif
);
id2 = swtmrId1;
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
id2 = swtmrId1;
ICUNIT_GOTO_NOT_EQUAL(id1, id2, swtmrId1, EXIT);
ret = LOS_SwtmrDelete(id1);

View File

@@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
id2 = swtmrId1;
ICUNIT_GOTO_NOT_EQUAL(id1, id2, swtmrId1, EXIT);
ICUNIT_GOTO_NOT_EQUAL(id1, id2, swtmrId1, EXIT1);
ret = LOS_SwtmrDelete(id1);
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
@@ -78,9 +78,10 @@ static UINT32 Testcase(VOID)
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
return LOS_OK;
EXIT1:
LOS_SwtmrDelete(id2);
EXIT:
LOS_SwtmrDelete(id1);
LOS_SwtmrDelete(id2);
return LOS_OK;
}

View File

@@ -30,6 +30,8 @@
#ifndef IT_POSIX_QUEUE_H
#define IT_POSIX_QUEUE_H
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#include <stdlib.h>
#include <mqueue.h>
@@ -40,6 +42,7 @@
#include <signal.h>
#include <osTest.h>
#include "pthread.h"
#include "unistd.h"
#define MAXMSG5 5
#define MSGLEN 10
@@ -105,6 +108,7 @@ 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);
extern void TestExtraTaskDelay(UINT32 tick);
VOID ItPosixQueue001(VOID);
VOID ItPosixQueue002(VOID);

View File

@@ -58,7 +58,6 @@ static UINT32 Testcase(VOID)
return LOS_OK;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
return LOS_OK;
}

View File

@@ -35,9 +35,6 @@ static UINT32 Testcase(VOID)
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;
@@ -59,7 +56,6 @@ static UINT32 Testcase(VOID)
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);

View File

@@ -34,8 +34,6 @@ 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());

View File

@@ -34,7 +34,6 @@ 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());

View File

@@ -55,7 +55,7 @@ EXIT:
static VOID *PthreadF02(VOID *argument)
{
INT32 j, ret;
INT32 ret;
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
@@ -82,8 +82,6 @@ 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;

View File

@@ -36,7 +36,7 @@ static VOID *PthreadF01(VOID *argument)
g_testCount = 1;
TestAssertWaitDelay(&g_testCount, 3); // 3, Here, assert the g_testCount.
TestAssertWaitDelay((UINT32 *)&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);
@@ -104,7 +104,7 @@ static UINT32 Testcase(VOID)
ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
TestAssertWaitDelay(&g_testCount, 1);
TestAssertWaitDelay((UINT32 *)&g_testCount, 1);
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST2);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
@@ -115,7 +115,7 @@ static UINT32 Testcase(VOID)
ret = MqueueTaskDelay(10); // 10, Set delay time.
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
TestAssertWaitDelay(&g_testCount, 4); // 4, Here, assert the g_testCount.
TestAssertWaitDelay((UINT32 *)&g_testCount, 4); // 4, Here, assert the g_testCount.
ret = PosixPthreadDestroy(&attr1, newTh2);
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);

View File

@@ -37,7 +37,7 @@ static UINT32 Testcase(VOID)
pthread_mutex_t mutex = TEST_MUTEX_INIT;
sem_t sem;
int pshared;
int pshared = 0;
ret = pthread_mutexattr_init(&mta);
ICUNIT_ASSERT_EQUAL(ret, 0, ret);

View File

@@ -33,7 +33,7 @@
#define THREAD_NUM 5
#define LOOPS 4
static g_value;
static int g_value;
static pthread_mutex_t g_mutex036 = PTHREAD_MUTEX_INITIALIZER;
/* pthread_mutex_lock 1-1.c

View File

@@ -28,13 +28,17 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#include "It_posix_mutex.h"
#include "unistd.h"
#define THREAD_NUM 6
#define LOOPS 3
static pthread_mutex_t g_mutex040 = PTHREAD_MUTEX_INITIALIZER;
static g_value;
static int g_value;
static void *TaskF01(void *parm)
{

View File

@@ -38,7 +38,7 @@ pthread_t TestPthreadSelf(void)
{
pthread_t tid = pthread_self();
if (tid == 0) {
tid = ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
tid = (pthread_t)(((LosTaskCB *)(OsCurrTaskGet()))->taskID);
}
return tid;
}

View File

@@ -28,6 +28,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#include <securec.h>
#include "osTest.h"
#include "pthread.h"

View File

@@ -71,8 +71,8 @@ static_library("posix_test") {
if (!defined(LOSCFG_COMPILER_ICCARM)) {
cflags = [
"-Wno-error",
"-Wno-unused-function",
"-Wno-int-conversion",
]
} else {
cflags = [ "--no_warnings" ]

View File

@@ -95,7 +95,8 @@ LITE_TEST_CASE(PosixSysFuncTestSuite, testOsSysStrerror001, Function | MediumTes
LOG("strerror(10) = %s\n", strerror(10));
TEST_ASSERT_EQUAL_STRING("No children", strerror(10));
#endif
return LOS_OK;
};
RUN_TEST_SUITE(PosixSysFuncTestSuite);

View File

@@ -85,6 +85,7 @@ extern void PosixIslowerFuncTest(void);
extern void PosixIsxdigitFuncTest(void);
extern void PosixTolowerFuncTest(void);
extern void PosixToupperFuncTest(void);
extern void ItSuitePosixMqueue(void);
extern void PosixStrerrorTest(void);

View File

@@ -91,12 +91,12 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll001, Function | MediumTest |
LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll002, Function | MediumTest | Level1)
{
long long value = atoll("-9223372036854775808");
if (value == -9223372036854775808LL) {
if (value == -9223372036854775808ULL) {
LOG("[DEMO] posix stdlib test case 2:atoll(%lld) ok.\n", value);
} else {
LOG("[DEMO] posix stdlib test case 2:atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == -9223372036854775808LL);
TEST_ASSERT_TRUE(value == -9223372036854775808ULL);
return 0;
}
@@ -126,7 +126,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll003, Function | MediumTest |
LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll004, Function | MediumTest | Level1)
{
long long value = atoll("9223372036854775808");
if (value == -9223372036854775808LL) {
if (value == -9223372036854775808ULL) {
LOG("[DEMO] posix stdlib test case 4(except):atoll(%lld) != 9223372036854775808 ok.\n", value);
} else {
LOG("[DEMO] posix stdlib test case 4(except):atoll(%lld) fail.\n", value);

View File

@@ -29,6 +29,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"

View File

@@ -29,6 +29,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define _GNU_SOURCE
#include "ohos_types.h"
#include "posix_test.h"
#include "los_config.h"

View File

@@ -30,6 +30,9 @@
*/
#define _GNU_SOURCE
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#include <sys/time.h>
#include <sys/times.h>
#include <time.h>