From ad6f249d1ea878f06864d79bdbed772b21eeac49 Mon Sep 17 00:00:00 2001 From: LiteOS2021 Date: Wed, 26 Jan 2022 14:50:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(posix=20unittest):=20posix=20unittest=20?= =?UTF-8?q?=E8=9E=8D=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit posix unittest 融合 Signed-off-by: LiteOS2021 --- testsuites/unittest/posix/src/common_test.h | 12 ++++++++-- .../posix/src/fs/posix_fs_func_test.c | 3 ++- .../unittest/posix/src/math/math_func_test.c | 4 ++-- .../posix/src/mqueue/mqueue_func_test.c | 19 ++++++++------- .../src/pthread/pthread_cond_func_test.c | 5 ++++ .../posix/src/time/time_func_test_01.c | 23 ++++++++++--------- 6 files changed, 42 insertions(+), 24 deletions(-) diff --git a/testsuites/unittest/posix/src/common_test.h b/testsuites/unittest/posix/src/common_test.h index 4744d7c2..a075f41b 100644 --- a/testsuites/unittest/posix/src/common_test.h +++ b/testsuites/unittest/posix/src/common_test.h @@ -29,8 +29,8 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef KERNEL_TEST_H -#define KERNEL_TEST_H +#ifndef COMMON_TEST_H +#define COMMON_TEST_H #define TESTCOUNT_NUM_1 1 #define TESTCOUNT_NUM_2 2 @@ -83,6 +83,14 @@ } \ } while (0) +#define ICUNIT_ASSERT_NOT_EQUAL_VOID(param, value, retcode) \ + do { \ + if ((param) == (value)) { \ + TEST_ASSERT_EQUAL(param, value); \ + return; \ + } \ + } while (0) + #define ICUNIT_TRACK_EQUAL(param, value, retcode) \ do { \ if ((param) != (value)) { \ diff --git a/testsuites/unittest/posix/src/fs/posix_fs_func_test.c b/testsuites/unittest/posix/src/fs/posix_fs_func_test.c index a641414b..0257303a 100644 --- a/testsuites/unittest/posix/src/fs/posix_fs_func_test.c +++ b/testsuites/unittest/posix/src/fs/posix_fs_func_test.c @@ -54,7 +54,7 @@ LITE_TEST_SUIT(Posix, PosixFs, PosixFsFuncTestSuite); /* Corresponding to different platforms, only need to modify TEST_ROOT */ -#define TEST_ROOT "/ram" +#define TEST_ROOT "/littlefs" #define TEST_FILE_PTAH_RIGHT TEST_ROOT"/FILE0" /* file path, to open/rd/close */ @@ -1459,6 +1459,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat003, Function | MediumTest | Leve ssize_t size; char writeBuf[TEST_BUF_SIZE] = "write test"; + (void)memset_s(&buf, sizeof(buf), 0, sizeof(buf)); fd = open(tmpFileName, O_CREAT | O_RDWR, 0777); TEST_ASSERT_TRUE(ret != -1); diff --git a/testsuites/unittest/posix/src/math/math_func_test.c b/testsuites/unittest/posix/src/math/math_func_test.c index 98a78ffe..c752b706 100644 --- a/testsuites/unittest/posix/src/math/math_func_test.c +++ b/testsuites/unittest/posix/src/math/math_func_test.c @@ -276,8 +276,8 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow002, Function | MediumTest | L LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow003, Function | MediumTest | Level1) { double testValues[][TEST_EXPECTED + 1] = { - {0.0, -7, -HUGE_VAL}, - {-0.0, -6.22, -HUGE_VAL}, + {0.0, -7, HUGE_VAL}, + {-0.0, -6.22, HUGE_VAL}, {-7.23, 3.57, NAN}, {121223, 5674343, HUGE_VAL} }; diff --git a/testsuites/unittest/posix/src/mqueue/mqueue_func_test.c b/testsuites/unittest/posix/src/mqueue/mqueue_func_test.c index ec211f01..6dc684c1 100644 --- a/testsuites/unittest/posix/src/mqueue/mqueue_func_test.c +++ b/testsuites/unittest/posix/src/mqueue/mqueue_func_test.c @@ -34,8 +34,10 @@ #include #include #include "common_test.h" +#include "kernel_test.h" +#include "log.h" -#define MQUEUE_STANDARD_NAME_LENGTH 50 +#define MQUEUE_STANDARD_NAME_LENGTH 52 #define MQUEUE_NO_ERROR 0 #define MQUEUE_SEND_STRING_TEST "mq_test" #define MQUEUE_SHORT_ARRAY_LENGTH strlen(MQUEUE_SEND_STRING_TEST) @@ -49,7 +51,7 @@ const int MQ_MAX_MSG = 16; // mqueue message number const char MQ_MSG[] = "MessageToSend"; // mqueue message to send const int MQ_MSG_LEN = sizeof(MQ_MSG); // mqueue message len to send -const int MAX_MQ_NUMBER = 1024; // max mqueue number +const int MAX_MQ_NUMBER = LOSCFG_BASE_IPC_QUEUE_LIMIT - 1; // max mqueue number const int MAX_MQ_NAME_LEN = 256; // max mqueue name length const int MAX_MQ_MSG_SIZE = 65530; // max mqueue message size @@ -289,6 +291,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le mqd_t queue[MAX_MQ_NUMBER + 1]; int flag = 0; int i; + (void)memset_s(queue, sizeof(queue), 0, sizeof(queue)); for (i=0; i__tm_zone = "UTC+8"; ftime = strftime(buffer, 80, "%F %T %Z", tmTime); - TEST_ASSERT_EQUAL_INT(0, ftime); + TEST_ASSERT_EQUAL_INT(20, ftime); LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40"); }; @@ -546,7 +547,7 @@ RUN_TEST_SUITE(PosixTimeFuncTestSuite); void PosixTimeFuncTest() { - LOG("begin PosixTimeFuncTest...."); + LOG("begin PosixTimeFuncTest....\n"); RUN_ONE_TESTCASE(testTimeUSleep001); RUN_ONE_TESTCASE(testTimeUSleep002);