commit
3019311435
|
@ -47,6 +47,23 @@ static_library("test_posix") {
|
||||||
"mqueue/It_posix_queue_016.c",
|
"mqueue/It_posix_queue_016.c",
|
||||||
"mqueue/It_posix_queue_017.c",
|
"mqueue/It_posix_queue_017.c",
|
||||||
"mqueue/It_posix_queue_018.c",
|
"mqueue/It_posix_queue_018.c",
|
||||||
|
"mqueue/It_posix_queue_019.c",
|
||||||
|
"mqueue/It_posix_queue_020.c",
|
||||||
|
"mqueue/It_posix_queue_021.c",
|
||||||
|
"mqueue/It_posix_queue_022.c",
|
||||||
|
"mqueue/It_posix_queue_023.c",
|
||||||
|
"mqueue/It_posix_queue_024.c",
|
||||||
|
"mqueue/It_posix_queue_025.c",
|
||||||
|
"mqueue/It_posix_queue_026.c",
|
||||||
|
"mqueue/It_posix_queue_027.c",
|
||||||
|
"mqueue/It_posix_queue_028.c",
|
||||||
|
"mqueue/It_posix_queue_029.c",
|
||||||
|
"mqueue/It_posix_queue_030.c",
|
||||||
|
"mqueue/It_posix_queue_031.c",
|
||||||
|
"mqueue/It_posix_queue_032.c",
|
||||||
|
"mqueue/It_posix_queue_033.c",
|
||||||
|
"mqueue/It_posix_queue_034.c",
|
||||||
|
"mqueue/It_posix_queue_035.c",
|
||||||
"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",
|
||||||
|
|
|
@ -70,4 +70,21 @@ VOID ItSuitePosixMqueue(void)
|
||||||
ItPosixQueue016();
|
ItPosixQueue016();
|
||||||
ItPosixQueue017();
|
ItPosixQueue017();
|
||||||
ItPosixQueue018();
|
ItPosixQueue018();
|
||||||
|
ItPosixQueue019();
|
||||||
|
ItPosixQueue020();
|
||||||
|
ItPosixQueue021();
|
||||||
|
ItPosixQueue022();
|
||||||
|
ItPosixQueue023();
|
||||||
|
ItPosixQueue024();
|
||||||
|
ItPosixQueue025();
|
||||||
|
ItPosixQueue026();
|
||||||
|
ItPosixQueue027();
|
||||||
|
ItPosixQueue028();
|
||||||
|
ItPosixQueue029();
|
||||||
|
ItPosixQueue030();
|
||||||
|
ItPosixQueue031();
|
||||||
|
ItPosixQueue032();
|
||||||
|
ItPosixQueue033();
|
||||||
|
ItPosixQueue034();
|
||||||
|
ItPosixQueue035();
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
#define LOSCFG_BASE_IPC_QUEUE_CONFIG 1024
|
#define LOSCFG_BASE_IPC_QUEUE_CONFIG 1024
|
||||||
|
|
||||||
#define LOS_AtomicInc(a) (++*(a))
|
#define LOS_AtomicInc(a) (++*(a))
|
||||||
#define MqueueTaskDelay (usleep(tick * 10000))
|
#define MqueueTaskDelay(tick) (usleep((tick) * 10000))
|
||||||
|
|
||||||
#ifdef __LP64__
|
#ifdef __LP64__
|
||||||
#define PER_ADDED_VALUE 8
|
#define PER_ADDED_VALUE 8
|
||||||
|
@ -123,4 +123,21 @@ VOID ItPosixQueue015(VOID);
|
||||||
VOID ItPosixQueue016(VOID);
|
VOID ItPosixQueue016(VOID);
|
||||||
VOID ItPosixQueue017(VOID);
|
VOID ItPosixQueue017(VOID);
|
||||||
VOID ItPosixQueue018(VOID);
|
VOID ItPosixQueue018(VOID);
|
||||||
|
VOID ItPosixQueue019(VOID);
|
||||||
|
VOID ItPosixQueue020(VOID);
|
||||||
|
VOID ItPosixQueue021(VOID);
|
||||||
|
VOID ItPosixQueue022(VOID);
|
||||||
|
VOID ItPosixQueue023(VOID);
|
||||||
|
VOID ItPosixQueue024(VOID);
|
||||||
|
VOID ItPosixQueue025(VOID);
|
||||||
|
VOID ItPosixQueue026(VOID);
|
||||||
|
VOID ItPosixQueue027(VOID);
|
||||||
|
VOID ItPosixQueue028(VOID);
|
||||||
|
VOID ItPosixQueue029(VOID);
|
||||||
|
VOID ItPosixQueue030(VOID);
|
||||||
|
VOID ItPosixQueue031(VOID);
|
||||||
|
VOID ItPosixQueue032(VOID);
|
||||||
|
VOID ItPosixQueue033(VOID);
|
||||||
|
VOID ItPosixQueue034(VOID);
|
||||||
|
VOID ItPosixQueue035(VOID);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
ret = mq_close((mqd_t)-1); // -1: invalid message queue descriptor
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(ret, 0, ret);
|
||||||
|
|
||||||
|
ICUNIT_ASSERT_EQUAL(errno, EBADF, errno);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue019
|
||||||
|
* @tc.desc: Test interface mq_close
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue019(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue019", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
struct timespec ts;
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq020_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ts.tv_sec = 1;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(mqueue, msgptr, strlen(msgptr), 0, &ts);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue020
|
||||||
|
* @tc.desc: Test interface mq_receive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue020(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue020", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -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)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct sigevent se;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq021_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue021
|
||||||
|
* @tc.desc: Test interface mq_open
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue021(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue021", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -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 mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq022_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, MQUEUE_SHORT_ARRAY_LENGTH, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue022
|
||||||
|
* @tc.desc: Test interface mq_receive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue022(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue022", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -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 = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
struct timespec ts;
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq023_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ts.tv_sec = 1;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
ret = mq_timedsend(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX + 1, &ts);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue023
|
||||||
|
* @tc.desc: Test interface mq_timedsend
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue023(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue023", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq024_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue024
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue024(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue024", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static VOID *PthreadF01(VOID *argument)
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
INT32 ret;
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
|
||||||
|
g_testCount = 1;
|
||||||
|
|
||||||
|
g_mqueueTaskPID = LOS_CurTaskIDGet();
|
||||||
|
|
||||||
|
for (i = 0; i < 5 + 1; i++) { // 5, The loop frequency.
|
||||||
|
ret = mq_send(g_gqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
}
|
||||||
|
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, Here, assert the g_testCount.
|
||||||
|
|
||||||
|
g_testCount = 2; // 2, Init test count value.
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
EXIT:
|
||||||
|
g_testCount = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID *PthreadF02(VOID *argument)
|
||||||
|
{
|
||||||
|
INT32 j, ret;
|
||||||
|
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
|
||||||
|
g_testCount = 3; // 3, Init test count value.
|
||||||
|
|
||||||
|
ret = mq_receive(g_gqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, strlen(MQUEUE_SEND_STRING_TEST), ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_close(g_gqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(g_gqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
g_testCount = 4; // 4, Init test count value.
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
EXIT:
|
||||||
|
g_testCount = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
pthread_t newTh1, newTh2;
|
||||||
|
UINT32 ret;
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
pthread_attr_t attr1;
|
||||||
|
|
||||||
|
ret = snprintf_s(g_gqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq025_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = 5; // 5, queue max message size.
|
||||||
|
|
||||||
|
g_testCount = 0;
|
||||||
|
|
||||||
|
g_gqueue = mq_open(g_gqname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(g_gqueue, (mqd_t)-1, g_gqueue, EXIT);
|
||||||
|
|
||||||
|
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
MqueueTaskDelay(5); // 5, Set delay time.
|
||||||
|
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
|
||||||
|
|
||||||
|
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ret = pthread_create(&newTh2, &attr1, PthreadF02, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ret = MqueueTaskDelay(5); // 5, Set delay time.
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, Here, assert the g_testCount.
|
||||||
|
|
||||||
|
ret = PosixPthreadDestroy(&attr1, newTh2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = PosixPthreadDestroy(&attr1, newTh1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
|
||||||
|
EXIT2:
|
||||||
|
PosixPthreadDestroy(&attr1, newTh2);
|
||||||
|
EXIT1:
|
||||||
|
PosixPthreadDestroy(&attr1, newTh1);
|
||||||
|
EXIT:
|
||||||
|
mq_close(g_gqueue);
|
||||||
|
mq_unlink(g_gqname);
|
||||||
|
EXIT3:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue025
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue025(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue025", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,155 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static VOID *PthreadF01(VOID *argument)
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
struct timespec ts;
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
UINT32 ret;
|
||||||
|
|
||||||
|
ts.tv_sec = 0xffff;
|
||||||
|
ts.tv_nsec = 0;
|
||||||
|
|
||||||
|
g_testCount = 1;
|
||||||
|
|
||||||
|
for (i = 0; i < 5 + 1; i++) { // 5, The loop frequency.
|
||||||
|
ret = mq_timedsend(g_gqueue, msgptr, strlen(msgptr), 0, &ts);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
}
|
||||||
|
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT1); // 3, Here, assert the g_testCount.
|
||||||
|
|
||||||
|
g_testCount = 2; // 2, Init test count value.
|
||||||
|
|
||||||
|
EXIT1:
|
||||||
|
return NULL;
|
||||||
|
EXIT2:
|
||||||
|
g_testCount = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID *PthreadF02(VOID *argument)
|
||||||
|
{
|
||||||
|
INT32 ret;
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
|
||||||
|
g_testCount = 3; // 3, Init test count value.
|
||||||
|
|
||||||
|
ret = mq_receive(g_gqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, strlen(MQUEUE_SEND_STRING_TEST), ret, EXIT1);
|
||||||
|
|
||||||
|
TestExtraTaskDelay(2); // 2, Set delay time.
|
||||||
|
ret = mq_close(g_gqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(g_gqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
g_testCount = 4; // 4, Init test count value.
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(g_gqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(g_gqname);
|
||||||
|
EXIT2:
|
||||||
|
g_testCount = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
UINT32 ret;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
pthread_attr_t attr1;
|
||||||
|
pthread_t newTh1, newTh2;
|
||||||
|
|
||||||
|
ret = snprintf_s(g_gqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq026_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT3);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = 5; // 5, queue max message size.
|
||||||
|
g_gqueue = mq_open(g_gqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(g_gqueue, (mqd_t)-1, g_gqueue, EXIT);
|
||||||
|
|
||||||
|
g_testCount = 0;
|
||||||
|
|
||||||
|
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = pthread_create(&newTh1, &attr1, PthreadF01, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
MqueueTaskDelay(5); // 5, Set delay time.
|
||||||
|
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT1);
|
||||||
|
|
||||||
|
ret = PosixPthreadInit(&attr1, MQUEUE_PTHREAD_PRIORITY_TEST2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ret = pthread_create(&newTh2, &attr1, PthreadF02, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ret = MqueueTaskDelay(5); // 5, Set delay time.
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT2); // 4, Here, assert the g_testCount.
|
||||||
|
|
||||||
|
ret = PosixPthreadDestroy(&attr1, newTh2);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = PosixPthreadDestroy(&attr1, newTh1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
|
||||||
|
EXIT2:
|
||||||
|
PosixPthreadDestroy(&attr1, newTh2);
|
||||||
|
EXIT1:
|
||||||
|
PosixPthreadDestroy(&attr1, newTh1);
|
||||||
|
EXIT:
|
||||||
|
mq_close(g_gqueue);
|
||||||
|
mq_unlink(g_gqname);
|
||||||
|
EXIT3:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue026
|
||||||
|
* @tc.desc: Test interface mq_timedsend
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue026(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue026", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret, i = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgptr[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq027_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
ret = snprintf_s(msgptr, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, "message %d", i);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
if (ret == -1) {
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
ICUNIT_GOTO_EQUAL(i, MQUEUE_SHORT_ARRAY_LENGTH, i, EXIT1);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
ret = snprintf_s(msgptr, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, "message %d", i);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
|
||||||
|
|
||||||
|
ret = strcmp(msgptr, msgrcd);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue027
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue027(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue027", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -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] = {0};
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq028_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_ASSERT_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), MQ_PRIO_MAX - 1);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, strlen(msgptr), ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_STRING_EQUAL(msgrcd, msgptr, msgrcd, EXIT1);
|
||||||
|
|
||||||
|
ret = strncmp(msgptr, msgrcd, strlen(msgptr));
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue028
|
||||||
|
* @tc.desc: Test interface mq_receive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue028(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue028", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -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] = {0};
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq029_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_SHORT_ARRAY_LENGTH;
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send((mqd_t)(&mqueue + 1), msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = strcmp(msgptr, msgrcd);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue029
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue029(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue029", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
CHAR qname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t queue;
|
||||||
|
INT32 unresolved = 0;
|
||||||
|
INT32 failure = 0;
|
||||||
|
INT32 ret = 0;
|
||||||
|
|
||||||
|
ret = snprintf_s(qname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq030-1_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT);
|
||||||
|
|
||||||
|
queue = mq_open(qname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(queue, (mqd_t)-1, queue, EXIT);
|
||||||
|
|
||||||
|
ret = mq_send((mqd_t)(&queue + 1), msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT2);
|
||||||
|
|
||||||
|
ret = mq_close(queue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_unlink(qname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT2:
|
||||||
|
mq_close(queue);
|
||||||
|
EXIT1:
|
||||||
|
mq_unlink(qname);
|
||||||
|
EXIT:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue030
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue030(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue030", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -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 = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
CHAR msgrcd[MQUEUE_STANDARD_NAME_LENGTH * 2];
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq031_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EBADF, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EMSGSIZE, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrcd, MQUEUE_STANDARD_NAME_LENGTH * 2, NULL); // 2, mqueue message length.
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EAGAIN, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue031
|
||||||
|
* @tc.desc: Test interface mq_receive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue031(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue031", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -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 = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrv[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = "test message";
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct timespec ts;
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq032_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH;
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ts.tv_sec = 1;
|
||||||
|
ts.tv_nsec = -1;
|
||||||
|
ret = mq_timedreceive(mqueue, msgrv, MQUEUE_STANDARD_NAME_LENGTH, NULL, &ts);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue032
|
||||||
|
* @tc.desc: Test interface mq_timedreceive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue032(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue032", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 i;
|
||||||
|
INT32 ret = 0;
|
||||||
|
INT32 mqueuePri[MQUEUE_PRIORITY_NUM_TEST] = {MQ_PRIO_MAX, MQ_PRIO_MAX + 1, MQ_PRIO_MAX + 5}; // 5, Mqueue priority.
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = MQUEUE_SEND_STRING_TEST;
|
||||||
|
mqd_t mqueue;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1, \
|
||||||
|
"/mq033_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
for (i = 0; i < MQUEUE_PRIORITY_NUM_TEST; i++) {
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), mqueuePri[i]);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EINVAL, errno, EXIT1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue033
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue033(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue033", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 i, ret = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = "";
|
||||||
|
const CHAR *msgptr = "01234567890123456789";
|
||||||
|
mqd_t mqueue;
|
||||||
|
INT32 messagesize[MQUEUE_PRIORITY_NUM_TEST] = {19, 2, 1}; // 19, 2, 1: three values of messagesize for test.
|
||||||
|
|
||||||
|
struct mq_attr attr = {0};
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq034_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
for (i = 0; i < MQUEUE_PRIORITY_NUM_TEST; i++) {
|
||||||
|
attr.mq_msgsize = messagesize[i];
|
||||||
|
attr.mq_maxmsg = messagesize[i];
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EMSGSIZE, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue034
|
||||||
|
* @tc.desc: Test interface mq_send
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue034(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue034", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022 Huawei Device Co., Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||||
|
* to endorse or promote products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
#include "It_posix_queue.h"
|
||||||
|
|
||||||
|
static UINT32 Testcase(VOID)
|
||||||
|
{
|
||||||
|
INT32 ret = 0;
|
||||||
|
CHAR mqname[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
CHAR msgrv[MQUEUE_STANDARD_NAME_LENGTH] = {0};
|
||||||
|
const CHAR *msgptr = "test message";
|
||||||
|
mqd_t mqueue;
|
||||||
|
struct mq_attr attr;
|
||||||
|
|
||||||
|
ret = snprintf_s(mqname, MQUEUE_STANDARD_NAME_LENGTH, MQUEUE_STANDARD_NAME_LENGTH - 1,
|
||||||
|
"/mq035_%d", LOS_CurTaskIDGet());
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(ret, -1, ret, EXIT2);
|
||||||
|
|
||||||
|
attr.mq_msgsize = MQUEUE_STANDARD_NAME_LENGTH + 1;
|
||||||
|
attr.mq_maxmsg = MQUEUE_STANDARD_NAME_LENGTH + 1;
|
||||||
|
|
||||||
|
mqueue = mq_open(mqname, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
|
||||||
|
ICUNIT_GOTO_NOT_EQUAL(mqueue, (mqd_t)-1, mqueue, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_send(mqueue, msgptr, strlen(msgptr), 0);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_receive(mqueue, msgrv, MQUEUE_STANDARD_NAME_LENGTH, NULL);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT1);
|
||||||
|
ICUNIT_GOTO_EQUAL(errno, EMSGSIZE, errno, EXIT1);
|
||||||
|
|
||||||
|
ret = mq_close(mqueue);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||||
|
|
||||||
|
ret = mq_unlink(mqname);
|
||||||
|
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT2);
|
||||||
|
|
||||||
|
return LOS_OK;
|
||||||
|
EXIT1:
|
||||||
|
mq_close(mqueue);
|
||||||
|
EXIT:
|
||||||
|
mq_unlink(mqname);
|
||||||
|
EXIT2:
|
||||||
|
return LOS_NOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @tc.name: ItPosixQueue035
|
||||||
|
* @tc.desc: Test interface mq_receive
|
||||||
|
* @tc.type: FUNC
|
||||||
|
* @tc.require: issueI6148G
|
||||||
|
*/
|
||||||
|
|
||||||
|
VOID ItPosixQueue035(VOID)
|
||||||
|
{
|
||||||
|
TEST_ADD_CASE("ItPosixQueue035", Testcase, TEST_POSIX, TEST_QUE, TEST_LEVEL2, TEST_FUNCTION);
|
||||||
|
}
|
Loading…
Reference in New Issue