未验证 提交 6a7a18e2 编写于 作者: O openharmony_ci 提交者: Gitee

!723 Fix: 对测试用例中的POSIX相关的测试用例添加入口

Merge pull request !723 from yinjiaming/master
......@@ -45,6 +45,8 @@ kernel_module("test_init") {
"src/osTest.c",
]
include_dirs = [ "unittest/posix/src" ]
configs += [ ":include" ]
}
......@@ -63,6 +65,7 @@ group("testsuites") {
"sample/kernel/swtmr:test_swtmr",
"sample/kernel/task:test_task",
"sample/posix:test_posix",
"unittest/posix:posix_test",
]
if (defined(LOSCFG_DYNLINK)) {
deps += [ "sample/kernel/dynlink:test_dynlink" ]
......
......@@ -35,6 +35,9 @@
#if (LITEOS_CMSIS_TEST == 1)
#include "cmsis_os.h"
#endif
#if (LOS_POSIX_TEST == 1)
#include "posix_test.h"
#endif
UINT32 volatile g_testCount;
UINT32 g_testTskHandle;
......@@ -221,11 +224,7 @@ VOID TestTaskEntry()
TestKernel();
#if (LOS_POSIX_TEST == 1)
ret = PthreadFuncTestSuite();
if (ret != 0) {
PRINTF("PthreadFuncTestSuite start failed! errno: %u\n", ret);
return;
}
ItSuitePosix();
#endif
#if (LOS_CMSIS_TEST == 1)
......
......@@ -29,8 +29,7 @@
import("//test/xts/tools/lite/build/suite_lite.gni")
hctest_suite("PosixTest") {
suite_name = "acts"
static_library("posix_test") {
sources = [
"src/ctype/ctype_func_test.c",
"src/ctype/isdigit_test.c",
......@@ -42,7 +41,7 @@ hctest_suite("PosixTest") {
"src/fs/posix_fs_func_test.c",
"src/math/math_func_test.c",
"src/mqueue/mqueue_func_test.c",
"src/pthread/pthread_cond_func_test.c",
"src/posix_test.c",
"src/regex/regex_func_test.c",
"src/semaphore/semaphore_func_test.c",
"src/stdarg/stdarg_func_test.c",
......@@ -65,6 +64,7 @@ hctest_suite("PosixTest") {
"//test/xts/tools/hctest/include",
"src",
]
cflags = [ "-Wno-error" ]
deps = [ "//kernel/liteos_m/kal/posix" ]
configs += [ "//kernel/liteos_m/testsuites:include" ]
}
......@@ -49,63 +49,6 @@
#define THREAD_COUNT_MAX 30
#define THREAD_STACK_SPACE_MAX 4096
#define ICUNIT_GOTO_NOT_EQUAL(param, value, retcode, label) \
do { \
if ((param) == (value)) { \
TEST_ASSERT_NOT_EQUAL(param, value); \
printf("\nret = %d, expect = %d\n", param, value); \
goto label; \
} \
} while (0)
#define ICUNIT_GOTO_EQUAL(param, value, retcode, label) \
do { \
if ((param) != (value)) { \
TEST_ASSERT_EQUAL(param, value); \
printf("\nret = %d, expect = %d\n", param, value); \
goto label; \
} \
} while (0)
#define ICUNIT_GOTO_STRING_EQUAL(str1, str2, retcode, label) \
do { \
if (strcmp(str1, str2) != 0) { \
TEST_ASSERT_EQUAL(retcode, retcode + 1); \
goto label; \
} \
} while (0)
#define ICUNIT_ASSERT_EQUAL_VOID(param, value, retcode) \
do { \
if ((param) != (value)) { \
TEST_ASSERT_EQUAL(param, value); \
return; \
} \
} 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)) { \
TEST_ASSERT_EQUAL(param, value); \
printf("\nret = %d, expect = %d\n", param, value); \
} \
} while (0)
#define ICUNIT_TRACK_NOT_EQUAL(param, value, retcode) \
do { \
if ((param) == (value)) { \
TEST_ASSERT_NOT_EQUAL(param, value); \
printf("\nret = %d, expect = %d\n", param, value); \
} \
} while (0)
#ifdef __cplusplus
#if __cplusplus
#endif
......
......@@ -30,8 +30,8 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "los_config.h"
#include "posix_test.h"
#include "kernel_test.h"
#include "log.h"
......@@ -75,6 +75,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum001, Function | MediumTe
int src = 'A';
int ret = isalnum(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -87,6 +88,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum002, Function | MediumTe
int src = '1';
int ret = isalnum(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -99,6 +101,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum003, Function | MediumTe
int src = '@';
int ret = isalnum(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -111,6 +114,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum004, Function | MediumTe
int src = ' ';
int ret = isalnum(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -123,6 +127,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsalnum005, Function | MediumTe
int src = '\f'; // 0x0c 14
int ret = isalnum(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
......@@ -136,6 +141,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii001, Function | MediumTe
const int src = -1;
int ret = isascii(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -148,6 +154,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii002, Function | MediumTe
const int src = 0;
int ret = isascii(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -160,6 +167,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii003, Function | MediumTe
const int src = 127;
int ret = isascii(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -172,6 +180,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii004, Function | MediumTe
const int src = 128;
int ret = isascii(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -184,6 +193,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsascii005, Function | MediumTe
int src = '\f'; // 0x0c 14
int ret = isascii(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -196,6 +206,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint001, Function | MediumTe
int src = 'A';
int ret = isprint(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -208,6 +219,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint002, Function | MediumTe
int src = '1';
int ret = isprint(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -220,6 +232,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint003, Function | MediumTe
int src = '@';
int ret = isprint(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -232,6 +245,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint004, Function | MediumTe
int src = ' ';
int ret = isprint(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -244,6 +258,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsprint005, Function | MediumTe
int src = '\f'; // 0x0c
int ret = isprint(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
......@@ -257,6 +272,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace001, Function | MediumTe
int src = 'A';
int ret = isspace(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -269,6 +285,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace002, Function | MediumTe
int src = '1';
int ret = isspace(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -281,6 +298,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace003, Function | MediumTe
int src = '@';
int ret = isspace(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -293,6 +311,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace004, Function | MediumTe
int src = ' ';
int ret = isspace(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -305,6 +324,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsspace005, Function | MediumTe
int src = '\t';
int ret = isspace(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
......@@ -318,6 +338,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper001, Function | MediumTe
int src = 'A';
int ret = isupper(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -330,6 +351,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper002, Function | MediumTe
int src = 'a';
int ret = isupper(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -342,6 +364,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper003, Function | MediumTe
const int src = 0x45;
int ret = isupper(src);
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -354,6 +377,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper004, Function | MediumTe
int src = ' ';
int ret = isupper(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -366,6 +390,7 @@ LITE_TEST_CASE(PosixCtypeFuncTestSuite, testCtypeIsupper005, Function | MediumTe
int src = '\t';
int ret = isupper(src);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
RUN_TEST_SUITE(PosixCtypeFuncTestSuite);
......
......@@ -31,7 +31,7 @@
#include <ctype.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -80,6 +80,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit001, Function | MediumTest
LOG("[DEMO] posix ctype test case 1:isdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(1, ret);
return 0;
}
/**
......@@ -98,6 +99,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit002, Function | MediumTest
LOG("[DEMO] posix ctype test case 2:isdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(1, ret);
return 0;
}
/**
......@@ -116,6 +118,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit003, Function | MediumTest
LOG("[DEMO] posix ctype test case 3:isdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(1, ret);
return 0;
}
/**
......@@ -134,6 +137,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit004, Function | MediumTest
LOG("[DEMO] posix ctype test case 4(except):isdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/**
......@@ -152,6 +156,7 @@ LITE_TEST_CASE(PosixCTypeIsdigitTest, testCTypeIsdigit005, Function | MediumTest
LOG("[DEMO] posix ctype test case 5(except):isdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
RUN_TEST_SUITE(PosixCTypeIsdigitTest);
......
......@@ -31,7 +31,7 @@
#include <ctype.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -79,6 +79,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower001, Function | MediumTest
LOG("[DEMO] posix ctype test case 1:islower(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(1, ret);
return 0;
}
/* *
......@@ -96,6 +97,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower002, Function | MediumTest
LOG("[DEMO] posix ctype test case 2:islower(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(1, ret);
return 0;
}
/* *
......@@ -113,6 +115,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower003, Function | MediumTest
LOG("[DEMO] posix ctype test case 3:islower(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(1, ret);
return 0;
}
/* *
......@@ -130,6 +133,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower004, Function | MediumTest
LOG("[DEMO] posix ctype test case 4(except):islower(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -147,6 +151,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower005, Function | MediumTest
LOG("[DEMO] posix ctype test case 5(except):islower(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -164,6 +169,7 @@ LITE_TEST_CASE(PosixCTypeIslowerTest, testCTypeIslower006, Function | MediumTest
LOG("[DEMO] posix ctype test case 6(except):islower(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
RUN_TEST_SUITE(PosixCTypeIslowerTest);
......
......@@ -31,7 +31,7 @@
#include <ctype.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -79,6 +79,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit001, Function | MediumTe
LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -96,6 +97,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit002, Function | MediumTe
LOG("[DEMO] posix ctype test case 2:isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -113,6 +115,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit003, Function | MediumTe
LOG("[DEMO] posix ctype test case 3:isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -130,6 +133,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit004, Function | MediumTe
LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -147,6 +151,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit005, Function | MediumTe
LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -164,6 +169,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit006, Function | MediumTe
LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -181,6 +187,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit007, Function | MediumTe
LOG("[DEMO] posix ctype test case 1:isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_NOT_EQUAL(0, ret);
return 0;
}
/* *
......@@ -198,6 +205,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit008, Function | MediumTe
LOG("[DEMO] posix ctype test case 5(except):isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -215,6 +223,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit009, Function | MediumTe
LOG("[DEMO] posix ctype test case 4(except):isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
/* *
......@@ -232,6 +241,7 @@ LITE_TEST_CASE(PosixCTypeIsxdigitTest, testCTypeIsxdigit010, Function | MediumTe
LOG("[DEMO] posix ctype test case 5(except):isxdigit(%c) fail.\n", a);
}
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
}
RUN_TEST_SUITE(PosixCTypeIsxdigitTest);
......
......@@ -31,7 +31,7 @@
#include <ctype.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -79,6 +79,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower001, Function | MediumTest
LOG("[DEMO] posix ctype test case 1:tolower(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'a');
return 0;
}
/* *
......@@ -96,6 +97,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower002, Function | MediumTest
LOG("[DEMO] posix ctype test case 2:tolower(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'a');
return 0;
}
/* *
......@@ -113,6 +115,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower003, Function | MediumTest
LOG("[DEMO] posix ctype test case 3:tolower(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'z');
return 0;
}
/* *
......@@ -130,6 +133,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower004, Function | MediumTest
LOG("[DEMO] posix ctype test case 4:tolower(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'z');
return 0;
}
/* *
......@@ -147,6 +151,7 @@ LITE_TEST_CASE(PosixCTypeTolowerTest, testCTypeTolower005, Function | MediumTest
LOG("[DEMO] posix ctype test case 5(except):tolower(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == '1');
return 0;
}
RUN_TEST_SUITE(PosixCTypeTolowerTest);
......
......@@ -31,7 +31,7 @@
#include <ctype.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -79,6 +79,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper001, Function | MediumTest
LOG("[DEMO] posix ctype test case 1:toupper(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'A');
return 0;
}
/* *
......@@ -96,6 +97,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper002, Function | MediumTest
LOG("[DEMO] posix ctype test case 2:toupper(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'A');
return 0;
}
/* *
......@@ -113,6 +115,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper003, Function | MediumTest
LOG("[DEMO] posix ctype test case 3:toupper(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'Z');
return 0;
}
/* *
......@@ -130,6 +133,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper004, Function | MediumTest
LOG("[DEMO] posix ctype test case 4:toupper(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == 'Z');
return 0;
}
/* *
......@@ -147,6 +151,7 @@ LITE_TEST_CASE(PosixCTypeToupperTest, testCTypeToupper005, Function | MediumTest
LOG("[DEMO] posix ctype test case 5(except):toupper(%c)!=%c fail.\n", a);
}
TEST_ASSERT_TRUE(ret == '1');
return 0;
}
RUN_TEST_SUITE(PosixCTypeToupperTest);
......
......@@ -32,7 +32,7 @@
#include <stdlib.h>
#include <errno.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......
......@@ -37,7 +37,7 @@
#include <stdio.h>
#include <libgen.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......
......@@ -49,7 +49,7 @@
#define THREAD_COUNT_MAX 30
#define THREAD_STACK_SPACE_MAX 4096
#define RUN_ONE_TESTCASE(caseName) UnityDefaultTestRun(caseName##_runTest, __FILE__, __LINE__)
#define RUN_ONE_TESTCASE(caseName) ADD_TEST_CASE(caseName)
#define AUTO_RUN_ONE_TESTCASEFUNC(func) UnityDefaultTestRun(func, __FILE__, __LINE__)
#ifdef __cplusplus
......
......@@ -32,7 +32,7 @@
#include <float.h>
#include <math.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -109,6 +109,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathAbs001, Function | MediumTest | L
LOG("\n [POSIXTEST][abs]abs(%d) = %d, expected is %d", testValues[i], ret, expected[i]);
TEST_ASSERT_EQUAL_INT(expected[i], ret);
}
return 0;
};
/* *
......@@ -127,6 +128,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathAbs002, Function | MediumTest | L
LOG("\n [POSIXTEST][abs]abs(%d) = %d, expected is %d", testValues[i], ret, expected[i]);
TEST_ASSERT_EQUAL_INT(expected[i], ret);
}
return 0;
};
/* *
......@@ -148,6 +150,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathLog001, Function | MediumTest | L
TEST_ASSERT_EQUAL_FLOAT(expected[i], ret);
TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret));
}
return 0;
};
/* *
......@@ -170,6 +173,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathLog002, Function | MediumTest | L
LOG("\n [POSIXTEST][log]log(%f) = %f, expected is %f", testValues[i], ret, expected[i]);
TEST_ASSERT_EQUAL_FLOAT(expected[i], ret);
}
return 0;
};
/* *
......@@ -189,6 +193,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathSqrt001, Function | MediumTest |
TEST_ASSERT_EQUAL_FLOAT(expected[i], ret);
TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret));
}
return 0;
};
/* *
......@@ -207,6 +212,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathSqrt002, Function | MediumTest |
LOG("\n [POSIXTEST][sqrt]sqrt(%f) = %f, expected is %f", testValues[i], ret, expected[i]);
TEST_ASSERT_EQUAL_FLOAT(expected[i], ret);
}
return 0;
};
/* *
......@@ -232,6 +238,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow001, Function | MediumTest | L
TEST_ASSERT_EQUAL_FLOAT(testValues[i][TEST_EXPECTED], ret);
TEST_ASSERT_TRUE(DoubleEquals(testValues[i][TEST_EXPECTED], ret));
}
return 0;
};
......@@ -266,6 +273,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow002, Function | MediumTest | L
LOG("\n [POSIXTEST][pow]pow1(%f,%f) = %f, expected is %f", testValues[i][TEST_VALUE_X],
testValues[i][TEST_VALUE_Y], ret, testValues[i][TEST_EXPECTED]);
}
return 0;
};
/* *
......@@ -291,6 +299,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow003, Function | MediumTest | L
testValues[i][TEST_VALUE_Y], ret, testValues[i][TEST_EXPECTED]);
TEST_ASSERT_TRUE(DoubleEquals(testValues[i][TEST_EXPECTED], ret));
}
return 0;
};
/* *
......@@ -311,6 +320,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathRound001, Function | MediumTest |
TEST_ASSERT_EQUAL_FLOAT(expected[i], ret);
TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret));
}
return 0;
};
/* *
......@@ -330,6 +340,7 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathRound002, Function | MediumTest |
TEST_ASSERT_EQUAL_FLOAT(expected[i], ret);
TEST_ASSERT_TRUE(DoubleEquals(expected[i], ret));
}
return 0;
};
RUN_TEST_SUITE(PosixMathFuncTestSuite);
......
......@@ -30,7 +30,7 @@
*/
#include <securec.h>
#include "hctest.h"
#include "posix_test.h"
#include <mqueue.h>
#include <fcntl.h>
#include "common_test.h"
......@@ -96,7 +96,7 @@ static BOOL MqueueFuncTestSuiteTearDown(void)
* @tc.name : event operation for create
* @tc.desc : [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqueue001, Function | MediumTest | Level1)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqueue001, Function | MediumTest | Level1)
{
unsigned int ret;
char msgrcd[MQUEUE_STANDARD_NAME_LENGTH] = {0};
......@@ -126,13 +126,13 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqueue001, Function | MediumTest | Level
ret = mq_unlink(mqname);
ICUNIT_GOTO_EQUAL(ret, MQUEUE_NO_ERROR, ret, EXIT);
return;
return 0;
EXIT1:
mq_close(mqueue);
EXIT:
mq_unlink(mqname);
return;
return 0;
};
/**
......@@ -140,7 +140,7 @@ EXIT:
* @tc.name mq_open function errno for EEXIST test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenEEXIST, Function | MediumTest | Level2)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqOpenEEXIST, Function | MediumTest | Level2)
{
char qName[MQ_NAME_LEN];
mqd_t queue, queueOther;
......@@ -160,7 +160,7 @@ EXIT1:
EXIT:
ret = mq_unlink(qName);
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
return;
return 0;
}
/**
......@@ -168,7 +168,7 @@ EXIT:
* @tc.name mq_open function errno for EINVAL test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenEINVAL, Function | MediumTest | Level2)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqOpenEINVAL, Function | MediumTest | Level2)
{
int i;
mqd_t queue;
......@@ -228,6 +228,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenEINVAL, Function | MediumTest | Le
attr.mq_maxmsg = MQ_MAX_MSG;
queue = mq_open(qName, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, &attr);
ICUNIT_TRACK_EQUAL(errno, EINVAL, errno);
return 0;
}
......@@ -236,7 +237,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenEINVAL, Function | MediumTest | Le
* @tc.name mq_open function errno for ENAMETOOLONG test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENAMETOOLONG, Function | MediumTest | Level2)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqOpenENAMETOOLONG, Function | MediumTest | Level2)
{
char qName[MAX_MQ_NAME_LEN + 10];
mqd_t queue;
......@@ -256,6 +257,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENAMETOOLONG, Function | MediumTes
}
ICUNIT_TRACK_EQUAL(errno, ENAMETOOLONG, errno);
return 0;
}
......@@ -264,7 +266,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENAMETOOLONG, Function | MediumTes
* @tc.name mq_open function errno for ENOENT test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENOENT, Function | MediumTest | Level3)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqOpenENOENT, Function | MediumTest | Level3)
{
mqd_t queue;
char qName[MQ_NAME_LEN];
......@@ -278,6 +280,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENOENT, Function | MediumTest | Le
mq_unlink(qName);
}
ICUNIT_TRACK_EQUAL(errno, ENOENT, errno);
return 0;
}
/**
......@@ -285,7 +288,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENOENT, Function | MediumTest | Le
* @tc.name mq_open function errno for ENFILE test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Level3)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqOpenENFILE, Function | MediumTest | Level3)
{
char qName[MAX_MQ_NUMBER + 1][30];
mqd_t queue[MAX_MQ_NUMBER + 1];
......@@ -318,6 +321,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
mq_close(queue[i]);
mq_unlink(qName[i]);
}
return 0;
}
/**
......@@ -325,7 +329,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
* @tc.name mq_open function errno for ENOSPC test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENOSPC, Function | MediumTest | Level3)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqOpenENOSPC, Function | MediumTest | Level3)
{
mqd_t queue;
struct mq_attr setAttr = {0};
......@@ -342,6 +346,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENOSPC, Function | MediumTest | Le
mq_unlink(qName);
}
ICUNIT_TRACK_EQUAL(errno, ENOSPC, errno);
return 0;
}
/**
......@@ -349,10 +354,11 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENOSPC, Function | MediumTest | Le
* @tc.name mq_close function errno for EBADF test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqCloseEBADF, Function | MediumTest | Level2)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqCloseEBADF, Function | MediumTest | Level2)
{
ICUNIT_TRACK_EQUAL(mq_close(NULL), -1, -1);
ICUNIT_TRACK_EQUAL(errno, EBADF, errno);
return 0;
}
/**
......@@ -360,7 +366,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqCloseEBADF, Function | MediumTest | Le
* @tc.name mq_send function errno for EAGAIN test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEAGAIN, Function | MediumTest | Level2)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqSendEAGAIN, Function | MediumTest | Level2)
{
mqd_t queue;
struct mq_attr attr = {0};
......@@ -385,6 +391,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEAGAIN, Function | MediumTest | Le
ret = mq_unlink(qName);
ICUNIT_TRACK_EQUAL(ret, 0, ret);
return 0;
}
/**
......@@ -392,7 +399,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEAGAIN, Function | MediumTest | Le
* @tc.name mq_send function errno for EBADF and EMSGSIZE test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTest | Level2)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqSendEBADFEMSGSIZE, Function | MediumTest | Level2)
{
mqd_t queue;
struct mq_attr attr = {0};
......@@ -441,6 +448,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
ret = mq_unlink(qName);
ICUNIT_TRACK_EQUAL(ret, 0, ret);
return 0;
}
/**
......@@ -448,7 +456,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
* @tc.name mq_send function errno for EINVAL test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEINVAL, Function | MediumTest | Level3)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqSendEINVAL, Function | MediumTest | Level3)
{
mqd_t queue;
struct mq_attr attr = {0};
......@@ -470,6 +478,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEINVAL, Function | MediumTest | Le
ret = mq_unlink(qName);
ICUNIT_TRACK_EQUAL(ret, 0, ret);
return 0;
}
/**
......@@ -477,7 +486,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEINVAL, Function | MediumTest | Le
* @tc.name mq_receive function errno for EAGAIN test
* @tc.desc [C- SOFTWARE -0200]
*/
LITE_TEST_CASE(MqueueFuncTestSuite, testMqReceiveEAGAIN, Function | MediumTest | Level2)
LITE_TEST_CASE(MqueueFuncTestSuite, TestMqReceiveEAGAIN, Function | MediumTest | Level2)
{
mqd_t queue;
unsigned int prio;
......@@ -509,6 +518,26 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqReceiveEAGAIN, Function | MediumTest |
ret = mq_unlink(qName);
ICUNIT_TRACK_EQUAL(ret, 0, ret);
return 0;
}
RUN_TEST_SUITE(MqueueFuncTestSuite);
void PosixMqueueFuncTest(void)
{
LOG("begin PosixMqueueFuncTest....");
RUN_ONE_TESTCASE(TestMqueue001);
RUN_ONE_TESTCASE(TestMqOpenEEXIST);
RUN_ONE_TESTCASE(TestMqOpenEINVAL);
RUN_ONE_TESTCASE(TestMqOpenENAMETOOLONG);
RUN_ONE_TESTCASE(TestMqOpenENOENT);
RUN_ONE_TESTCASE(TestMqOpenENFILE);
RUN_ONE_TESTCASE(TestMqOpenENOSPC);
RUN_ONE_TESTCASE(TestMqCloseEBADF);
RUN_ONE_TESTCASE(TestMqSendEAGAIN);
RUN_ONE_TESTCASE(TestMqSendEBADFEMSGSIZE);
RUN_ONE_TESTCASE(TestMqSendEINVAL);
RUN_ONE_TESTCASE(TestMqReceiveEAGAIN);
return;
}
/*
* Copyright (c) 2022-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 "posix_test.h"
void ItSuitePosix(void)
{
PRINTF("***********************BEGIN POSIX TEST**********************\n");
PthreadFuncTestSuite();
PosixCtypeFuncTest();
PosixIsdigitFuncTest();
PosixIslowerFuncTest();
PosixIsxdigitFuncTest();
PosixTolowerFuncTest();
PosixToupperFuncTest();
PosixStrerrorTest();
PosixMathFuncTest();
PosixMqueueFuncTest();
PosixStdargFuncTest();
PosixStdlibAtoiFuncTest();
PosixStdlibAtolFuncTest();
PosixStdlibAtollFuncTest();
PosixStdlibStrtolFuncTest();
PosixStdlibStrtoulFuncTest();
PosixStdlibStrtoullFuncTest();
PosixStringMemTest03();
PosixStringStrchrTest();
PosixStringFuncTest02();
PosixStringStrcasecmpFuncTest();
PosixStringFuncTest03();
#if (LOS_KERNEL_TEST_FULL == 1)
PosixSemaphoreFuncTest();
PosixTimeFuncTest();
#endif
}
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _POSIX_TEST_H
#define _POSIX_TEST_H
#include <stdlib.h>
#include "iCunit.h"
#define TEST_STR(func) ItLos##func
#define TEST_TO_STR(x) #x
#define TEST_HEAD_TO_STR(x) TEST_TO_STR(x)
#define ADD_TEST_CASE(func) \
TEST_ADD_CASE(TEST_HEAD_TO_STR(TEST_STR(func)), func, TEST_LOS, TEST_TASK, TEST_LEVEL0, TEST_FUNCTION)
#define Function 0
#define MediumTest 0
#define Level1 0
#define LITE_TEST_CASE(module, function, flag) static int function(void)
#define TEST_ASSERT_EQUAL(expected, actual) ICUNIT_ASSERT_EQUAL(expected, actual, actual)
#define TEST_ASSERT_EQUAL_INT(expected, actual) TEST_ASSERT_EQUAL(expected, actual)
#define TEST_ASSERT_EQUAL_INT32(expected, actual) TEST_ASSERT_EQUAL(expected, actual)
#define TEST_ASSERT_EQUAL_INT64(expected, actual) TEST_ASSERT_EQUAL(expected, actual)
#define TEST_ASSERT_EQUAL_UINT32(expected, actual) TEST_ASSERT_EQUAL(expected, actual)
#define TEST_ASSERT_EQUAL_UINT64(expected, actual) TEST_ASSERT_EQUAL(expected, actual)
#define TEST_ASSERT_NULL(ptr) TEST_ASSERT_EQUAL(NULL, ptr)
#define TEST_ASSERT_EQUAL_PTR(expected, actual) TEST_ASSERT_EQUAL(expected, actual)
#define TEST_ASSERT_NOT_EQUAL(expected, actual) ICUNIT_ASSERT_NOT_EQUAL(expected, actual, actual)
#define TEST_ASSERT_NOT_NULL(ptr) TEST_ASSERT_NOT_EQUAL(NULL, ptr)
#define TEST_ASSERT_EQUAL_STRING(str1, str2) ICUNIT_ASSERT_STRING_EQUAL(str1, str2, 1)
#define TEST_ASSERT_TRUE(condition) TEST_ASSERT_NOT_EQUAL(0, condition)
#define TEST_ASSERT_LESS_THAN(threshold, actual) TEST_ASSERT_TRUE((actual) < (threshold))
#define TEST_ASSERT_LESS_THAN_INT(threshold, actual) TEST_ASSERT_LESS_THAN(threshold, actual)
#define TEST_ASSERT_GREATER_THAN(threshold, actual) TEST_ASSERT_TRUE((actual) > (threshold))
#define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) TEST_ASSERT_GREATER_THAN(threshold, actual)
#define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) TEST_ASSERT_TRUE((actual) >= (threshold))
#define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) TEST_ASSERT_TRUE((actual) <= (threshold))
#define TEST_ASSERT_INT32_WITHIN(a, b, c) ICUNIT_ASSERT_WITHIN_EQUAL(c, (b) - (a), (b) + (a), c)
#define TEST_FAIL() TEST_ASSERT_TRUE(0)
#define TEST_ASSERT_EQUAL_CHAR_ARRAY(expected, actual, num) ICUNIT_ASSERT_SIZE_STRING_EQUAL(expected, actual, num, 1)
#define TEST_ASSERT_EQUAL_FLOAT(expected, actual) \
TEST_ASSERT_TRUE(((expected) == (actual)) || (isnan(expected) && isnan(actual)))
void ItSuitePosix(void);
extern void PosixCtypeFuncTest(void);
extern void PosixIsdigitFuncTest(void);
extern void PosixIslowerFuncTest(void);
extern void PosixIsxdigitFuncTest(void);
extern void PosixTolowerFuncTest(void);
extern void PosixToupperFuncTest(void);
extern void PosixStrerrorTest(void);
extern void PosixFsFuncTest(void);
extern void PosixMathFuncTest(void);
extern void PosixMqueueFuncTest(void);
extern int PthreadFuncTestSuite(void);
extern void PosixRegexFuncTest(void);
extern void PosixSemaphoreFuncTest(void);
extern void PosixStdargFuncTest(void);
extern void PosixStdlibAtoiFuncTest(void);
extern void PosixStdlibAtolFuncTest(void);
extern void PosixStdlibAtollFuncTest(void);
extern void PosixStdlibStrtolFuncTest(void);
extern void PosixStdlibStrtoulFuncTest(void);
extern void PosixStdlibStrtoullFuncTest(void);
extern void PosixStringMemTest03(void);
extern void PosixStringStrchrTest(void);
extern void PosixStringFuncTest02(void);
extern void PosixStringStrcasecmpFuncTest(void);
extern void PosixStringFuncTest03(void);
extern void PosixStringStrstrTest(void);
extern void PosixTimeFuncTest(void);
#endif
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include <regex.h>
......
......@@ -34,7 +34,7 @@
#include <stdio.h>
#include <errno.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -124,6 +124,7 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait001, Function |
TEST_ASSERT_LESS_THAN_INT(20, abs(timeDiff));
TEST_ASSERT_EQUAL_INT(0, sem_destroy((sem_t *)&sem));
return 0;
}
/* *
......@@ -166,6 +167,7 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait002, Function |
LOG("\n wait timeDiff %d", timeDiff);
TEST_ASSERT_EQUAL_INT(0, sem_destroy((sem_t *)&sem));
return 0;
}
/* *
......@@ -212,6 +214,7 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Timedwait003, Function |
ret = sem_timedwait(NULL, &ts);
TEST_ASSERT_EQUAL_INT(-1, ret);
TEST_ASSERT_EQUAL_INT(errno, EINVAL);
return 0;
}
/* *
......@@ -240,6 +243,7 @@ LITE_TEST_CASE(PosixSemaphoreFuncTestSuite, testIpcSem_Trywait004, Function | Me
} else {
TEST_ASSERT_EQUAL_INT(0, ret);
}
return 0;
}
RUN_TEST_SUITE(PosixSemaphoreFuncTestSuite);
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include <string.h>
......@@ -105,6 +105,7 @@ LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg001, Function | MediumTest |
{
int ret = VaFunc(1, 10);
TEST_ASSERT_EQUAL_INT(RET_OK, ret);
return 0;
}
/* *
......@@ -116,6 +117,7 @@ LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg002, Function | MediumTest |
{
int ret = VaFunc(2, 10, 'A');
TEST_ASSERT_EQUAL_INT(RET_OK, ret);
return 0;
}
/* *
......@@ -127,6 +129,7 @@ LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg003, Function | MediumTest |
{
int ret = VaFunc(3, 10, 'A', "hello world");
TEST_ASSERT_EQUAL_INT(RET_OK, ret);
return 0;
}
/* *
......@@ -138,6 +141,7 @@ LITE_TEST_CASE(PosixStdargFuncTestSuite, testStdarg004, Function | MediumTest |
{
int ret = VaFunc(3, 10, 'A', "hello world", '\0');
TEST_ASSERT_EQUAL_INT(RET_OK, ret);
return 0;
}
RUN_TEST_SUITE(PosixStdargFuncTestSuite);
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "ctype.h"
......@@ -79,6 +79,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi001, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 1:atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(2147483647, value);
return 0;
}
/* *
......@@ -95,6 +96,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi002, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 2:atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(-2147483648, value);
return 0;
}
/* *
......@@ -111,6 +113,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi003, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 3:atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(100, value);
return 0;
}
/* *
......@@ -127,6 +130,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi004, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 4(except):atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(-2147483648, value);
return 0;
}
/* *
......@@ -143,6 +147,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi005, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 5(except):atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(2147483647, value);
return 0;
}
/* *
......@@ -159,6 +164,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi006, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 6:atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(100, value);
return 0;
}
/* *
......@@ -175,6 +181,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi007, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 7:atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(-100, value);
return 0;
}
/* *
......@@ -191,6 +198,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi008, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 8(except):atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(0, value);
return 0;
}
/* *
......@@ -207,6 +215,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi009, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 9(except):atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(12, value);
return 0;
}
/* *
......@@ -223,6 +232,7 @@ LITE_TEST_CASE(PosixStdlibAtoiTest, testStdlibAtoi010, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 10(except):atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT(-10, value);
return 0;
}
RUN_TEST_SUITE(PosixStdlibAtoiTest);
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "ctype.h"
......@@ -79,6 +79,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol001, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 1:atol(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(2147483647, value);
return 0;
}
/* *
......@@ -95,6 +96,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol002, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 2:atol(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(-2147483648, value);
return 0;
}
/* *
......@@ -111,6 +113,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol003, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 3:atol(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(100, value);
return 0;
}
/* *
......@@ -127,6 +130,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol004, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 4(except):atol(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(-2147483648, value);
return 0;
}
/* *
......@@ -143,6 +147,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol005, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 5(except):atoi(%d) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(2147483647, value);
return 0;
}
/* *
......@@ -159,6 +164,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol006, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 6:atol(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(100, value);
return 0;
}
/* *
......@@ -175,6 +181,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol007, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 7:atoi(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(-100, value);
return 0;
}
/* *
......@@ -191,6 +198,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol008, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 8(except):atol(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(0, value);
return 0;
}
/* *
......@@ -207,6 +215,7 @@ LITE_TEST_CASE(PosixStdlibAtolTest, testStdlibAtol009, Function | MediumTest | L
LOG("[DEMO] posix stdlib test case 9(except):atol(%ld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT32(12, value);
return 0;
}
RUN_TEST_SUITE(PosixStdlibAtolTest);
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "ctype.h"
......@@ -80,6 +80,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll001, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 1:atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == 9223372036854775807LL);
return 0;
}
/* *
......@@ -96,6 +97,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll002, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 2:atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == -9223372036854775808LL);
return 0;
}
/* *
......@@ -112,6 +114,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll003, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 3:atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == 100LL);
return 0;
}
/* *
......@@ -128,6 +131,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll004, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 4(except):atoll(%lld) fail.\n", value);
}
TEST_ASSERT_EQUAL_INT64(LLONG_MIN, value);
return 0;
}
/* *
......@@ -145,6 +149,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll005, Function | MediumTest |
}
TEST_ASSERT_EQUAL_INT64(LLONG_MAX, value);
return 0;
}
/* *
......@@ -161,6 +166,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll006, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 6:atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == 100LL);
return 0;
}
/* *
......@@ -177,6 +183,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll007, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 7:atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == -100LL);
return 0;
}
/* *
......@@ -193,6 +200,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll008, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 8(except):atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == 0LL);
return 0;
}
/* *
......@@ -209,6 +217,7 @@ LITE_TEST_CASE(PosixStdlibAtollTest, testStdlibAtoll009, Function | MediumTest |
LOG("[DEMO] posix stdlib test case 9(except):atoll(%lld) fail.\n", value);
}
TEST_ASSERT_TRUE(value == 12LL);
return 0;
}
RUN_TEST_SUITE(PosixStdlibAtollTest);
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "ctype.h"
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "ctype.h"
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "ctype.h"
......
......@@ -32,7 +32,7 @@
#include <string.h>
#include <stdlib.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -101,6 +101,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy001, Function | MediumTest
break;
}
}
return 0;
};
......@@ -142,6 +143,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcpy002, Function | MediumTest
}
}
TEST_ASSERT_EQUAL_INT(0, failure);
return 0;
};
......@@ -163,6 +165,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemset001, Function | MediumTest
for (int i = 0; i < (sizeof(source) / sizeof(source[0])); i++) {
TEST_ASSERT_EQUAL_INT((int)source[i], (int)ch);
}
return 0;
};
......@@ -202,6 +205,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp001, Function | MediumTest
ret = memcmp(gt, orign, 0);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
};
......@@ -227,6 +231,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp002, Function | MediumTest
ret = memcmp(L"ABCDEFG", L"ABCDEFG", 6);
TEST_ASSERT_EQUAL_INT(0, ret);
return 0;
};
......@@ -243,6 +248,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemMemcmp003, Function | MediumTest
"immediate use in a computer\r\n"};
retValue = memcmp(source, dest, sizeof(source) / sizeof(source[0]));
TEST_ASSERT_LESS_THAN(0, retValue);
return 0;
};
......@@ -288,6 +294,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc001, Function | MediumTest
free(mem1);
TEST_ASSERT_EQUAL_INT(failure, 0);
}
return 0;
};
......@@ -320,6 +327,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc002, Function | MediumTest
mem = reMem;
}
free(mem);
return 0;
};
......@@ -334,6 +342,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc003, Function | MediumTest
retValue = (char *)realloc(retValue, 20);
TEST_ASSERT_NOT_NULL(retValue);
return 0;
};
/* *
......@@ -352,6 +361,7 @@ LITE_TEST_CASE(PosixMemFuncTestSuite, testOsMemRealloc004, Function | MediumTest
source = newData;
}
free(source);
return 0;
};
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include <ctype.h>
......@@ -80,6 +80,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr001, Function | MediumTest
LOG("[DEMO] posix string test case 1:strchr(!) %s fail.\n", src);
}
TEST_ASSERT_EQUAL_STRING(ret, "!! world");
return 0;
}
/* *
......@@ -97,6 +98,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr002, Function | MediumTest
LOG("[DEMO] posix string test case 2:strchr(l) %s fail.\n", src);
}
TEST_ASSERT_EQUAL_STRING(ret, "llo !! world");
return 0;
}
/* *
......@@ -114,6 +116,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr003, Function | MediumTest
LOG("[DEMO] posix string test case 3:strchr(\'\\0\') %s fail.\n", src);
}
TEST_ASSERT_NOT_NULL(ret);
return 0;
}
/* *
......@@ -131,6 +134,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr004, Function | MediumTest
LOG("[DEMO] posix string test case 4(except):strchr(?) %s fail.\n", src);
}
TEST_ASSERT_NULL(ret);
return 0;
}
/* *
......@@ -148,6 +152,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr005, Function | MediumTest
LOG("[DEMO] posix string test case 5(except):strchr(m) %s fail.\n", src);
}
TEST_ASSERT_NULL(ret);
return 0;
}
/* *
......@@ -165,6 +170,7 @@ LITE_TEST_CASE(PosixStringStrchrTest, testStringStrchr006, Function | MediumTest
LOG("[DEMO] posix string test case 6(except):strchr(0) %s fail.\n", src);
}
TEST_ASSERT_NOT_NULL(ret);
return 0;
}
RUN_TEST_SUITE(PosixStringStrchrTest);
......
......@@ -29,7 +29,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -73,6 +73,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen001, Function | MediumT
char src[] = "helloworld";
int ret = strlen(src);
TEST_ASSERT_EQUAL_INT(ret, 10);
return 0;
}
/* *
......@@ -85,6 +86,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen002, Function | MediumT
char src[] = "hello world";
int ret = strlen(src);
TEST_ASSERT_EQUAL_INT(ret, 11);
return 0;
}
/* *
......@@ -96,6 +98,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen003, Function | MediumT
{
int ret = strlen("");
TEST_ASSERT_EQUAL_INT(ret, 0);
return 0;
}
/* *
......@@ -108,6 +111,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen004, Function | MediumT
char src[] = "hello\0world";
int ret = strlen(src);
TEST_ASSERT_EQUAL_INT(ret, 5);
return 0;
}
/* *
......@@ -120,6 +124,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrlen005, Function | MediumT
char src[] = "\0helloworld";
int ret = strlen(src);
TEST_ASSERT_EQUAL_INT(ret, 0);
return 0;
}
......@@ -133,6 +138,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp001, Function | Me
char *src[] = {"helloworld", "HElloworld"};
int ret = strncasecmp(src[0], src[1], 2);
TEST_ASSERT_EQUAL_INT(RET_OK, ret);
return 0;
}
/* *
......@@ -145,6 +151,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp002, Function | Me
char *src[] = {"helloworld", "he\0lloworld"};
int ret = strncasecmp(src[0], src[1], 3);
TEST_ASSERT_GREATER_THAN(RET_OK, ret);
return 0;
}
/* *
......@@ -157,6 +164,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp003, Function | Me
char *src[] = {"helloworld", "he lloworld"};
int ret = strncasecmp(src[0], src[1], 3);
TEST_ASSERT_GREATER_THAN(RET_OK, ret);
return 0;
}
/* *
......@@ -169,6 +177,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp004, Function | Me
char *src[] = {"helloworld", "hello World"};
int ret = strncasecmp(src[0], src[1], 3);
TEST_ASSERT_EQUAL_INT(RET_OK, ret);
return 0;
}
/* *
......@@ -181,6 +190,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncasecmp005, Function | Me
char *src[] = {"helloworld", "\0"};
int ret = strncasecmp(src[0], src[1], 1);
TEST_ASSERT_GREATER_THAN(RET_OK, ret);
return 0;
}
/* *
......@@ -193,6 +203,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp001, Function | Medium
char *src[] = {"helloworld", "HELloworld"};
int ret = strncmp(src[0], src[1], 3);
TEST_ASSERT_GREATER_THAN(RET_OK, ret);
return 0;
}
/* *
......@@ -205,6 +216,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp002, Function | Medium
char *src[] = {"helloworld", "he\0lloworld"};
int ret = strncmp(src[0], src[1], 3);
TEST_ASSERT_GREATER_THAN(RET_OK, ret);
return 0;
}
/* *
......@@ -217,6 +229,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp003, Function | Medium
char *src[] = {"helloworld", "he lloworld"};
int ret = strncmp(src[0], src[1], 3);
TEST_ASSERT_GREATER_THAN(RET_OK, ret);
return 0;
}
/* *
......@@ -229,6 +242,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp004, Function | Medium
char *src[] = {"helloworld", "hello World"};
int ret = strncmp(src[0], src[1], 3);
TEST_ASSERT_EQUAL_INT(RET_OK, ret);
return 0;
}
/* *
......@@ -241,6 +255,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrncmp005, Function | Medium
char *src[] = {"helloworld", "\0"};
int ret = strncmp(src[0], src[1], 3);
TEST_ASSERT_GREATER_THAN(RET_OK, ret);
return 0;
}
......@@ -255,6 +270,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr001, Function | Medium
char *ret = strrchr(src, '!');
TEST_ASSERT_EQUAL_PTR(ret, NULL);
TEST_ASSERT_NULL(ret);
return 0;
}
/* *
......@@ -268,6 +284,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr002, Function | Medium
char *ret = strrchr(src, '\0');
TEST_ASSERT_EQUAL_PTR(ret, src + 11);
TEST_ASSERT_NOT_NULL(ret);
return 0;
}
/* *
......@@ -281,6 +298,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr003, Function | Medium
char *ret = strrchr(src, '\0');
TEST_ASSERT_EQUAL_PTR(ret, src + 5);
TEST_ASSERT_NOT_NULL(ret);
return 0;
}
/* *
......@@ -294,6 +312,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr004, Function | Medium
char *ret = strrchr(src, ' ');
TEST_ASSERT_EQUAL_PTR(ret, src + 5);
TEST_ASSERT_NOT_NULL(ret);
return 0;
}
/* *
......@@ -307,6 +326,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStringStrrchr005, Function | Medium
char *ret = strrchr(src, ' ');
TEST_ASSERT_EQUAL_PTR(ret, NULL);
TEST_ASSERT_NULL(ret);
return 0;
}
RUN_TEST_SUITE(PosixStringFuncTestSuite);
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -91,6 +91,7 @@ LITE_TEST_CASE(PosixStringsFuncTestSuite, testStrCaseCmp001, Function | MediumTe
ret = strcasecmp("abcdef", "abcdEFg");
TEST_ASSERT_NOT_EQUAL(ret, EQUAL);
return 0;
};
RUN_TEST_SUITE(PosixStringsFuncTestSuite);
......
......@@ -32,7 +32,7 @@
#include <string.h>
#include <stdlib.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include "log.h"
......@@ -86,6 +86,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp001, Function | MediumTest
ret = strcmp("123456", "654321");
TEST_ASSERT_GREATER_THAN(ret, 0);
TEST_ASSERT_EQUAL_INT(strcmp("~!@#$%^&*()_+", "~!@#$%^&*()_+"), 0);
return 0;
};
......@@ -102,6 +103,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp002, Function | MediumTest
retValue = strcmp(source, dest);
TEST_ASSERT_LESS_THAN(retValue, 0);
return 0;
};
......@@ -118,6 +120,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrstrcmp003, Function | MediumTest
retValue = strcmp(source, dest);
TEST_ASSERT_GREATER_THAN(retValue, 0);
return 0;
};
......@@ -144,6 +147,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup001, Function | MediumTest
ret = strdup(srcS);
TEST_ASSERT_EQUAL_CHAR_ARRAY(ret, "This is String1", sizeof(srcS) / sizeof(srcS[0]));
free(ret);
return 0;
};
......@@ -161,6 +165,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrdup002, Function | MediumTest
TEST_ASSERT_NOT_NULL(dest);
printf("The Result Display :%s\r\n", dest);
TEST_ASSERT_EQUAL_CHAR_ARRAY(dest, source, sizeof(source) / sizeof(source[0]));
return 0;
};
......@@ -186,6 +191,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrcspn001, Function | MediumTes
const char srcS[] = "a";
ret = strcspn(dest, srcS);
TEST_ASSERT_EQUAL_INT(13U, ret);
return 0;
};
/* *
......@@ -201,6 +207,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrcspn002, Function | MediumTes
retValue = strcspn(source, dest);
TEST_ASSERT_EQUAL_INT(1, retValue);
return 0;
};
/* *
......@@ -219,6 +226,7 @@ LITE_TEST_CASE(PosixStringFuncTestSuite, testStrStrptime001, Function | MediumTe
TEST_ASSERT_EQUAL_INT(tmData.tm_mday, 29);
TEST_ASSERT_EQUAL_INT(tmData.tm_hour, 21);
TEST_ASSERT_EQUAL_INT(tmData.tm_min, 24);
return 0;
}
......
......@@ -30,7 +30,7 @@
*/
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "kernel_test.h"
#include <ctype.h>
......@@ -310,4 +310,24 @@ LITE_TEST_CASE(PosixStringStrStrTest, testStringStrStr013, Function | MediumTest
TEST_ASSERT_NULL(ret);
}
RUN_TEST_SUITE(PosixStringStrStrTest);
\ No newline at end of file
RUN_TEST_SUITE(PosixStringStrStrTest);
void PosixStringStrstrTest(void)
{
LOG("begin PosixStringStrstrTest....");
RUN_ONE_TESTCASE(testStringStrStr001);
RUN_ONE_TESTCASE(testStringStrStr002);
RUN_ONE_TESTCASE(testStringStrStr003);
RUN_ONE_TESTCASE(testStringStrStr004);
RUN_ONE_TESTCASE(testStringStrStr005);
RUN_ONE_TESTCASE(testStringStrStr006);
RUN_ONE_TESTCASE(testStringStrStr007);
RUN_ONE_TESTCASE(testStringStrStr008);
RUN_ONE_TESTCASE(testStringStrStr009);
RUN_ONE_TESTCASE(testStringStrStr010);
RUN_ONE_TESTCASE(testStringStrStr011);
RUN_ONE_TESTCASE(testStringStrStr012);
RUN_ONE_TESTCASE(testStringStrStr013);
return;
}
......@@ -35,11 +35,12 @@
#include <errno.h>
#include <limits.h>
#include "ohos_types.h"
#include "hctest.h"
#include "posix_test.h"
#include "los_config.h"
#include "securec.h"
#include "kernel_test.h"
#include "log.h"
#include "los_tick.h"
#define RET_OK 0
......@@ -161,6 +162,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeUSleep001, Function | MediumTest
TEST_ASSERT_GREATER_OR_EQUAL(interval[j], d);
TEST_ASSERT_INT32_WITHIN(SLEEP_ACCURACY, interval[j], d);
}
return 0;
}
/* *
......@@ -179,6 +181,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeUSleep002, Function | MediumTest
long long duration = (time2.tv_sec - time1.tv_sec) * 1000000 + (time2.tv_nsec - time1.tv_nsec) / 1000;
LOG("\n usleep(0), actual usleep duration: %lld us\n", duration);
TEST_ASSERT_LESS_OR_EQUAL_INT64(1000, duration);
return 0;
}
/* *
......@@ -213,6 +216,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeGmtime001, Function | MediumTest
stm = gmtime(&time1);
LOG("\n LONG_MIN + 1 = %lld, cvt result : %s", time1, TmToStr(stm, timeStr, TIME_STR_LEN));
TEST_ASSERT_EQUAL_STRING("1901/12/13 20:45:53 WEEK(5)", TmToStr(stm, timeStr, TIME_STR_LEN));
return 0;
};
/* *
......@@ -245,6 +249,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime001, Function | MediumTe
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmEnd);
TEST_ASSERT_EQUAL_STRING("08:00:01", cTime);
LOG("\n time_t=%lld, first time:%s", tEnd, cTime);
return 0;
}
/* *
......@@ -278,6 +283,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime002, Function | MediumTe
strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart);
TEST_ASSERT_EQUAL_STRING("70-01-01 07:59:59", cTime);
LOG("\n time_t=%lld, first time:%s", tStart, cTime);
return 0;
}
/* *
......@@ -314,6 +320,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltimer001, Function | MediumT
TEST_ASSERT_EQUAL_STRING("08:00:01", cTime);
strftime(cTime, sizeof(cTime), "%H:%M:%S", tmrEndPtr);
TEST_ASSERT_EQUAL_STRING("08:00:01", cTime);
return 0;
}
/* *
......@@ -349,6 +356,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltimer002, Function | MediumT
strftime(cTime, sizeof(cTime), "%y-%m-%d %H:%M:%S", tmStart);
TEST_ASSERT_EQUAL_STRING("70-01-01 07:59:59", cTime);
LOG("\n time_t=%lld, first time:%s", tStart, cTime);
return 0;
}
/* *
......@@ -392,6 +400,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime001, Function | MediumTest
timeRet = mktime(stm);
TEST_ASSERT_EQUAL_INT(0, timeRet);
LOG("\n input 0, mktime Ret = %lld", timeRet);
return 0;
}
/* *
......@@ -407,6 +416,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime002, Function | MediumTest
time_t timeRet = mktime(&timeptr);
LOG("\n 1800-8-9 10:10:00, mktime Ret lld = %lld", timeRet);
TEST_ASSERT_EQUAL_INT(-1, timeRet);
return 0;
}
......@@ -444,6 +454,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime001, Function | MediumTes
TEST_ASSERT_GREATER_THAN_INT(0, ftime);
TEST_ASSERT_EQUAL_STRING("01/01/70 4 13:14:40", buffer);
LOG("\nresult: %s, expected : %s", buffer, "01/01/70 4 13:14:40");
return 0;
};
/* *
......@@ -472,6 +483,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime002, Function | MediumTes
TEST_ASSERT_GREATER_THAN_INT(0, ftime);
TEST_ASSERT_EQUAL_STRING("01/01/70 Thursday 13:14:40", buffer);
LOG("\nresult: %s, expected : %s", buffer, "01/01/70 Thursday 13:14:40");
return 0;
};
/* *
......@@ -507,6 +519,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime003, Function | MediumTes
ftime = strftime(buffer, 80, "%F %T %Z", tmTime);
TEST_ASSERT_EQUAL_INT(20, ftime);
LOG("\nresult: %s, expected : %s", buffer, "1970-01-01 13:14:40");
return 0;
};
/* *
......@@ -541,11 +554,12 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimes, Function | MediumTest | Level1
if (!CheckValueClose((endTime - stTime), testClockt, 0.02)) {
TEST_FAIL();
}
return 0;
}
RUN_TEST_SUITE(PosixTimeFuncTestSuite);
void PosixTimeFuncTest()
void PosixTimeFuncTest(void)
{
LOG("begin PosixTimeFuncTest....\n");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册