fix: POSIX 测试用例后续补充
【背景】 kernel_litos_m 中需要补充 POSIX 相关的测试用例 【修改方案】 从 A 核中移植了一部分的POSIX 相关的测试用例 到 sample/posix/mqueue 目录下 【影响】 对现有的产品编译不会有影响 Signed-off-by: yinjiaming <yinjiaming@huawei.com> Change-Id: I64efeb7d3ae3dbd966b716bf8e296a9eb0f5db06
This commit is contained in:
parent
e540254ed9
commit
7e442ddd61
|
@ -28,6 +28,25 @@
|
||||||
|
|
||||||
static_library("test_posix") {
|
static_library("test_posix") {
|
||||||
sources = [
|
sources = [
|
||||||
|
"mqueue/It_posix_queue.c",
|
||||||
|
"mqueue/It_posix_queue_001.c",
|
||||||
|
"mqueue/It_posix_queue_002.c",
|
||||||
|
"mqueue/It_posix_queue_003.c",
|
||||||
|
"mqueue/It_posix_queue_004.c",
|
||||||
|
"mqueue/It_posix_queue_005.c",
|
||||||
|
"mqueue/It_posix_queue_006.c",
|
||||||
|
"mqueue/It_posix_queue_007.c",
|
||||||
|
"mqueue/It_posix_queue_008.c",
|
||||||
|
"mqueue/It_posix_queue_009.c",
|
||||||
|
"mqueue/It_posix_queue_010.c",
|
||||||
|
"mqueue/It_posix_queue_011.c",
|
||||||
|
"mqueue/It_posix_queue_012.c",
|
||||||
|
"mqueue/It_posix_queue_013.c",
|
||||||
|
"mqueue/It_posix_queue_014.c",
|
||||||
|
"mqueue/It_posix_queue_015.c",
|
||||||
|
"mqueue/It_posix_queue_016.c",
|
||||||
|
"mqueue/It_posix_queue_017.c",
|
||||||
|
"mqueue/It_posix_queue_018.c",
|
||||||
"mutex/It_posix_mutex.c",
|
"mutex/It_posix_mutex.c",
|
||||||
"mutex/It_posix_mutex_001.c",
|
"mutex/It_posix_mutex_001.c",
|
||||||
"mutex/It_posix_mutex_002.c",
|
"mutex/It_posix_mutex_002.c",
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "stdio.h"
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
CHAR *g_mqueueMsessage[MQUEUE_SHORT_ARRAY_LENGTH] = {"0123456789", "1234567890", "2345678901",
|
||||||
|
"3456789012", "4567890123", "5678901234",
|
||||||
|
"6789012345", "7890123456", "lalalalala",
|
||||||
|
"hahahahaha"};
|
||||||
|
CHAR g_gqname[MQUEUE_STANDARD_NAME_LENGTH];
|
||||||
|
CHAR g_mqueueName[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1][MQUEUE_STANDARD_NAME_LENGTH];
|
||||||
|
mqd_t g_mqueueId[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
|
||||||
|
SEM_HANDLE_T g_mqueueSem;
|
||||||
|
mqd_t g_messageQId;
|
||||||
|
mqd_t g_gqueue;
|
||||||
|
|
||||||
|
VOID TestAssertWaitDelay(UINT32 *testCount, UINT32 flag)
|
||||||
|
{
|
||||||
|
while (*testCount != flag) {
|
||||||
|
usleep(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID ItSuitePosixMqueue(void)
|
||||||
|
{
|
||||||
|
printf("*********** BEGIN SAMPLE POSIX MQUEUE TEST ************\n");
|
||||||
|
ItPosixQueue001();
|
||||||
|
ItPosixQueue002();
|
||||||
|
ItPosixQueue003();
|
||||||
|
ItPosixQueue004();
|
||||||
|
ItPosixQueue005();
|
||||||
|
ItPosixQueue006();
|
||||||
|
ItPosixQueue007();
|
||||||
|
ItPosixQueue008();
|
||||||
|
ItPosixQueue009();
|
||||||
|
ItPosixQueue010();
|
||||||
|
ItPosixQueue011();
|
||||||
|
ItPosixQueue012();
|
||||||
|
ItPosixQueue013();
|
||||||
|
ItPosixQueue014();
|
||||||
|
ItPosixQueue015();
|
||||||
|
ItPosixQueue016();
|
||||||
|
ItPosixQueue017();
|
||||||
|
ItPosixQueue018();
|
||||||
|
}
|
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IT_POSIX_QUEUE_H
|
||||||
|
#define IT_POSIX_QUEUE_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <mqueue.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <sched.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <osTest.h>
|
||||||
|
#include "pthread.h"
|
||||||
|
|
||||||
|
#define MAXMSG5 5
|
||||||
|
#define MSGLEN 10
|
||||||
|
#define MAXMSG 10
|
||||||
|
|
||||||
|
#define MQUEUE_SEND_STRING_TEST "0123456789"
|
||||||
|
#define MQUEUE_SHORT_ARRAY_LENGTH 10 // 10: strlen(MQUEUE_SEND_STRING_TEST)
|
||||||
|
#define MQUEUE_STANDARD_NAME_LENGTH 50
|
||||||
|
|
||||||
|
#define MQUEUE_PTHREAD_PRIORITY_TEST1 3
|
||||||
|
#define MQUEUE_PTHREAD_PRIORITY_TEST2 4
|
||||||
|
#define MQUEUE_PATH_MAX_TEST PATH_MAX
|
||||||
|
#define MQUEUE_NAME_MAX_TEST NAME_MAX
|
||||||
|
#define MQUEUE_PTHREAD_NUM_TEST 5
|
||||||
|
#define MQUEUE_PRIORITY_TEST 0
|
||||||
|
#define MQUEUE_TIMEOUT_TEST 7
|
||||||
|
#define MQUEUE_PRIORITY_NUM_TEST 3
|
||||||
|
#define MQUEUE_MAX_NUM_TEST (LOSCFG_BASE_IPC_QUEUE_CONFIG - QUEUE_EXISTED_NUM)
|
||||||
|
#define MQ_MAX_MSG_NUM 16
|
||||||
|
#define MQ_MAX_MSG_LEN 64
|
||||||
|
#define HWI_NUM_TEST 1
|
||||||
|
#define HWI_NUM_TEST1 2
|
||||||
|
|
||||||
|
#if (LOSCFG_LIBC_NEWLIB == 1)
|
||||||
|
#define MQ_PRIO_MAX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LOSCFG_BASE_IPC_QUEUE_CONFIG 1024
|
||||||
|
|
||||||
|
#define LOS_AtomicInc(a) (++*(a))
|
||||||
|
#define MqueueTaskDelay (usleep(tick * 10000))
|
||||||
|
|
||||||
|
#ifdef __LP64__
|
||||||
|
#define PER_ADDED_VALUE 8
|
||||||
|
#else
|
||||||
|
#define PER_ADDED_VALUE 4
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ICUNIT_GOTO_WITHIN_EQUAL(param, value1, value2, retcode, label) \
|
||||||
|
do { \
|
||||||
|
if ((param) < (value1) || (param) > (value2)) { \
|
||||||
|
ICunitSaveErr(__LINE__, (iiUINT32)retcode); \
|
||||||
|
goto label; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
typedef UINT32 TSK_HANDLE_T;
|
||||||
|
typedef UINT32 SEM_HANDLE_T ;
|
||||||
|
|
||||||
|
extern SEM_HANDLE_T g_mqueueSem;
|
||||||
|
|
||||||
|
static TSK_HANDLE_T g_mqueueTaskPID;
|
||||||
|
extern CHAR g_gqname[MQUEUE_STANDARD_NAME_LENGTH];
|
||||||
|
extern CHAR g_mqueueName[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1][MQUEUE_STANDARD_NAME_LENGTH];
|
||||||
|
extern mqd_t g_mqueueId[LOSCFG_BASE_IPC_QUEUE_CONFIG + 1];
|
||||||
|
|
||||||
|
extern CHAR *g_mqueueMsessage[MQUEUE_SHORT_ARRAY_LENGTH];
|
||||||
|
extern mqd_t g_messageQId;
|
||||||
|
extern mqd_t g_gqueue;
|
||||||
|
|
||||||
|
extern VOID ItSuitePosixMqueue(VOID);
|
||||||
|
extern UINT32 PosixPthreadInit(pthread_attr_t *attr, int pri);
|
||||||
|
extern UINT32 PosixPthreadDestroy(pthread_attr_t *attr, pthread_t thread);
|
||||||
|
extern VOID TestAssertWaitDelay(UINT32 *testCount, UINT32 flag);
|
||||||
|
|
||||||
|
VOID ItPosixQueue001(VOID);
|
||||||
|
VOID ItPosixQueue002(VOID);
|
||||||
|
VOID ItPosixQueue003(VOID);
|
||||||
|
VOID ItPosixQueue004(VOID);
|
||||||
|
VOID ItPosixQueue005(VOID);
|
||||||
|
VOID ItPosixQueue006(VOID);
|
||||||
|
VOID ItPosixQueue007(VOID);
|
||||||
|
VOID ItPosixQueue008(VOID);
|
||||||
|
VOID ItPosixQueue009(VOID);
|
||||||
|
VOID ItPosixQueue010(VOID);
|
||||||
|
VOID ItPosixQueue011(VOID);
|
||||||
|
VOID ItPosixQueue012(VOID);
|
||||||
|
VOID ItPosixQueue013(VOID);
|
||||||
|
VOID ItPosixQueue014(VOID);
|
||||||
|
VOID ItPosixQueue015(VOID);
|
||||||
|
VOID ItPosixQueue016(VOID);
|
||||||
|
VOID ItPosixQueue017(VOID);
|
||||||
|
VOID ItPosixQueue018(VOID);
|
||||||
|
#endif
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = 0;
|
||||||
|
|
||||||
|
(void)snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH - 1, MQUEUE_STANDARD_NAME_LENGTH, "/mq001_%d",
|
||||||
|
LOS_CurTaskIDGet());
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue001
|
||||||
|
* @tc.desc: Test interface mq_open
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue001(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue001", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = 1;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq002_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_STRING_EQUAL(msgrcd, MQUEUE_SEND_STRING_TEST, msgrcd, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue002
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue002(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue002", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrv1[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
INT32 ret = 0;
|
||||||
|
INT32 i;
|
||||||
|
pthread_t pthread1;
|
||||||
|
pthread_t pthread2;
|
||||||
|
mqd_t mqueue1;
|
||||||
|
mqd_t mqueue2;
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq003_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
|
||||||
|
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1);
|
||||||
|
|
||||||
|
mqueue2 = mq_open(mqname, O_RDWR | O_EXCL, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(mqueue2, (mqd_t)-1, mqueue2);
|
||||||
|
|
||||||
|
ts.tv_sec = 1;
|
||||||
|
ts.tv_nsec = 1;
|
||||||
|
ret = mq_timedreceive(mqueue1, msgrv1, MQUEUE_STANDARD_NAME_LENGTH, NULL, &ts);
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, -1, ret);
|
||||||
|
|
||||||
|
EXIT:
|
||||||
|
mq_close(mqueue1);
|
||||||
|
mq_close(mqueue2);
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT1:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue003
|
||||||
|
* @tc.desc: Test interface mq_timedreceive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue003(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue003", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq004_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
mqueue = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
|
||||||
|
EXIT:
|
||||||
|
mq_close(mqueue);
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT1:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue004
|
||||||
|
* @tc.desc: Test interface mq_open
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue004(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue004", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t roqueue;
|
||||||
|
mqd_t roqueue2;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq005_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
roqueue = mq_open(mqname, O_CREAT | O_RDONLY, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(roqueue, (mqd_t)-1, roqueue, EXIT);
|
||||||
|
|
||||||
|
roqueue2 = mq_open(mqname, O_RDONLY, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(roqueue2, (mqd_t)-1, roqueue2, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(roqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(roqueue2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(roqueue2);
|
||||||
|
EXIT:
|
||||||
|
mq_close(roqueue);
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue005
|
||||||
|
* @tc.desc: Test interface mq_close
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue005(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue005", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrcd2[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t rdwrqueue;
|
||||||
|
mqd_t rdwrqueue2;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq006_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
rdwrqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(rdwrqueue, (mqd_t)-1, rdwrqueue, EXIT);
|
||||||
|
|
||||||
|
ret = mq_send(rdwrqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_receive(rdwrqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT);
|
||||||
|
|
||||||
|
rdwrqueue2 = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(rdwrqueue2, (mqd_t)-1, rdwrqueue2, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(rdwrqueue2, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(rdwrqueue2, msgrcd2, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(rdwrqueue2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(rdwrqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(rdwrqueue2);
|
||||||
|
EXIT:
|
||||||
|
mq_close(rdwrqueue);
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue006
|
||||||
|
* @tc.desc: Test interface mq_receive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue006(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue006", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue1;
|
||||||
|
mqd_t mqueue2;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq007_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||||
|
|
||||||
|
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue1, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
mqueue2 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue2, (mqd_t)-1, mqueue2, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue2, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT2:
|
||||||
|
mq_close(mqueue2);
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue1);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT3:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue007
|
||||||
|
* @tc.desc: Test interface mq_close
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue007(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue007", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq008_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_getattr(mqueue, &attr);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attr.mq_curmsgs, 0, attr.mq_curmsgs, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attr.mq_flags, O_CREAT | O_RDWR, attr.mq_flags, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attr.mq_maxmsg, MQ_MAX_MSG_NUM, attr.mq_maxmsg, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attr.mq_msgsize, MQ_MAX_MSG_LEN, attr.mq_msgsize, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue008
|
||||||
|
* @tc.desc: Test interface mq_getattr
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue008(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue008", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
struct mq_attr attrget;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq009_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||||
|
attr.mq_msgsize = 5; // 5, queue message size.
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_getattr(mqueue, &attrget);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attrget.mq_curmsgs, 0, attrget.mq_curmsgs, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attrget.mq_flags, O_CREAT | O_RDWR | O_NONBLOCK, attrget.mq_flags, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attrget.mq_maxmsg, attr.mq_maxmsg, attrget.mq_maxmsg, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(attrget.mq_msgsize, attr.mq_msgsize, attrget.mq_msgsize, EXIT1);
|
||||||
|
|
||||||
|
if (!(attrget.mq_flags & O_NONBLOCK)) {
|
||||||
|
goto EXIT1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue009
|
||||||
|
* @tc.desc: Test interface mq_getattr
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue009(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue009", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t mqueue1;
|
||||||
|
mqd_t mqueue2;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq010_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||||
|
|
||||||
|
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||||
|
|
||||||
|
mqueue2 = mq_open(mqname, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(mqueue2, (mqd_t)-1, mqueue2, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT2:
|
||||||
|
mq_close(mqueue2);
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue1);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT3:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue010
|
||||||
|
* @tc.desc: Test interface mq_unlink
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue010(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue010", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq011_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue011
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue011(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue011", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue1;
|
||||||
|
mqd_t mqueue2;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq012_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
|
||||||
|
mqueue1 = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue1, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue1, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
mqueue2 = mq_open(mqname, O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue1, (mqd_t)-1, mqueue1, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue1, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
|
||||||
|
EXIT2:
|
||||||
|
mq_close(mqueue2);
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue1);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT3:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue012
|
||||||
|
* @tc.desc: Test interface mq_receive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue012(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue012", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct sigevent ev;
|
||||||
|
struct sigaction act;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq013_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue013
|
||||||
|
* @tc.desc: Test interface mq_close
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue013(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue013", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq014_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
|
||||||
|
EXIT:
|
||||||
|
mq_close(mqueue);
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT1:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue014
|
||||||
|
* @tc.desc: Test interface mq_open
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue014(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue014", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
#define QUEUE_NAME_MAX_LEN (MQUEUE_NAME_MAX_TEST * 2)
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
CHAR mqname[QUEUE_NAME_MAX_LEN];
|
||||||
|
mqd_t mqueue;
|
||||||
|
UINT32 ret;
|
||||||
|
INT32 i;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, QUEUE_NAME_MAX_LEN, QUEUE_NAME_MAX_LEN - 1, \
|
||||||
|
"/mq015_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
for (i = 0; i < MQUEUE_NAME_MAX_TEST; i++) {
|
||||||
|
ret = strcat_s(mqname, QUEUE_NAME_MAX_LEN, "0");
|
||||||
|
ICUNIT_ASSERT_EQUAL(ret, EOK, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENAMETOOLONG, errno);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT:
|
||||||
|
mq_close(mqueue);
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT1:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue015
|
||||||
|
* @tc.desc: Test interface mq_open
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue015(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue015", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR qname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
mqd_t queue;
|
||||||
|
|
||||||
|
ret = snprintf_s(qname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq016-1_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
queue = mq_open(qname, O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(queue, (mqd_t)-1, queue, EXIT);
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT:
|
||||||
|
mq_close(queue);
|
||||||
|
mq_unlink(qname);
|
||||||
|
EXIT1:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue016
|
||||||
|
* @tc.desc: Test interface mq_open
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue016(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue016", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
CHAR qname[MQUEUE_STANDARD_NAME_LENGTH];
|
||||||
|
INT32 ret;
|
||||||
|
mqd_t queue;
|
||||||
|
|
||||||
|
ret = snprintf_s(qname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq017-1_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
queue = mq_open(qname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
if (queue == (mqd_t)-1) {
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(qname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT:
|
||||||
|
mq_close(queue);
|
||||||
|
mq_unlink(qname);
|
||||||
|
EXIT1:
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue017
|
||||||
|
* @tc.desc: Test interface mq_close
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue017(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue017", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,92 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
#define QUEUE_MSG_SIZE 20
|
||||||
|
#define QUEUE_MAX_MSG_SIZE 20
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
CHAR msgrcd[QUEUE_MSG_SIZE] = {0};
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
struct timespec absTimeout = {0};
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
(void)snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH - 1, MQUEUE_STANDARD_NAME_LENGTH, "/mq018_%d",
|
||||||
|
LOS_CurTaskIDGet());
|
||||||
|
|
||||||
|
attr.mq_msgsize = QUEUE_MSG_SIZE;
|
||||||
|
attr.mq_maxmsg = QUEUE_MAX_MSG_SIZE;
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue);
|
||||||
|
|
||||||
|
ret = mq_timedsend(mqueue, "1234567890123456789", QUEUE_MSG_SIZE, 0, &absTimeout);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, QUEUE_MSG_SIZE, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, QUEUE_MSG_SIZE, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, QUEUE_MSG_SIZE, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue018
|
||||||
|
* @tc.desc: Test interface mq_timedsend
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI603SR6
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue018(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue018", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL0, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ void ItSuitePosix(void)
|
||||||
PthreadFuncTestSuite();
|
PthreadFuncTestSuite();
|
||||||
ItSuitePosixPthread();
|
ItSuitePosixPthread();
|
||||||
ItSuitePosixMutex();
|
ItSuitePosixMutex();
|
||||||
|
ItSuitePosixMqueue();
|
||||||
PosixCtypeFuncTest();
|
PosixCtypeFuncTest();
|
||||||
PosixIsdigitFuncTest();
|
PosixIsdigitFuncTest();
|
||||||
PosixIslowerFuncTest();
|
PosixIslowerFuncTest();
|
||||||
|
|
Loading…
Reference in New Issue