diff --git a/testsuites/unittest/xts/BUILD.gn b/testsuites/unittest/xts/BUILD.gn index e5751833..4784b934 100644 --- a/testsuites/unittest/xts/BUILD.gn +++ b/testsuites/unittest/xts/BUILD.gn @@ -33,6 +33,7 @@ static_library("xts_test") { deps = [ "io:io_test", "ipc:ipc_test", + "math:math_test", ] configs += [ "$LITEOSTOPDIR/testsuites:include" ] } diff --git a/testsuites/unittest/xts/ipc/BUILD.gn b/testsuites/unittest/xts/ipc/BUILD.gn index 639f126c..48c24839 100644 --- a/testsuites/unittest/xts/ipc/BUILD.gn +++ b/testsuites/unittest/xts/ipc/BUILD.gn @@ -31,6 +31,8 @@ import("//kernel/liteos_m/liteos.gni") static_library("ipc_test") { sources = [ "cond/pthread_cond_test.c", + "msg_queue/mq_exp_test.c", + "msg_queue/mq_test.c", "mutex/pthread_mutex_test.c", "semaphone/sem_abn_test.c", "semaphone/sem_test.c", diff --git a/testsuites/unittest/xts/ipc/cond/pthread_cond_test.c b/testsuites/unittest/xts/ipc/cond/pthread_cond_test.c index 189cd5ef..9e42c133 100644 --- a/testsuites/unittest/xts/ipc/cond/pthread_cond_test.c +++ b/testsuites/unittest/xts/ipc/cond/pthread_cond_test.c @@ -65,6 +65,7 @@ LITE_TEST_CASE(PthreadCondApiTestSuite, testPthreadCondInit, Function | MediumTe pthread_cond_t cond2; ret = pthread_cond_init(&cond2, NULL); ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); + return 0; } /** @@ -92,8 +93,9 @@ LITE_TEST_CASE(PthreadCondApiTestSuite, testPthreadCondDestroy, Function | Mediu ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER; - ret =pthread_cond_destroy(&cond3); + ret = pthread_cond_destroy(&cond3); ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); + return 0; } /** @@ -108,10 +110,11 @@ LITE_TEST_CASE(PthreadCondApiTestSuite, testPthreadCondattrInit, Function | Medi ret = pthread_condattr_init(&condAttr); ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); - ret =pthread_condattr_destroy(&condAttr); + ret = pthread_condattr_destroy(&condAttr); ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); ret = pthread_condattr_init(&condAttr); ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); + return 0; } // pthread_cond_broadcast @@ -179,6 +182,7 @@ EXIT: ret = pthread_mutex_destroy(&g_mtx3); ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); ICUNIT_ASSERT_EQUAL(testInt, TEST_SEEK_SIZE, testInt); + return 0; } RUN_TEST_SUITE(PthreadCondApiTestSuite); diff --git a/testsuites/unittest/xts/ipc/msg_queue/mq_exp_test.c b/testsuites/unittest/xts/ipc/msg_queue/mq_exp_test.c new file mode 100644 index 00000000..fcc23090 --- /dev/null +++ b/testsuites/unittest/xts/ipc/msg_queue/mq_exp_test.c @@ -0,0 +1,670 @@ +/* + * Copyright (c) 2023-2023 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 "xts_ipc.h" + +LITE_TEST_SUIT(IPC, IpcMqExceptionApi, IpcMqExceptionApiTestSuite); + +static BOOL IpcMqExceptionApiTestSuiteSetUp(void) +{ + return TRUE; +} + +static BOOL IpcMqExceptionApiTestSuiteTearDown(void) +{ + return TRUE; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_RECEIVE_0200 + * @tc.name mq_receive function errno for EBADF and EMSGSIZE test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqReceiveEBADFEMSGSIZE001, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct mq_attr attr = { 0 }; + struct mq_attr getAttr = { 0 }; + char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN], rMsgErr[1]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqReceiveEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_receive(NULL, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_receive(queue, rMsgErr, sizeof(rMsgErr), &prio); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EMSGSIZE, errno); + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_RECEIVE_0200 + * @tc.name mq_receive function errno for EBADF and EMSGSIZE test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqReceiveEBADFEMSGSIZE002, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct mq_attr attr = { 0 }; + struct mq_attr getAttr = { 0 }; + char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqReceiveEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_WRONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + ret = mq_getattr(queue, &getAttr); + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + attr.mq_flags |= O_NONBLOCK; + ret = mq_setattr(queue, &attr, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_RECEIVE_0300 + * @tc.name mq_receive function errno for EINVAL test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqReceiveEINVAL, Function | MediumTest | Level3) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct mq_attr attr = { 0 }; + char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqReceiveEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = mq_receive(queue, rMsg, 0, &prio); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0100 + * @tc.name mq_timedsend function errno for EAGAIN and EBADF test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendEAGAINEBADF, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + char qName[MQ_NAME_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = 1; /* 1, common data for test, no special meaning */ + queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ts.tv_sec = 0; + ts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EAGAIN, errno); + ret = mq_timedsend(NULL, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + + attr.mq_flags |= O_NONBLOCK; + ret = mq_setattr(queue, &attr, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0200 + * @tc.name mq_timedsend function errno for EINVAL test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendEINVAL, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + char qName[MQ_NAME_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + for (int i = 0; i < 3; i++) { /* 3, common data for test, no special meaning */ + switch (i) { + case 0: + ts.tv_sec = -1; /* -1, common data for test, no special meaning */ + ts.tv_nsec = 0; + break; + case 1: + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = -1; /* -1, common data for test, no special meaning */ + break; + case 2: + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = 1000000000UL + 1UL; + break; + } + + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + } + ret = mq_timedsend(queue, MQ_MSG, 0, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0300 + * @tc.name mq_timedsend function errno for EMSGSIZE test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendEMSGSIZE, Function | MediumTest | Level3) +{ + int ret; + mqd_t queue; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + char qName[MQ_NAME_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendEMSGSIZE_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = 1; /* 1, common data for test, no special meaning */ + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EMSGSIZE, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDSEND_0400 + * @tc.name mq_timedsend function errno for ETIMEDOUT test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedSendETIMEDOUT, Function | MediumTest | Level3) +{ + int ret; + mqd_t queue; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + char qName[MQ_NAME_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedSendETIMEDOUT_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = 1; /* 1, common data for test, no special meaning */ + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ts.tv_sec = 0; + ts.tv_nsec = 100; /* 100, common data for test, no special meaning */ + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, ETIMEDOUT, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0100 + * @tc.name mq_timedreceive function errno for EAGAIN and EBADF test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveEAGAINEBADF, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + struct mq_attr getAttr = { 0 }; + char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveEAGAIN_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = 0; + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EAGAIN, errno); + ret = mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_WRONLY | O_NONBLOCK, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + + attr.mq_flags |= O_NONBLOCK; + ret = mq_setattr(queue, &attr, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_timedreceive(NULL, rMsg, getAttr.mq_msgsize, &prio, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0200 + * @tc.name mq_timedreceive function errno for EINVAL test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveEINVAL, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + struct mq_attr getAttr = { 0 }; + char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + for (int i = 0; i < 3; i++) { /* 3, common data for test, no special meaning */ + switch (i) { + case 0: + ts.tv_sec = -1; /* -1, common data for test, no special meaning */ + ts.tv_nsec = 0; + break; + case 1: + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = -1; /* -1, common data for test, no special meaning */ + break; + case 2: + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = 1000000000UL + 1UL; + break; + } + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + } + ret = mq_timedreceive(queue, rMsg, 0, &prio, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0300 + * @tc.name mq_timedreceive function errno for ETIMEDOUT test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveETIMEDOUT, Function | MediumTest | Level3) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + struct mq_attr getAttr = { 0 }; + char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveETIMEDOUT_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ts.tv_sec = 0; + ts.tv_nsec = 100; /* 100, common data for test, no special meaning */ + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &ts); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, ETIMEDOUT, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_TIMEDRECEIVE_0400 + * @tc.name mq_timedreceive function errno for EMSGSIZE test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqTimedReceiveEMSGSIZE, Function | MediumTest | Level3) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec ts = { 0, 0 }; + struct mq_attr attr = { 0 }; + char qName[MQ_NAME_LEN], rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqTimedReceiveEMSGSIZE_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + attr.mq_msgsize = MQ_MSG_SIZE; + attr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + ts.tv_nsec = 0; + ret = mq_timedreceive(queue, rMsg, 1, &prio, &ts); /* 1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EMSGSIZE, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_UNLINK_0100 + * @tc.name mq_unlink function errno for ENAMETOOLONG test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqUnlinkENAMETOOLONG, Function | MediumTest | Level2) +{ + char qName[MAX_MQ_NAME_LEN + 10]; /* 10, common data for test, no special meaning */ + int i; + for (i = 0; i < MAX_MQ_NAME_LEN + 5; i++) { /* 5, common data for test, no special meaning */ + qName[i] = '8'; + } + qName[i] = '\0'; + int ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, ENAMETOOLONG, errno); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_UNLINK_0200 + * @tc.name mq_unlink function errno for ENOENT test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqUnlinkENOENT, Function | MediumTest | Level2) +{ + char qName[64] = "/mq_file-does-not-exit"; /* 64, common data for test, no special meaning */ + int ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, ENOENT, errno); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_UNLINK_0300 + * @tc.name mq_unlink function errno for EINVAL test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqUnlinkEINVAL, Function | MediumTest | Level3) +{ + int ret = mq_unlink(""); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_GETATTR_0100 + * @tc.name mq_getattr function errno for EBAD and EINVALF test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqGetAttrEBADFEINVAL, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + struct mq_attr mqstat = { 0 }; + char qName[MQ_NAME_LEN]; + + memset_s(&mqstat, sizeof(mqstat), 0, sizeof(mqstat)); + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqSendEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + queue = mq_open(qName, O_CREAT | O_RDWR | O_NONBLOCK, S_IRUSR | S_IWUSR, NULL); + + ret = mq_getattr(NULL, &mqstat); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + + ret = mq_getattr(queue, NULL); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_SETATTR_0100 + * @tc.name mq_receive function errno for EBADF and EINVAL test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqExceptionApiTestSuite, testMqSetAttrEBADFEINVAL, Function | MediumTest | Level2) +{ + int ret; + char qName[MQ_NAME_LEN]; + mqd_t queue; + struct mq_attr gMqstat = { 0 }, sMqstat = { 0 }; + + ret = sprintf_s(qName, MQ_NAME_LEN, "testMqSetAttrEBADFEINVAL_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, NULL); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + memset_s(&gMqstat, sizeof(gMqstat), 0, sizeof(gMqstat)); + memset_s(&sMqstat, sizeof(sMqstat), 0, sizeof(sMqstat)); + ret = mq_getattr(queue, &gMqstat); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + sMqstat.mq_flags |= O_NONBLOCK; + ret = mq_setattr(queue, &sMqstat, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_getattr(queue, &gMqstat); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_NOT_EQUAL(gMqstat.mq_flags, sMqstat.mq_flags, gMqstat.mq_flags); + + ret = mq_setattr(NULL, &sMqstat, NULL); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EBADF, errno); + ret = mq_setattr(queue, NULL, NULL); + ICUNIT_ASSERT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +RUN_TEST_SUITE(IpcMqExceptionApiTestSuite); + +void IpcMqExceptionFuncTest(void) +{ + RUN_ONE_TESTCASE(testMqReceiveEBADFEMSGSIZE001); + RUN_ONE_TESTCASE(testMqReceiveEBADFEMSGSIZE002); + RUN_ONE_TESTCASE(testMqReceiveEINVAL); + RUN_ONE_TESTCASE(testMqTimedSendEAGAINEBADF); + RUN_ONE_TESTCASE(testMqTimedSendEINVAL); + RUN_ONE_TESTCASE(testMqTimedSendEMSGSIZE); + RUN_ONE_TESTCASE(testMqTimedSendETIMEDOUT); + RUN_ONE_TESTCASE(testMqTimedReceiveEAGAINEBADF); + RUN_ONE_TESTCASE(testMqTimedReceiveEINVAL); + RUN_ONE_TESTCASE(testMqTimedReceiveETIMEDOUT); + RUN_ONE_TESTCASE(testMqTimedReceiveEMSGSIZE); + RUN_ONE_TESTCASE(testMqUnlinkENAMETOOLONG); + RUN_ONE_TESTCASE(testMqUnlinkENOENT); + RUN_ONE_TESTCASE(testMqUnlinkEINVAL); + RUN_ONE_TESTCASE(testMqGetAttrEBADFEINVAL); + RUN_ONE_TESTCASE(testMqSetAttrEBADFEINVAL); +} diff --git a/testsuites/unittest/xts/ipc/msg_queue/mq_test.c b/testsuites/unittest/xts/ipc/msg_queue/mq_test.c new file mode 100644 index 00000000..6ffe1d30 --- /dev/null +++ b/testsuites/unittest/xts/ipc/msg_queue/mq_test.c @@ -0,0 +1,511 @@ +/* + * Copyright (c) 2023-2023 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 "xts_ipc.h" + +LITE_TEST_SUIT(IPC, IpcMqApi, IpcMqApiTestSuite); + +static BOOL IpcMqApiTestSuiteSetUp(void) +{ + return TRUE; +} + +static BOOL IpcMqApiTestSuiteTearDown(void) +{ + return TRUE; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_0100 + * @tc.name mq_send and mq_receive function test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqOneLevelCom, Function | MediumTest | Level0) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + char rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, sizeof(qName), "testMqOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, MQ_MSG_SIZE, getAttr.mq_msgsize); + ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, MQ_MAX_MSG, getAttr.mq_maxmsg); + + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, 0, prio); + + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_0200 + * @tc.name mq_timedsend and mq_timedreceive function test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqTimedOneLevelCom, Function | MediumTest | Level1) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec tts = { 0 }; + struct timespec rts = { 0 }; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + char rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, sizeof(qName), "testMqTimedOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + tts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, MQ_MSG_SIZE, getAttr.mq_msgsize); + ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, MQ_MAX_MSG, getAttr.mq_maxmsg); + + rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + rts.tv_nsec = 0; + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, 0, prio); + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_0300 + * @tc.name all send and all receive function test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqAllOneLevelCom001, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + char rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, sizeof(qName), "testMqAllOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + memset_s(&getAttr, sizeof(getAttr), 0, sizeof(getAttr)); + memset_s(&setAttr, sizeof(setAttr), 0, sizeof(setAttr)); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + ret = mq_getattr(queue, &setAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + ret = mq_setattr(queue, &setAttr, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, setAttr.mq_msgsize, getAttr.mq_msgsize); + ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, setAttr.mq_maxmsg, getAttr.mq_maxmsg); + ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */ + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_0300 + * @tc.name all send and all receive function test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqAllOneLevelCom002, Function | MediumTest | Level2) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec tts = { 0 }; + struct timespec rts = { 0 }; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + char rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, sizeof(qName), "testMqAllOneLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + memset_s(&getAttr, sizeof(getAttr), 0, sizeof(getAttr)); + memset_s(&setAttr, sizeof(setAttr), 0, sizeof(setAttr)); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + + tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + tts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(getAttr.mq_msgsize, setAttr.mq_msgsize, getAttr.mq_msgsize); + ICUNIT_ASSERT_EQUAL(getAttr.mq_maxmsg, setAttr.mq_maxmsg, getAttr.mq_maxmsg); + ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */ + + rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + rts.tv_nsec = 0; + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +static void *PthreadCom(void *arg) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct mq_attr getAttr = { 0 }; + char rMsg[MQ_RX_LEN]; + + queue = (mqd_t)arg; + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio); + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return NULL; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_0700 + * @tc.name mq_send and mq_receive function test in thread and process + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqTwoThreadCom, Function | MediumTest | Level1) +{ + int ret; + mqd_t queue; + pthread_t tid; + unsigned int prio; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + char rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, sizeof(qName), "testMqTwoLevelCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = pthread_create(&tid, NULL, PthreadCom, (void *)queue); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = pthread_join(tid, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */ + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio); + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +static void *PthreadTimedCom(void *arg) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec tts = { 0 }; + struct timespec rts = { 0 }; + struct mq_attr getAttr = { 0 }; + char rMsg[MQ_RX_LEN]; + + queue = (mqd_t)arg; + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + rts.tv_nsec = 0; + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio); + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + tts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + return NULL; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_0800 + * @tc.name mq_timedsend and mq_timedreceive function test in thread and process + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqTimedTwoThreadCom, Function | MediumTest | Level1) +{ + int ret; + mqd_t queue; + pthread_t tid; + unsigned int prio; + struct timespec tts = { 0 }; + struct timespec rts = { 0 }; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + char rMsg[MQ_RX_LEN]; + ret = sprintf_s(qName, sizeof(qName), "testMqTimedTwoThreadCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = pthread_create(&tid, NULL, PthreadTimedCom, (void *)queue); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + + tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + tts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = pthread_join(tid, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */ + rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + rts.tv_nsec = 0; + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio); + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +static void *PthreadAllCom(void *arg) +{ + int ret; + mqd_t queue; + unsigned int prio; + struct timespec tts = { 0 }; + struct timespec rts = { 0 }; + struct mq_attr getAttr = { 0 }; + char rMsg[MQ_RX_LEN]; + + queue = (mqd_t)arg; + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + rts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + rts.tv_nsec = 0; + ret = mq_timedreceive(queue, rMsg, getAttr.mq_msgsize, &prio, &rts); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio); + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + tts.tv_sec = time(NULL) + 1; /* 1, common data for test, no special meaning */ + tts.tv_nsec = 0; + ret = mq_timedsend(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO, &tts); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + return NULL; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_0900 + * @tc.name all send and all receive function test in thread and process + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqAllTwoThreadCom, Function | MediumTest | Level1) +{ + int ret; + mqd_t queue; + pthread_t tid; + unsigned int prio; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + char rMsg[MQ_RX_LEN]; + + ret = sprintf_s(qName, sizeof(qName), "testMqAllTwoThreadCom_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + ret = pthread_create(&tid, NULL, PthreadAllCom, (void *)queue); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + + ret = mq_send(queue, MQ_MSG, MQ_MSG_LEN, MQ_MSG_PRIO); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = pthread_join(tid, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ICUNIT_ASSERT_EQUAL(getAttr.mq_curmsgs, 1, getAttr.mq_curmsgs); /* 1, common data for test, no special meaning */ + ret = mq_receive(queue, rMsg, getAttr.mq_msgsize, &prio); + ICUNIT_ASSERT_NOT_EQUAL(ret, -1, ret); /* -1, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(prio, MQ_MSG_PRIO, prio); + ret = strncmp(MQ_MSG, rMsg, MQ_MSG_LEN); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +/* * + * @tc.number SUB_KERNEL_IPC_MQ_1200 + * @tc.name mq_setattr set and clean mq_flags for O_NONBLOCK function test + * @tc.desc [C- SOFTWARE -0200] + */ +LITE_TEST_CASE(IpcMqApiTestSuite, testMqSetGetAttr, Function | MediumTest | Level1) +{ + int ret; + mqd_t queue; + struct mq_attr getAttr = { 0 }; + struct mq_attr setAttr = { 0 }; + char qName[MQ_NAME_LEN]; + + ret = sprintf_s(qName, sizeof(qName), "testMqFunction_%d", GetRandom(10000)); /* 10000, common data for test, no special meaning */ + ICUNIT_ASSERT_EQUAL(ret, strlen(qName), ret); + memset_s(&setAttr, sizeof(setAttr), 0, sizeof(setAttr)); + setAttr.mq_msgsize = MQ_MSG_SIZE; + setAttr.mq_maxmsg = MQ_MAX_MSG; + setAttr.mq_flags = O_NONBLOCK; + queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &setAttr); + ICUNIT_ASSERT_NOT_EQUAL(queue, (mqd_t)-1, queue); /* -1, common data for test, no special meaning */ + + memset_s(&getAttr, sizeof(getAttr), 0, sizeof(getAttr)); + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = (getAttr.mq_flags & O_NONBLOCK); + ICUNIT_ASSERT_EQUAL(ret, O_NONBLOCK, ret); + + setAttr.mq_flags &= ~O_NONBLOCK; + ret = mq_setattr(queue, &setAttr, NULL); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + + ret = mq_getattr(queue, &getAttr); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = (getAttr.mq_flags & O_NONBLOCK); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_close(queue); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + ret = mq_unlink(qName); + ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; +} + +RUN_TEST_SUITE(IpcMqApiTestSuite); + +void IpcMqFuncTest(void) +{ + RUN_ONE_TESTCASE(testMqOneLevelCom); + RUN_ONE_TESTCASE(testMqTimedOneLevelCom); + RUN_ONE_TESTCASE(testMqAllOneLevelCom001); + RUN_ONE_TESTCASE(testMqAllOneLevelCom002); + RUN_ONE_TESTCASE(testMqTwoThreadCom); + RUN_ONE_TESTCASE(testMqTimedTwoThreadCom); + RUN_ONE_TESTCASE(testMqAllTwoThreadCom); + RUN_ONE_TESTCASE(testMqSetGetAttr); +} diff --git a/testsuites/unittest/xts/ipc/mutex/pthread_mutex_test.c b/testsuites/unittest/xts/ipc/mutex/pthread_mutex_test.c index 700e2866..c6885bc8 100644 --- a/testsuites/unittest/xts/ipc/mutex/pthread_mutex_test.c +++ b/testsuites/unittest/xts/ipc/mutex/pthread_mutex_test.c @@ -128,6 +128,7 @@ LITE_TEST_CASE(PthreadMutexApiTestSuite, testPthreadMutexCond, Function | Medium ret = pthread_join(tid[1], NULL); /* 1, common data for test, no special meaning */ ICUNIT_ASSERT_EQUAL(ret, POSIX_IPC_NO_ERROR, ret); ICUNIT_ASSERT_EQUAL(g_st1.count, POSIX_IPC_NO_ERROR, g_st1.count); + return 0; } RUN_TEST_SUITE(PthreadMutexApiTestSuite); diff --git a/testsuites/unittest/xts/ipc/semaphone/sem_abn_test.c b/testsuites/unittest/xts/ipc/semaphone/sem_abn_test.c index 7638ec42..77b3a8a6 100644 --- a/testsuites/unittest/xts/ipc/semaphone/sem_abn_test.c +++ b/testsuites/unittest/xts/ipc/semaphone/sem_abn_test.c @@ -63,6 +63,7 @@ LITE_TEST_CASE(SemAbnormalTestSuite, testSemInitAbnormalSemvaluemax, Function | ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -80,7 +81,7 @@ LITE_TEST_CASE(SemAbnormalTestSuite, testSemInitAbnormalGtsemvaluemax, Function ICUNIT_GOTO_EQUAL(ret, -1, ret, EXIT); /* -1, common data for test, no special meaning */ ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno); EXIT: - return; + return 0; } /** @@ -98,6 +99,7 @@ LITE_TEST_CASE(SemAbnormalTestSuite, testSemInitAbnormalInitTwice, Function | Me ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -120,6 +122,7 @@ LITE_TEST_CASE(SemAbnormalTestSuite, testSemPostAbnormal, Function | MediumTest EXIT: ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -149,6 +152,7 @@ EXIT: ICUNIT_ASSERT_EQUAL(semValue, 0, semValue); ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -177,6 +181,7 @@ EXIT: ICUNIT_ASSERT_EQUAL(semValue, 0, semValue); ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } RUN_TEST_SUITE(SemAbnormalTestSuite); diff --git a/testsuites/unittest/xts/ipc/semaphone/sem_test.c b/testsuites/unittest/xts/ipc/semaphone/sem_test.c index 2a572a95..3ef39856 100644 --- a/testsuites/unittest/xts/ipc/semaphone/sem_test.c +++ b/testsuites/unittest/xts/ipc/semaphone/sem_test.c @@ -59,6 +59,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testSemInit0100, Function | MediumTest | Leve ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); } + return 0; } LITE_TEST_CASE(IpcSemApiTestSuite, testSemPost0100, Function | MediumTest | Level2) @@ -80,6 +81,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testSemPost0100, Function | MediumTest | Leve ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } LITE_TEST_CASE(IpcSemApiTestSuite, testSemWait0100, Function | MediumTest | Level2) @@ -101,6 +103,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testSemWait0100, Function | MediumTest | Leve ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } void *ThreadChat(void *arg) @@ -153,6 +156,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testThreadChat0100, Function | MediumTest | L ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } void *ThreadNThreadWait1(void *arg) @@ -250,6 +254,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testThreadChat0400, Function | MediumTest | L ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } LITE_TEST_CASE(IpcSemApiTestSuite, testSemInitAbnormal0200, Function | MediumTest | Level3) @@ -274,6 +279,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testSemInitAbnormal0200, Function | MediumTes ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } LITE_TEST_CASE(IpcSemApiTestSuite, testSemPostAbnormal, Function | MediumTest | Level3) @@ -289,6 +295,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testSemPostAbnormal, Function | MediumTest | ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } LITE_TEST_CASE(IpcSemApiTestSuite, testSemTimedWaitAbnormalA, Function | MediumTest | Level3) @@ -309,6 +316,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testSemTimedWaitAbnormalA, Function | MediumT ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } LITE_TEST_CASE(IpcSemApiTestSuite, testSemTimedWaitAbnormalB, Function | MediumTest | Level3) @@ -329,6 +337,7 @@ LITE_TEST_CASE(IpcSemApiTestSuite, testSemTimedWaitAbnormalB, Function | MediumT ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } RUN_TEST_SUITE(IpcSemApiTestSuite); diff --git a/testsuites/unittest/xts/ipc/semaphone/sem_xts_test.c b/testsuites/unittest/xts/ipc/semaphone/sem_xts_test.c index fd08c36a..cc0106e6 100644 --- a/testsuites/unittest/xts/ipc/semaphone/sem_xts_test.c +++ b/testsuites/unittest/xts/ipc/semaphone/sem_xts_test.c @@ -64,6 +64,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testSemInitA, Function | MediumTest | Leve ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -88,6 +89,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testSemInitB, Function | MediumTest | Leve ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -112,6 +114,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testSemInitC, Function | MediumTest | Leve ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -149,6 +152,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testSemPost, Function | MediumTest | Level ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -186,6 +190,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testSemWait, Function | MediumTest | Level ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } /** @@ -203,6 +208,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testSemdestroy, Function | MediumTest | Le ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } void *ThreadChatF01(void *arg) @@ -256,6 +262,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testThreadChat, Function | MediumTest | Le ICUNIT_ASSERT_EQUAL(reInt, 0, reInt); reInt = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(reInt, 0, reInt); + return 0; } void *ThreadSemTimedWait(void *arg) @@ -318,6 +325,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testThreadSemTimedWait, Function | MediumT ICUNIT_ASSERT_EQUAL(reInt, 0, reInt); ret = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(ret, 0, ret); + return 0; } void *ThreadNThreadWaitF01(void *arg) @@ -411,6 +419,7 @@ LITE_TEST_CASE(IpcSemApiXtsTestSuite, testNThreadWait, Function | MediumTest | L ICUNIT_ASSERT_EQUAL(reInt, 0, reInt); reInt = sem_destroy(&sem); ICUNIT_ASSERT_EQUAL(reInt, 0, reInt); + return 0; } RUN_TEST_SUITE(IpcSemApiXtsTestSuite); diff --git a/testsuites/unittest/xts/ipc/xts_ipc.c b/testsuites/unittest/xts/ipc/xts_ipc.c index 7e3bc406..c6d09071 100644 --- a/testsuites/unittest/xts/ipc/xts_ipc.c +++ b/testsuites/unittest/xts/ipc/xts_ipc.c @@ -34,10 +34,9 @@ void IpcSemApiTest(void) { PosixFutexCondTest(); PosixFutexMutexTest(); - + IpcMqExceptionFuncTest(); + IpcMqFuncTest(); PosixSemFuncTest(); PosixSemAbnFuncTest(); PosixSemXtsFuncTest(); - - return; } \ No newline at end of file diff --git a/testsuites/unittest/xts/ipc/xts_ipc.h b/testsuites/unittest/xts/ipc/xts_ipc.h index 190d1b77..50463a89 100644 --- a/testsuites/unittest/xts/ipc/xts_ipc.h +++ b/testsuites/unittest/xts/ipc/xts_ipc.h @@ -43,22 +43,39 @@ #include #include #include +#include +#include +#include +#include +#include +#include #define NANO_S 1000000000 #define NANO_MS 1000000 - #define TEN_CONT 10 #define FIFTY_CONT 50 #define HUNDRED_CONT 100 - #define TEST_INTP_SIZE 10 #define TEST_SEEK_SIZE 12 -#define POSIX_IPC_NO_ERROR 0 - +#define POSIX_IPC_NO_ERROR 0 #define KERNEL_NS_PER_SECOND 1000000000 #define SEM_VALUE_MAX 0xFFFE - #define KERNEL_NS_PER_SECOND 1000000000 #define KERNEL_100MS_BY_NS 100000000 +#define MQ_NAME_LEN 64 +#define MQ_TX_LEN 64 +#define MQ_RX_LEN 64 +#define MQ_MSG_SIZE 64 +#define MQ_MSG_PRIO 0 +#define MQ_MAX_MSG 16 +#define MQ_MAX_QN_LEN 24 +#define MAX_SIGNAL_NUMBER 64 +#define MAX_PIPE_BUFFER 1023 +#define MAX_PIPE_NUMBER 32 +#define MAX_MQ_NUMBER LOSCFG_BASE_IPC_QUEUE_LIMIT +#define MAX_MQ_NAME_LEN 2560 +#define MAX_MQ_MSG_SIZE 65530 +#define MQ_MSG "MessageToSend" +#define MQ_MSG_LEN sizeof(MQ_MSG) #endif \ No newline at end of file diff --git a/testsuites/unittest/xts/math/BUILD.gn b/testsuites/unittest/xts/math/BUILD.gn new file mode 100644 index 00000000..51e7d703 --- /dev/null +++ b/testsuites/unittest/xts/math/BUILD.gn @@ -0,0 +1,43 @@ +# Copyright (c) 2023-2023 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. + +import("//kernel/liteos_m/liteos.gni") + +static_library("math_test") { + sources = [ + "math_api_test.c", + "math_std_api_test.c", + "xts_math.c", + ] + + include_dirs = [ + ".", + "$LITEOSTOPDIR/testsuites/include", + "$LITEOSTOPDIR/testsuites/unittest/xts", + ] +} diff --git a/testsuites/unittest/xts/math/math_api_test.c b/testsuites/unittest/xts/math/math_api_test.c new file mode 100644 index 00000000..f620c531 --- /dev/null +++ b/testsuites/unittest/xts/math/math_api_test.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2023-2023 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 "xts_math.h" + +LITE_TEST_SUIT(MATH, MathApi, MathApiTestSuite); + +static BOOL MathApiTestSuiteSetUp(void) +{ + return TRUE; +} + +static BOOL MathApiTestSuiteTearDown(void) +{ + return TRUE; +} + +/** +* @tc.number SUB_KERNEL_MATH_MATH_SIGNBIT_0100 +* @tc.name test signbit api +* @tc.desc [C- SOFTWARE -0100] +**/ +LITE_TEST_CASE(MathApiTestSuite, testsignbit, Function | MediumTest | Level1) +{ + const int testCount = 3; /* 3 common data for test, no special meaning */ + float testValues[] = {3.000001, -3.000001, 0.0}; /* 3.000001, -3.000001 common data for test, no special meaning */ + float expected[] = {0, 1, 0}; /* 1 common data for test, no special meaning */ + float ret; + for (int i = 0; i < testCount; ++i) { + ret = signbit(testValues[i]); + ICUNIT_ASSERT_EQUAL(ret, expected[i], ret); + } + return 0; +} + +RUN_TEST_SUITE(MathApiTestSuite); + +void MathApiTest(void) +{ + RUN_ONE_TESTCASE(testsignbit); +} diff --git a/testsuites/unittest/xts/math/math_std_api_test.c b/testsuites/unittest/xts/math/math_std_api_test.c new file mode 100644 index 00000000..a661d7ec --- /dev/null +++ b/testsuites/unittest/xts/math/math_std_api_test.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2023-2023 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 "xts_math.h" + +LITE_TEST_SUIT(MATH, MathStdApi, MathStdApiTestSuite); + +static BOOL MathStdApiTestSuiteSetUp(void) +{ + return TRUE; +} + +static BOOL MathStdApiTestSuiteTearDown(void) +{ + return TRUE; +} + +/** +* @tc.number SUB_KERNEL_MATH_STD_STDLIB_0100 +* @tc.name test abs api +* @tc.desc [C- SOFTWARE -0100] +*/ +LITE_TEST_CASE(MathStdApiTestSuite, testAbs, Function | MediumTest | Level1) +{ + const int testCount = 3; /* 3 common data for test, no special meaning */ + int testValues[] = {-3, 0, 3}; /* -3, 3 common data for test, no special meaning */ + int expected[] = {3, 0, 3}; /* 3 common data for test, no special meaning */ + int ret; + for (int i = 0; i < testCount; ++i) { + ret = abs(testValues[i]); + ICUNIT_ASSERT_EQUAL(ret, expected[i], ret); + } + return 0; +} + +/** +* @tc.number SUB_KERNEL_MATH_STD_LLABS_0100 +* @tc.name test llabs api +* @tc.desc [C- SOFTWARE -0100] +**/ +LITE_TEST_CASE(MathStdApiTestSuite, testllabs, Function | MediumTest | Level1) +{ + const int testCount = 3; /* 3 common data for test, no special meaning */ + intmax_t testValues[] = {2147483649, -2147483649, 0}; /* 2147483649, -2147483649 common data for test, no special meaning */ + intmax_t expected[] = {2147483649, 2147483649, 0}; /* 2147483649, common data for test, no special meaning */ + + long long ret; + for (int i = 0; i < testCount; ++i) { + ret = llabs(testValues[i]); + ICUNIT_ASSERT_EQUAL(ret, expected[i], ret); + } + return 0; +} + +RUN_TEST_SUITE(MathStdApiTestSuite); + +void MathStdApiTest(void) +{ + RUN_ONE_TESTCASE(testAbs); + RUN_ONE_TESTCASE(testllabs); +} diff --git a/testsuites/unittest/xts/math/xts_math.c b/testsuites/unittest/xts/math/xts_math.c new file mode 100644 index 00000000..1b1374c7 --- /dev/null +++ b/testsuites/unittest/xts/math/xts_math.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023-2023 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 "xts_test.h" + +void MathFuncTest(void) +{ + MathApiTest(); + MathStdApiTest(); +} \ No newline at end of file diff --git a/testsuites/unittest/xts/math/xts_math.h b/testsuites/unittest/xts/math/xts_math.h new file mode 100644 index 00000000..2b1174a7 --- /dev/null +++ b/testsuites/unittest/xts/math/xts_math.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023-2023 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 XTS_MATH_H +#define XTS_MATH_H + +#include "xts_test.h" +#include +#include +#include +#include +#include +#include + +#endif \ No newline at end of file diff --git a/testsuites/unittest/xts/xts_test.c b/testsuites/unittest/xts/xts_test.c index 85e61ee8..2da4f457 100644 --- a/testsuites/unittest/xts/xts_test.c +++ b/testsuites/unittest/xts/xts_test.c @@ -30,8 +30,17 @@ #include "xts_test.h" +uint32_t GetRandom(uint32_t max) +{ + if (max == 0 || max == 1) { /* 1, common data for test, no special meaning */ + return 1; + } + return (rand() % max) + 1; /* 1, common data for test, no special meaning */ +} + void XtsTestSuite(void) { IpcSemApiTest(); IoFuncTest(); + MathFuncTest(); } diff --git a/testsuites/unittest/xts/xts_test.h b/testsuites/unittest/xts/xts_test.h index 3bec36cc..121ff81d 100644 --- a/testsuites/unittest/xts/xts_test.h +++ b/testsuites/unittest/xts/xts_test.h @@ -32,6 +32,7 @@ #define _XTS_TEST_H #include +#include #include "iCunit.h" #define TEST_STR(func) ItLos##func @@ -50,10 +51,14 @@ #define RUN_ONE_TESTCASE(caseName) ADD_TEST_CASE(caseName) #define AUTO_RUN_ONE_TESTCASEFUNC(func) UnityDefaultTestRun(func, __FILE__, __LINE__) +uint32_t GetRandom(uint32_t max); + void XtsTestSuite(void); extern void IpcSemApiTest(void); extern void IoFuncTest(void); +extern void MathFuncTest(void); + #endif