Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos M
提交
ad6f249d
K
Kernel Liteos M
项目概览
OpenHarmony
/
Kernel Liteos M
大约 1 年 前同步成功
通知
20
Star
28
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos M
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ad6f249d
编写于
1月 26, 2022
作者:
L
LiteOS2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(posix unittest): posix unittest 融合
posix unittest 融合 Signed-off-by:
N
LiteOS2021
<
dinglu@huawei.com
>
上级
907dfc63
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
42 addition
and
24 deletion
+42
-24
testsuites/unittest/posix/src/common_test.h
testsuites/unittest/posix/src/common_test.h
+10
-2
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
+2
-1
testsuites/unittest/posix/src/math/math_func_test.c
testsuites/unittest/posix/src/math/math_func_test.c
+2
-2
testsuites/unittest/posix/src/mqueue/mqueue_func_test.c
testsuites/unittest/posix/src/mqueue/mqueue_func_test.c
+11
-8
testsuites/unittest/posix/src/pthread/pthread_cond_func_test.c
...uites/unittest/posix/src/pthread/pthread_cond_func_test.c
+5
-0
testsuites/unittest/posix/src/time/time_func_test_01.c
testsuites/unittest/posix/src/time/time_func_test_01.c
+12
-11
未找到文件。
testsuites/unittest/posix/src/common_test.h
浏览文件 @
ad6f249d
...
@@ -29,8 +29,8 @@
...
@@ -29,8 +29,8 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
#ifndef
KERNEL
_TEST_H
#ifndef
COMMON
_TEST_H
#define
KERNEL
_TEST_H
#define
COMMON
_TEST_H
#define TESTCOUNT_NUM_1 1
#define TESTCOUNT_NUM_1 1
#define TESTCOUNT_NUM_2 2
#define TESTCOUNT_NUM_2 2
...
@@ -83,6 +83,14 @@
...
@@ -83,6 +83,14 @@
} \
} \
} while (0)
} 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) \
#define ICUNIT_TRACK_EQUAL(param, value, retcode) \
do { \
do { \
if ((param) != (value)) { \
if ((param) != (value)) { \
...
...
testsuites/unittest/posix/src/fs/posix_fs_func_test.c
浏览文件 @
ad6f249d
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
LITE_TEST_SUIT
(
Posix
,
PosixFs
,
PosixFsFuncTestSuite
);
LITE_TEST_SUIT
(
Posix
,
PosixFs
,
PosixFsFuncTestSuite
);
/* Corresponding to different platforms, only need to modify TEST_ROOT */
/* 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 */
#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
...
@@ -1459,6 +1459,7 @@ LITE_TEST_CASE(PosixFsFuncTestSuite, testFsStat003, Function | MediumTest | Leve
ssize_t
size
;
ssize_t
size
;
char
writeBuf
[
TEST_BUF_SIZE
]
=
"write test"
;
char
writeBuf
[
TEST_BUF_SIZE
]
=
"write test"
;
(
void
)
memset_s
(
&
buf
,
sizeof
(
buf
),
0
,
sizeof
(
buf
));
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
fd
=
open
(
tmpFileName
,
O_CREAT
|
O_RDWR
,
0777
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
TEST_ASSERT_TRUE
(
ret
!=
-
1
);
...
...
testsuites/unittest/posix/src/math/math_func_test.c
浏览文件 @
ad6f249d
...
@@ -276,8 +276,8 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow002, Function | MediumTest | L
...
@@ -276,8 +276,8 @@ LITE_TEST_CASE(PosixMathFuncTestSuite, testMathPow002, Function | MediumTest | L
LITE_TEST_CASE
(
PosixMathFuncTestSuite
,
testMathPow003
,
Function
|
MediumTest
|
Level1
)
LITE_TEST_CASE
(
PosixMathFuncTestSuite
,
testMathPow003
,
Function
|
MediumTest
|
Level1
)
{
{
double
testValues
[][
TEST_EXPECTED
+
1
]
=
{
double
testValues
[][
TEST_EXPECTED
+
1
]
=
{
{
0
.
0
,
-
7
,
-
HUGE_VAL
},
{
0
.
0
,
-
7
,
HUGE_VAL
},
{
-
0
.
0
,
-
6
.
22
,
-
HUGE_VAL
},
{
-
0
.
0
,
-
6
.
22
,
HUGE_VAL
},
{
-
7
.
23
,
3
.
57
,
NAN
},
{
-
7
.
23
,
3
.
57
,
NAN
},
{
121223
,
5674343
,
HUGE_VAL
}
{
121223
,
5674343
,
HUGE_VAL
}
};
};
...
...
testsuites/unittest/posix/src/mqueue/mqueue_func_test.c
浏览文件 @
ad6f249d
...
@@ -34,8 +34,10 @@
...
@@ -34,8 +34,10 @@
#include <mqueue.h>
#include <mqueue.h>
#include <fcntl.h>
#include <fcntl.h>
#include "common_test.h"
#include "common_test.h"
#include "kernel_test.h"
#include "log.h"
#define MQUEUE_STANDARD_NAME_LENGTH 5
0
#define MQUEUE_STANDARD_NAME_LENGTH 5
2
#define MQUEUE_NO_ERROR 0
#define MQUEUE_NO_ERROR 0
#define MQUEUE_SEND_STRING_TEST "mq_test"
#define MQUEUE_SEND_STRING_TEST "mq_test"
#define MQUEUE_SHORT_ARRAY_LENGTH strlen(MQUEUE_SEND_STRING_TEST)
#define MQUEUE_SHORT_ARRAY_LENGTH strlen(MQUEUE_SEND_STRING_TEST)
...
@@ -49,7 +51,7 @@ const int MQ_MAX_MSG = 16; // mqueue message number
...
@@ -49,7 +51,7 @@ const int MQ_MAX_MSG = 16; // mqueue message number
const
char
MQ_MSG
[]
=
"MessageToSend"
;
// mqueue message to send
const
char
MQ_MSG
[]
=
"MessageToSend"
;
// mqueue message to send
const
int
MQ_MSG_LEN
=
sizeof
(
MQ_MSG
);
// mqueue message len 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_NAME_LEN
=
256
;
// max mqueue name length
const
int
MAX_MQ_MSG_SIZE
=
65530
;
// max mqueue message size
const
int
MAX_MQ_MSG_SIZE
=
65530
;
// max mqueue message size
...
@@ -289,6 +291,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
...
@@ -289,6 +291,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
mqd_t
queue
[
MAX_MQ_NUMBER
+
1
];
mqd_t
queue
[
MAX_MQ_NUMBER
+
1
];
int
flag
=
0
;
int
flag
=
0
;
int
i
;
int
i
;
(
void
)
memset_s
(
queue
,
sizeof
(
queue
),
0
,
sizeof
(
queue
));
for
(
i
=
0
;
i
<
MAX_MQ_NUMBER
+
1
;
i
++
)
{
for
(
i
=
0
;
i
<
MAX_MQ_NUMBER
+
1
;
i
++
)
{
sprintf_s
(
qName
[
i
],
MQ_NAME_LEN
,
"testMqOpenENFILE_%d"
,
i
);
sprintf_s
(
qName
[
i
],
MQ_NAME_LEN
,
"testMqOpenENFILE_%d"
,
i
);
}
}
...
@@ -301,7 +304,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
...
@@ -301,7 +304,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqOpenENFILE, Function | MediumTest | Le
printf
(
"break: i = %d"
,
i
);
printf
(
"break: i = %d"
,
i
);
break
;
break
;
}
}
ICUNIT_TRACK_EQUAL
(
queue
[
i
],
(
mqd_t
)
-
1
,
queue
[
i
]);
ICUNIT_TRACK_
NOT_
EQUAL
(
queue
[
i
],
(
mqd_t
)
-
1
,
queue
[
i
]);
}
}
printf
(
"func: i = %d"
,
i
);
printf
(
"func: i = %d"
,
i
);
...
@@ -368,7 +371,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEAGAIN, Function | MediumTest | Le
...
@@ -368,7 +371,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEAGAIN, Function | MediumTest | Le
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_maxmsg
=
1
;
attr
.
mq_maxmsg
=
1
;
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
ICUNIT_ASSERT_EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ICUNIT_ASSERT_
NOT_
EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
MQ_MSG_LEN
,
0
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
MQ_MSG_LEN
,
0
);
ICUNIT_TRACK_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_TRACK_EQUAL
(
ret
,
0
,
ret
);
...
@@ -400,7 +403,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
...
@@ -400,7 +403,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
attr
.
mq_msgsize
=
1
;
attr
.
mq_msgsize
=
1
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
ICUNIT_ASSERT_EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ICUNIT_ASSERT_
NOT_
EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ret
=
mq_send
(
NULL
,
MQ_MSG
,
1
,
MQ_MSG_PRIO
);
ret
=
mq_send
(
NULL
,
MQ_MSG
,
1
,
MQ_MSG_PRIO
);
ICUNIT_TRACK_EQUAL
(
ret
,
-
1
,
ret
);
ICUNIT_TRACK_EQUAL
(
ret
,
-
1
,
ret
);
...
@@ -419,7 +422,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
...
@@ -419,7 +422,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEBADFEMSGSIZE, Function | MediumTe
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDONLY
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDONLY
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
ICUNIT_ASSERT_EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ICUNIT_ASSERT_
NOT_
EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
MQ_MSG_LEN
,
MQ_MSG_PRIO
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
MQ_MSG_LEN
,
MQ_MSG_PRIO
);
ICUNIT_TRACK_EQUAL
(
ret
,
-
1
,
ret
);
ICUNIT_TRACK_EQUAL
(
ret
,
-
1
,
ret
);
...
@@ -456,7 +459,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEINVAL, Function | MediumTest | Le
...
@@ -456,7 +459,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqSendEINVAL, Function | MediumTest | Le
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
ICUNIT_ASSERT_EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ICUNIT_ASSERT_
NOT_
EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
0
,
MQ_MSG_PRIO
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
0
,
MQ_MSG_PRIO
);
ICUNIT_TRACK_EQUAL
(
ret
,
-
1
,
ret
);
ICUNIT_TRACK_EQUAL
(
ret
,
-
1
,
ret
);
...
@@ -487,7 +490,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqReceiveEAGAIN, Function | MediumTest |
...
@@ -487,7 +490,7 @@ LITE_TEST_CASE(MqueueFuncTestSuite, testMqReceiveEAGAIN, Function | MediumTest |
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_msgsize
=
MQ_MSG_SIZE
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
attr
.
mq_maxmsg
=
MQ_MAX_MSG
;
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
queue
=
mq_open
(
qName
,
O_CREAT
|
O_RDWR
|
O_NONBLOCK
,
S_IRUSR
|
S_IWUSR
,
&
attr
);
ICUNIT_ASSERT_EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ICUNIT_ASSERT_
NOT_
EQUAL_VOID
(
queue
,
(
mqd_t
)
-
1
,
queue
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
MQ_MSG_LEN
,
MQ_MSG_PRIO
);
ret
=
mq_send
(
queue
,
MQ_MSG
,
MQ_MSG_LEN
,
MQ_MSG_PRIO
);
ICUNIT_TRACK_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_TRACK_EQUAL
(
ret
,
0
,
ret
);
...
...
testsuites/unittest/posix/src/pthread/pthread_cond_func_test.c
浏览文件 @
ad6f249d
...
@@ -35,7 +35,12 @@
...
@@ -35,7 +35,12 @@
#include "los_config.h"
#include "los_config.h"
#include "cmsis_os2.h"
#include "cmsis_os2.h"
#include "common_test.h"
#include "common_test.h"
#include "kernel_test.h"
#include "pthread.h"
#include "log.h"
#define TASK_PRIO_TEST LOSCFG_BASE_CORE_TSK_DEFAULT_PRIO
#define OS_TSK_TEST_STACK_SIZE 0x1000
static
UINT32
g_testCount
;
static
UINT32
g_testCount
;
/**
/**
...
...
testsuites/unittest/posix/src/time/time_func_test_01.c
浏览文件 @
ad6f249d
...
@@ -239,11 +239,11 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime001, Function | MediumTe
...
@@ -239,11 +239,11 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltime001, Function | MediumTe
struct
tm
*
tmStart
=
localtime
(
&
tStart
);
struct
tm
*
tmStart
=
localtime
(
&
tStart
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmStart
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmStart
);
TEST_ASSERT_EQUAL_STRING
(
"
23
:59:59"
,
cTime
);
TEST_ASSERT_EQUAL_STRING
(
"
07
:59:59"
,
cTime
);
LOG
(
"
\n
time_t=%lld, first time:%s"
,
tStart
,
cTime
);
LOG
(
"
\n
time_t=%lld, first time:%s"
,
tStart
,
cTime
);
struct
tm
*
tmEnd
=
localtime
(
&
tEnd
);
struct
tm
*
tmEnd
=
localtime
(
&
tEnd
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmEnd
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmEnd
);
TEST_ASSERT_EQUAL_STRING
(
"0
0
:00:01"
,
cTime
);
TEST_ASSERT_EQUAL_STRING
(
"0
8
:00:01"
,
cTime
);
LOG
(
"
\n
time_t=%lld, first time:%s"
,
tEnd
,
cTime
);
LOG
(
"
\n
time_t=%lld, first time:%s"
,
tEnd
,
cTime
);
}
}
...
@@ -307,13 +307,13 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltimer001, Function | MediumT
...
@@ -307,13 +307,13 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeLocaltimer001, Function | MediumT
struct
tm
*
tmrEndPtr
=
localtime_r
(
&
tEnd
,
&
tmrEnd
);
struct
tm
*
tmrEndPtr
=
localtime_r
(
&
tEnd
,
&
tmrEnd
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
&
tmrStart
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
&
tmrStart
);
TEST_ASSERT_EQUAL_STRING
(
"
23
:59:59"
,
cTime
);
TEST_ASSERT_EQUAL_STRING
(
"
07
:59:59"
,
cTime
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmrStartPtr
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmrStartPtr
);
TEST_ASSERT_EQUAL_STRING
(
"
23
:59:59"
,
cTime
);
TEST_ASSERT_EQUAL_STRING
(
"
07
:59:59"
,
cTime
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
&
tmrEnd
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
&
tmrEnd
);
TEST_ASSERT_EQUAL_STRING
(
"0
0
:00:01"
,
cTime
);
TEST_ASSERT_EQUAL_STRING
(
"0
8
:00:01"
,
cTime
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmrEndPtr
);
strftime
(
cTime
,
sizeof
(
cTime
),
"%H:%M:%S"
,
tmrEndPtr
);
TEST_ASSERT_EQUAL_STRING
(
"0
0
:00:01"
,
cTime
);
TEST_ASSERT_EQUAL_STRING
(
"0
8
:00:01"
,
cTime
);
}
}
/* *
/* *
...
@@ -366,12 +366,12 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime001, Function | MediumTest
...
@@ -366,12 +366,12 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime001, Function | MediumTest
INIT_TM
(
timeptr
,
2020
,
7
,
9
,
18
,
10
,
0
,
7
);
INIT_TM
(
timeptr
,
2020
,
7
,
9
,
18
,
10
,
0
,
7
);
time_t
timeRet
=
mktime
(
&
timeptr
);
time_t
timeRet
=
mktime
(
&
timeptr
);
LOG
(
"
\n
2020-7-9 18:10:00, mktime Ret = %lld"
,
timeRet
);
LOG
(
"
\n
2020-7-9 18:10:00, mktime Ret = %lld"
,
timeRet
);
TEST_ASSERT_EQUAL_INT
(
15969
678
00
,
timeRet
);
TEST_ASSERT_EQUAL_INT
(
15969
966
00
,
timeRet
);
INIT_TM
(
timeptr
,
1970
,
0
,
1
,
8
,
0
,
0
,
0
);
INIT_TM
(
timeptr
,
1970
,
0
,
1
,
8
,
0
,
0
,
0
);
timeRet
=
mktime
(
&
timeptr
);
timeRet
=
mktime
(
&
timeptr
);
LOG
(
"
\n
1970-1-1 08:00:00, mktime Ret = %lld"
,
timeRet
);
LOG
(
"
\n
1970-1-1 08:00:00, mktime Ret = %lld"
,
timeRet
);
TEST_ASSERT_EQUAL_INT
(
0
,
timeRet
);
TEST_ASSERT_EQUAL_INT
(
2880
0
,
timeRet
);
struct
tm
*
stm
=
localtime
(
&
testTime
);
struct
tm
*
stm
=
localtime
(
&
testTime
);
LOG
(
"
\n
testTime 18880, tm : %s"
,
TmToStr
(
stm
,
timeStr
,
TIME_STR_LEN
));
LOG
(
"
\n
testTime 18880, tm : %s"
,
TmToStr
(
stm
,
timeStr
,
TIME_STR_LEN
));
...
@@ -406,7 +406,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime002, Function | MediumTest
...
@@ -406,7 +406,7 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeMktime002, Function | MediumTest
INIT_TM
(
timeptr
,
1969
,
7
,
9
,
10
,
10
,
0
,
7
);
INIT_TM
(
timeptr
,
1969
,
7
,
9
,
10
,
10
,
0
,
7
);
time_t
timeRet
=
mktime
(
&
timeptr
);
time_t
timeRet
=
mktime
(
&
timeptr
);
LOG
(
"
\n
1800-8-9 10:10:00, mktime Ret lld = %lld"
,
timeRet
);
LOG
(
"
\n
1800-8-9 10:10:00, mktime Ret lld = %lld"
,
timeRet
);
TEST_ASSERT_EQUAL_INT
(
0
,
timeRet
);
TEST_ASSERT_EQUAL_INT
(
-
1
,
timeRet
);
}
}
...
@@ -503,8 +503,9 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime003, Function | MediumTes
...
@@ -503,8 +503,9 @@ LITE_TEST_CASE(PosixTimeFuncTestSuite, testTimeStrftime003, Function | MediumTes
TEST_ASSERT_EQUAL_STRING
(
"1970-01-01 13:14:40"
,
buffer
);
TEST_ASSERT_EQUAL_STRING
(
"1970-01-01 13:14:40"
,
buffer
);
LOG
(
"
\n
result: %s, expected : %s"
,
buffer
,
"1970-01-01 13:14:40"
);
LOG
(
"
\n
result: %s, expected : %s"
,
buffer
,
"1970-01-01 13:14:40"
);
tmTime
->
__tm_zone
=
"UTC+8"
;
ftime
=
strftime
(
buffer
,
80
,
"%F %T %Z"
,
tmTime
);
ftime
=
strftime
(
buffer
,
80
,
"%F %T %Z"
,
tmTime
);
TEST_ASSERT_EQUAL_INT
(
0
,
ftime
);
TEST_ASSERT_EQUAL_INT
(
2
0
,
ftime
);
LOG
(
"
\n
result: %s, expected : %s"
,
buffer
,
"1970-01-01 13:14:40"
);
LOG
(
"
\n
result: %s, expected : %s"
,
buffer
,
"1970-01-01 13:14:40"
);
};
};
...
@@ -546,7 +547,7 @@ RUN_TEST_SUITE(PosixTimeFuncTestSuite);
...
@@ -546,7 +547,7 @@ RUN_TEST_SUITE(PosixTimeFuncTestSuite);
void
PosixTimeFuncTest
()
void
PosixTimeFuncTest
()
{
{
LOG
(
"begin PosixTimeFuncTest...."
);
LOG
(
"begin PosixTimeFuncTest....
\n
"
);
RUN_ONE_TESTCASE
(
testTimeUSleep001
);
RUN_ONE_TESTCASE
(
testTimeUSleep001
);
RUN_ONE_TESTCASE
(
testTimeUSleep002
);
RUN_ONE_TESTCASE
(
testTimeUSleep002
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录