Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
122ad013
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
122ad013
编写于
4月 20, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 20, 2022
浏览文件
操作
浏览文件
下载
差异文件
!517 增加单元测试用例
Merge pull request !517 from 熊磊/master_cc
上级
a11eec09
af509d93
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
611 addition
and
45 deletion
+611
-45
services/begetctl/shell/shell_bas.c
services/begetctl/shell/shell_bas.c
+5
-1
services/begetctl/shell/shell_bas.h
services/begetctl/shell/shell_bas.h
+23
-0
services/loopevent/loop/le_loop.h
services/loopevent/loop/le_loop.h
+12
-0
services/loopevent/socket/le_socket.h
services/loopevent/socket/le_socket.h
+10
-0
services/loopevent/task/le_task.h
services/loopevent/task/le_task.h
+13
-0
test/unittest/BUILD.gn
test/unittest/BUILD.gn
+2
-0
test/unittest/init/cmds_unittest.cpp
test/unittest/init/cmds_unittest.cpp
+13
-0
test/unittest/init/group_unittest.cpp
test/unittest/init/group_unittest.cpp
+5
-0
test/unittest/init/loopevent_unittest.cpp
test/unittest/init/loopevent_unittest.cpp
+290
-0
test/unittest/init/service_socket_unittest.cpp
test/unittest/init/service_socket_unittest.cpp
+6
-0
test/unittest/innerkits/innerkits_unittest.cpp
test/unittest/innerkits/innerkits_unittest.cpp
+0
-16
test/unittest/param/dac_unittest.cpp
test/unittest/param/dac_unittest.cpp
+18
-18
test/unittest/param/param_shell_unittest.cpp
test/unittest/param/param_shell_unittest.cpp
+197
-0
test/unittest/param/param_unittest.cpp
test/unittest/param/param_unittest.cpp
+14
-7
test/unittest/tools/prepare_testdata.sh
test/unittest/tools/prepare_testdata.sh
+3
-3
未找到文件。
services/begetctl/shell/shell_bas.c
浏览文件 @
122ad013
...
...
@@ -86,7 +86,9 @@ int32_t BShellCmdHelp(BShellHandle handle, int32_t argc, char *argv[])
static
int32_t
BShellCmdExit
(
BShellHandle
handle
,
int32_t
argc
,
char
*
argv
[])
{
#ifndef STARTUP_INIT_TEST
kill
(
getpid
(),
SIGINT
);
#endif
return
0
;
}
...
...
@@ -313,7 +315,9 @@ static int32_t BShellEnvHandleCtrC(BShellHandle handle, uint8_t code)
{
BSH_CHECK
(
handle
!=
NULL
,
return
BSH_INVALID_PARAM
,
"Invalid shell env"
);
BSH_LOGV
(
"BShellEnvHandleCtrC %d"
,
getpid
());
#ifndef STARTUP_INIT_TEST
kill
(
getpid
(),
SIGKILL
);
#endif
return
0
;
}
...
...
@@ -344,7 +348,7 @@ BShellKey *BShellEnvGetDefaultKey(uint8_t code)
return
NULL
;
}
static
void
BShellEnvProcessInput
(
BShellHandle
handle
,
char
data
)
SHELLSTATIC
void
BShellEnvProcessInput
(
BShellHandle
handle
,
char
data
)
{
BSH_CHECK
(
handle
!=
NULL
,
return
,
"Invalid shell env"
);
BShellEnv
*
shell
=
(
BShellEnv
*
)
handle
;
...
...
services/begetctl/shell/shell_bas.h
浏览文件 @
122ad013
...
...
@@ -32,6 +32,18 @@
#define BSH_CMD_NAME_END 48
#define BSH_CMD_MAX_KEY 5
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
#ifdef STARTUP_INIT_TEST
#define SHELLSTATIC
#else
#define SHELLSTATIC static
#endif
typedef
enum
{
BSH_IN_NORMAL
=
0
,
BSH_ANSI_ESC
,
...
...
@@ -90,4 +102,15 @@ void BShellEnvOutputByte(BShellHandle handle, char data);
void
BShellEnvOutputResult
(
BShellHandle
handle
,
int32_t
result
);
char
*
BShellEnvErrString
(
BShellHandle
handle
,
int32_t
err
);
const
char
*
BShellEnvGetStringParam
(
BShellHandle
handle
,
const
char
*
name
);
#ifdef STARTUP_INIT_TEST
void
BShellEnvProcessInput
(
BShellHandle
handle
,
char
data
);
BShellKey
*
BShellEnvGetDefaultKey
(
uint8_t
code
);
#endif
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
\ No newline at end of file
services/loopevent/loop/le_loop.h
浏览文件 @
122ad013
...
...
@@ -21,6 +21,12 @@
#include "le_utils.h"
#include "init_hashmap.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
typedef
struct
EventLoop_
{
LE_STATUS
(
*
close
)(
const
struct
EventLoop_
*
loop
);
LE_STATUS
(
*
runLoop
)(
const
struct
EventLoop_
*
loop
);
...
...
@@ -41,4 +47,10 @@ BaseTask *GetTaskByFd(EventLoop *loop, int fd);
void
DelTask
(
EventLoop
*
loop
,
BaseTask
*
task
);
LE_STATUS
ProcessEvent
(
const
EventLoop
*
loop
,
int
fd
,
uint32_t
oper
);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
\ No newline at end of file
services/loopevent/socket/le_socket.h
浏览文件 @
122ad013
...
...
@@ -18,7 +18,17 @@
#include "le_utils.h"
#include "loop_event.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
int
CreateSocket
(
int
flags
,
const
char
*
server
);
int
AcceptSocket
(
int
fd
,
int
flags
);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
\ No newline at end of file
services/loopevent/task/le_task.h
浏览文件 @
122ad013
...
...
@@ -35,6 +35,12 @@
#define LoopMutexUnlock(x) pthread_mutex_unlock(x)
#endif
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
typedef
struct
{
ListNode
node
;
uint32_t
buffSize
;
...
...
@@ -117,4 +123,11 @@ BaseTask *CreateTask(const LoopHandle loopHandle, int fd, const LE_BaseInfo *inf
void
CloseTask
(
const
LoopHandle
loopHandle
,
BaseTask
*
task
);
int
GetSocketFd
(
const
TaskHandle
task
);
int
CheckTaskFlags
(
const
BaseTask
*
task
,
uint32_t
flags
);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
\ No newline at end of file
test/unittest/BUILD.gn
浏览文件 @
122ad013
...
...
@@ -117,6 +117,7 @@ ohos_unittest("init_ut") {
"init/cmds_unittest.cpp",
"init/group_unittest.cpp",
"init/init_reboot_unittest.cpp",
"init/loopevent_unittest.cpp",
"init/mount_unittest.cpp",
"init/plugin_unittest.cpp",
"init/service_file_unittest.cpp",
...
...
@@ -125,6 +126,7 @@ ohos_unittest("init_ut") {
"init/utils_unittest.cpp",
"param/client_unittest.cpp",
"param/dac_unittest.cpp",
"param/param_shell_unittest.cpp",
"param/param_unittest.cpp",
"param/selinux_unittest.cpp",
"param/trigger_unittest.cpp",
...
...
test/unittest/init/cmds_unittest.cpp
浏览文件 @
122ad013
...
...
@@ -63,6 +63,19 @@ HWTEST_F(CmdsUnitTest, TestCmdExecByName, TestSize.Level1)
DoCmdByName
(
"makedev "
,
"999 999"
);
DoCmdByName
(
"mount_fstab "
,
""
);
DoCmdByName
(
"umount_fstab "
,
""
);
DoCmdByName
(
"mksandbox "
,
"system"
);
DoCmdByName
(
"timer_start "
,
"media_service|5000"
);
DoCmdByName
(
"timer_stop "
,
"media_service"
);
DoCmdByName
(
"exec "
,
"media_service"
);
DoCmdByName
(
"load_access_token_id "
,
"media_service"
);
DoCmdByName
(
"stopAllServices "
,
""
);
DoCmdByName
(
"umount "
,
""
);
DoCmdByName
(
"mount "
,
""
);
DoCmdByName
(
"init_global_key "
,
""
);
DoCmdByName
(
"init_main_user "
,
"testUser"
);
DoCmdByName
(
"mkswap "
,
""
);
DoCmdByName
(
"swapon "
,
""
);
DoCmdByName
(
"sync "
,
""
);
}
HWTEST_F
(
CmdsUnitTest
,
TestCommonMkdir
,
TestSize
.
Level1
)
...
...
test/unittest/init/group_unittest.cpp
浏览文件 @
122ad013
...
...
@@ -20,6 +20,8 @@
#include "init_unittest.h"
#include "init_utils.h"
#include "securec.h"
#include "init_service.h"
#include "le_timer.h"
using
namespace
testing
::
ext
;
using
namespace
std
;
...
...
@@ -239,6 +241,9 @@ HWTEST_F(InitGroupManagerUnitTest, TestAddService, TestSize.Level1)
cJSON_Delete
(
fileRoot
);
Service
*
service
=
GetServiceByName
(
"test-service"
);
ServiceStartTimer
(
service
,
1
);
((
TimerTask
*
)
service
->
timer
)
->
base
.
handleEvent
(
LE_GetDefaultLoop
(),
(
LoopBase
*
)
service
->
timer
,
Event_Read
);
ServiceStopTimer
(
service
);
ASSERT_NE
(
service
!=
nullptr
,
0
);
EXPECT_EQ
(
service
->
startMode
,
START_MODE_CONDITION
);
ReleaseService
(
service
);
...
...
test/unittest/init/loopevent_unittest.cpp
0 → 100644
浏览文件 @
122ad013
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <pthread.h>
#include <sys/eventfd.h>
#include "init_unittest.h"
#include "init_utils.h"
#include "init_param.h"
#include "init_hashmap.h"
#include "loop_event.h"
#include "le_loop.h"
#include "init.h"
#include "param_utils.h"
#include "le_task.h"
#include "le_socket.h"
#include "le_epoll.h"
#include "param_message.h"
#include "param_manager.h"
#include "param_service.h"
#include "trigger_manager.h"
using
namespace
testing
::
ext
;
using
namespace
std
;
using
HashTab
=
struct
{
HashNodeCompare
nodeCompare
;
HashKeyCompare
keyCompare
;
HashNodeFunction
nodeHash
;
HashKeyFunction
keyHash
;
HashNodeOnFree
nodeFree
;
int
maxBucket
;
uint32_t
tableId
;
HashNode
*
buckets
[
0
];
};
static
void
OnReceiveRequest
(
const
TaskHandle
task
,
const
uint8_t
*
buffer
,
uint32_t
nread
)
{
UNUSED
(
task
);
UNUSED
(
buffer
);
UNUSED
(
nread
);
}
static
void
Close
(
ParamTaskPtr
client
)
{
(
void
)(
client
);
return
;
}
static
void
ProcessAsyncEvent
(
const
TaskHandle
taskHandle
,
uint64_t
eventId
,
const
uint8_t
*
buffer
,
uint32_t
buffLen
)
{
UNUSED
(
taskHandle
);
UNUSED
(
eventId
);
UNUSED
(
buffer
);
UNUSED
(
buffLen
);
}
static
int
IncomingConnect
(
LoopHandle
loop
,
TaskHandle
server
)
{
UNUSED
(
loop
);
UNUSED
(
server
);
return
0
;
}
static
void
ProcessWatchEventTest
(
WatcherHandle
taskHandle
,
int
fd
,
uint32_t
*
events
,
const
void
*
context
)
{
UNUSED
(
taskHandle
);
UNUSED
(
fd
);
UNUSED
(
events
);
UNUSED
(
context
);
}
static
EventLoop
*
g_testLoop
=
nullptr
;
static
void
*
RunLoopThread
(
void
*
arg
)
{
LE_RunLoop
((
LoopHandle
)
g_testLoop
);
return
nullptr
;
}
namespace
init_ut
{
class
LoopEventUnittest
:
public
testing
::
Test
{
public:
LoopEventUnittest
()
{};
virtual
~
LoopEventUnittest
()
{};
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
()
{};
void
TearDown
()
{};
void
TestBody
(
void
)
{};
void
StreamTaskTest
()
{
LE_StreamInfo
streamInfo
=
{};
streamInfo
.
recvMessage
=
OnReceiveRequest
;
streamInfo
.
baseInfo
.
flags
=
TASK_STREAM
|
TASK_PIPE
|
TASK_CONNECT
|
TASK_TEST
;
streamInfo
.
server
=
(
char
*
)
"/data/testpipea"
;
TaskHandle
clientTaskHandle
=
nullptr
;
LE_AcceptStreamClient
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
GetParamWorkSpace
()
->
serverTask
,
&
clientTaskHandle
,
&
streamInfo
);
if
(
clientTaskHandle
==
nullptr
)
{
return
;
}
((
StreamConnectTask
*
)
clientTaskHandle
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
clientTaskHandle
,
Event_Read
);
((
StreamConnectTask
*
)
clientTaskHandle
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
clientTaskHandle
,
Event_Write
);
((
StreamConnectTask
*
)
clientTaskHandle
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
clientTaskHandle
,
0
);
((
HashTab
*
)((
EventLoop
*
)
LE_GetDefaultLoop
())
->
taskMap
)
->
nodeFree
(
&
((
BaseTask
*
)(
&
clientTaskHandle
))
->
hashNode
);
streamInfo
.
baseInfo
.
flags
=
TASK_STREAM
|
TASK_PIPE
|
TASK_SERVER
;
streamInfo
.
server
=
(
char
*
)
"/data/testpipeb"
;
TaskHandle
clientTaskHandleb
=
nullptr
;
LE_CreateStreamClient
(
LE_GetDefaultLoop
(),
&
clientTaskHandleb
,
&
streamInfo
);
if
(
clientTaskHandleb
==
nullptr
)
{
return
;
}
((
StreamClientTask
*
)
clientTaskHandleb
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
clientTaskHandleb
,
Event_Read
);
((
StreamClientTask
*
)
clientTaskHandleb
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
clientTaskHandleb
,
Event_Write
);
((
StreamClientTask
*
)
clientTaskHandleb
)
->
stream
.
base
.
innerClose
(
LE_GetDefaultLoop
(),
clientTaskHandleb
);
TaskHandle
clientTaskHandlec
=
nullptr
;
streamInfo
.
baseInfo
.
flags
=
TASK_STREAM
|
TASK_TCP
|
TASK_SERVER
;
streamInfo
.
server
=
(
char
*
)
"0.0.0.0:10110"
;
LE_CreateStreamClient
(
LE_GetDefaultLoop
(),
&
clientTaskHandlec
,
&
streamInfo
);
if
(
clientTaskHandlec
==
nullptr
)
{
return
;
}
TaskHandle
clientTaskHandled
=
nullptr
;
streamInfo
.
baseInfo
.
flags
=
TASK_STREAM
|
TASK_TCP
|
TASK_CONNECT
;
streamInfo
.
server
=
(
char
*
)
"127.0.0.1:10111"
;
LE_CreateStreamClient
(
LE_GetDefaultLoop
(),
&
clientTaskHandled
,
&
streamInfo
);
if
(
clientTaskHandled
==
nullptr
)
{
return
;
}
}
void
LeTaskTest
()
{
ParamTaskPtr
serverTask
=
nullptr
;
LE_StreamServerInfo
info
=
{};
info
.
baseInfo
.
flags
=
TASK_STREAM
|
TASK_PIPE
|
TASK_SERVER
|
TASK_TEST
;
info
.
server
=
(
char
*
)
"/data/testpipe"
;
info
.
baseInfo
.
close
=
Close
;
info
.
incommingConntect
=
IncomingConnect
;
LE_CreateStreamServer
(
LE_GetDefaultLoop
(),
&
serverTask
,
&
info
);
if
(
serverTask
==
nullptr
)
{
return
;
}
((
StreamServerTask
*
)
serverTask
)
->
base
.
handleEvent
(
LE_GetDefaultLoop
(),
serverTask
,
Event_Write
);
((
StreamServerTask
*
)
serverTask
)
->
base
.
handleEvent
(
LE_GetDefaultLoop
(),
serverTask
,
Event_Read
);
uint64_t
eventId
=
0
;
ParamStreamInfo
paramStreamInfo
=
{};
paramStreamInfo
.
flags
=
PARAM_TEST_FLAGS
;
paramStreamInfo
.
server
=
NULL
;
paramStreamInfo
.
close
=
Close
;
paramStreamInfo
.
recvMessage
=
ProcessMessage
;
paramStreamInfo
.
incomingConnect
=
NULL
;
ParamTaskPtr
client
=
NULL
;
int
ret
=
ParamStreamCreate
(
&
client
,
GetParamWorkSpace
()
->
serverTask
,
&
paramStreamInfo
,
sizeof
(
ParamWatcher
));
PARAM_CHECK
(
ret
==
0
,
return
,
"Failed to create client"
);
BufferHandle
handle
=
LE_CreateBuffer
(
LE_GetDefaultLoop
(),
1
+
sizeof
(
eventId
));
LE_Buffer
*
buffer
=
(
LE_Buffer
*
)
handle
;
AddBuffer
((
StreamTask
*
)
client
,
buffer
);
((
StreamConnectTask
*
)
client
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
(
TaskHandle
)(
&
client
),
Event_Write
);
LE_Buffer
*
next
=
nullptr
;
LE_Buffer
*
nextBuff
=
GetNextBuffer
((
StreamTask
*
)
client
,
next
);
if
(
nextBuff
!=
nullptr
)
{
LE_FreeBuffer
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
&
client
,
nextBuff
);
}
ret
=
ParamStreamCreate
(
&
client
,
GetParamWorkSpace
()
->
serverTask
,
&
paramStreamInfo
,
sizeof
(
ParamWatcher
));
PARAM_CHECK
(
ret
==
0
,
return
,
"Failed to create client"
);
((
StreamConnectTask
*
)(
&
client
))
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
(
TaskHandle
)(
&
client
),
Event_Read
);
}
void
ProcessEventTest
()
{
ProcessEvent
((
EventLoop
*
)
LE_GetDefaultLoop
(),
1
,
Event_Read
);
}
void
ProcessasynEvent
()
{
TaskHandle
asynHandle
=
nullptr
;
LE_CreateAsyncTask
(
LE_GetDefaultLoop
(),
&
asynHandle
,
ProcessAsyncEvent
);
if
(
asynHandle
==
nullptr
)
{
return
;
}
((
AsyncEventTask
*
)
asynHandle
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
asynHandle
,
Event_Read
);
((
AsyncEventTask
*
)
asynHandle
)
->
stream
.
base
.
handleEvent
(
LE_GetDefaultLoop
(),
asynHandle
,
Event_Write
);
LE_StopAsyncTask
(
LE_GetDefaultLoop
(),
asynHandle
);
}
void
ProcessWatcherTask
()
{
WatcherHandle
handle
=
nullptr
;
LE_WatchInfo
info
=
{};
info
.
fd
=
-
1
;
info
.
flags
=
WATCHER_ONCE
;
info
.
events
=
Event_Read
;
info
.
processEvent
=
ProcessWatchEventTest
;
LE_StartWatcher
(
LE_GetDefaultLoop
(),
&
handle
,
&
info
,
nullptr
);
if
(
handle
==
nullptr
)
{
return
;
}
((
WatcherTask
*
)
handle
)
->
base
.
handleEvent
(
LE_GetDefaultLoop
(),
(
TaskHandle
)
handle
,
Event_Read
);
}
void
CreateSocketTest
()
{
ParamTaskPtr
clientTask
=
nullptr
;
LE_StreamServerInfo
info
=
{};
info
.
baseInfo
.
flags
=
TASK_PIPE
|
TASK_CONNECT
|
TASK_TEST
;
info
.
server
=
(
char
*
)
"/data/testpipe"
;
info
.
baseInfo
.
close
=
Close
;
info
.
incommingConntect
=
IncomingConnect
;
LE_CreateStreamServer
(
LE_GetDefaultLoop
(),
&
clientTask
,
&
info
);
EXPECT_NE
(
clientTask
,
nullptr
);
if
(
clientTask
==
nullptr
)
{
return
;
}
LE_GetSocketFd
(
clientTask
);
AcceptSocket
(
-
1
,
TASK_PIPE
);
AcceptSocket
(
-
1
,
TASK_TCP
);
}
};
HWTEST_F
(
LoopEventUnittest
,
StreamTaskTest
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
loopevtest
.
StreamTaskTest
();
}
HWTEST_F
(
LoopEventUnittest
,
LeTaskTest
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
loopevtest
.
LeTaskTest
();
}
HWTEST_F
(
LoopEventUnittest
,
runServerTest
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
loopevtest
.
ProcessEventTest
();
}
HWTEST_F
(
LoopEventUnittest
,
ProcessasynEvent
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
loopevtest
.
ProcessasynEvent
();
}
HWTEST_F
(
LoopEventUnittest
,
CreateSocketTest
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
loopevtest
.
CreateSocketTest
();
}
HWTEST_F
(
LoopEventUnittest
,
ProcessWatcherTask
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
loopevtest
.
ProcessWatcherTask
();
}
HWTEST_F
(
LoopEventUnittest
,
RunLoopThread
,
TestSize
.
Level1
)
{
pthread_t
tid
=
0
;
int
fd
=
eventfd
(
1
,
EFD_NONBLOCK
|
EFD_CLOEXEC
);
LE_CreateLoop
((
LoopHandle
*
)
&
g_testLoop
);
EventEpoll
*
epoll
=
(
EventEpoll
*
)
g_testLoop
;
struct
epoll_event
event
=
{};
event
.
events
=
EPOLLIN
;
if
(
fd
>=
0
)
{
epoll_ctl
(
epoll
->
epollFd
,
EPOLL_CTL_ADD
,
fd
,
&
event
);
}
pthread_create
(
&
tid
,
nullptr
,
RunLoopThread
,
nullptr
);
LE_StopLoop
((
LoopHandle
)
g_testLoop
);
event
.
events
=
EPOLLOUT
;
epoll_ctl
(
epoll
->
epollFd
,
EPOLL_CTL_MOD
,
fd
,
&
event
);
pthread_join
(
tid
,
nullptr
);
}
}
// namespace init_ut
test/unittest/init/service_socket_unittest.cpp
浏览文件 @
122ad013
...
...
@@ -21,6 +21,7 @@
#include "init_socket.h"
#include "init_unittest.h"
#include "securec.h"
#include "le_task.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
init_ut
{
...
...
@@ -34,8 +35,11 @@ public:
HWTEST_F
(
ServiceSocketUnitTest
,
TestCreateSocket
,
TestSize
.
Level0
)
{
const
char
*
testSocName
=
"test_socket"
;
uint32_t
eventid
=
1
;
Service
*
service
=
(
Service
*
)
AddService
(
"TestCreateSocket"
);
ASSERT_NE
(
service
,
nullptr
);
service
->
socketCfg
=
nullptr
;
service
->
attribute
=
SERVICE_ATTR_ONDEMAND
;
ServiceSocket
*
sockopt
=
(
ServiceSocket
*
)
calloc
(
1
,
sizeof
(
ServiceSocket
)
+
strlen
(
testSocName
)
+
1
);
ASSERT_NE
(
sockopt
,
nullptr
);
sockopt
->
type
=
SOCK_STREAM
;
...
...
@@ -56,6 +60,8 @@ HWTEST_F(ServiceSocketUnitTest, TestCreateSocket, TestSize.Level0)
service
->
socketCfg
->
next
=
sockopt
;
}
int
ret1
=
CreateServiceSocket
(
service
);
((
WatcherTask
*
)((
ServiceSocket
*
)
service
->
socketCfg
)
->
watcher
)
->
processEvent
(
LE_GetDefaultLoop
(),
0
,
&
eventid
,
service
);
EXPECT_EQ
(
ret1
,
0
);
ret1
=
GetControlSocket
(
testSocName
);
EXPECT_GE
(
ret1
,
0
);
...
...
test/unittest/innerkits/innerkits_unittest.cpp
浏览文件 @
122ad013
...
...
@@ -16,7 +16,6 @@
#include <cinttypes>
#include <sys/mount.h>
#include "fs_manager/fs_manager.h"
#include "fs_manager/fs_manager_log.h"
#include "init_log.h"
#include "init_unittest.h"
#include "securec.h"
...
...
@@ -129,19 +128,4 @@ HWTEST_F(InnerkitsUnitTest, GetMountFlags_unitest, TestSize.Level1)
ReleaseFstab
(
fstab
);
fstab
=
nullptr
;
}
HWTEST_F
(
InnerkitsUnitTest
,
TestFsManagerLog
,
TestSize
.
Level1
)
{
FsManagerLogInit
(
LOG_TO_KERNEL
,
FILE_NAME
);
FSMGR_LOGE
(
"Fsmanager log to kernel."
);
FsManagerLogInit
(
LOG_TO_STDIO
,
""
);
FSMGR_LOGE
(
"Fsmanager log to stdio."
);
string
logPath
=
"/data/init_ut/fs_log.txt"
;
auto
fp
=
std
::
unique_ptr
<
FILE
,
decltype
(
&
fclose
)
>
(
fopen
(
logPath
.
c_str
(),
"at+"
),
fclose
);
EXPECT_TRUE
(
fp
!=
nullptr
);
sync
();
FsManagerLogInit
(
LOG_TO_FILE
,
logPath
.
c_str
());
FSMGR_LOGE
(
"Fsmanager log to file."
);
FsManagerLogDeInit
();
}
}
// namespace init_ut
test/unittest/param/dac_unittest.cpp
浏览文件 @
122ad013
...
...
@@ -204,29 +204,29 @@ HWTEST_F(DacUnitTest, TestDacCheckUserParaPermission, TestSize.Level0)
EXPECT_EQ
(
ret
,
0
);
dacData
.
mode
=
0400
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.read.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0400
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.read.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
// write
dacData
.
mode
=
0200
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_READ
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0200
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_EQ
(
ret
,
0
);
dacData
.
mode
=
0200
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
// watch
dacData
.
mode
=
0100
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_READ
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0100
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0100
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_EQ
(
ret
,
0
);
...
...
@@ -245,29 +245,29 @@ HWTEST_F(DacUnitTest, TestDacCheckGroupParaPermission, TestSize.Level0)
EXPECT_EQ
(
ret
,
0
);
dacData
.
mode
=
0040
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.read.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0040
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.read.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
// write
dacData
.
mode
=
0020
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_READ
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0020
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_EQ
(
ret
,
0
);
dacData
.
mode
=
0020
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
// watch
dacData
.
mode
=
0010
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_READ
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0010
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0010
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_EQ
(
ret
,
0
);
...
...
@@ -286,29 +286,29 @@ HWTEST_F(DacUnitTest, TestDacCheckOtherParaPermission, TestSize.Level0)
EXPECT_EQ
(
ret
,
0
);
dacData
.
mode
=
0004
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.read.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0004
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.read.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
// write
dacData
.
mode
=
0002
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_READ
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0002
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_EQ
(
ret
,
0
);
dacData
.
mode
=
0002
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.write.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
// watch
dacData
.
mode
=
0001
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_READ
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0001
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_WRITE
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
dacData
.
mode
=
0001
;
ret
=
test
.
TestDacCheckParaPermission
(
"test.permission.watch.aaa"
,
&
dacData
,
DAC_WATCH
);
EXPECT_EQ
(
ret
,
0
);
...
...
test/unittest/param/param_shell_unittest.cpp
0 → 100644
浏览文件 @
122ad013
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "begetctl.h"
#include "init_unittest.h"
#include "securec.h"
#include "shell.h"
#include "shell_utils.h"
#include "shell_bas.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
init_ut
{
class
ParamShellUnitTest
:
public
testing
::
Test
{
public:
ParamShellUnitTest
()
{};
virtual
~
ParamShellUnitTest
()
{};
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
(
void
)
{};
void
TearDown
(
void
)
{};
void
TestBody
(
void
)
{};
void
TestInitParamShell
()
{
BShellHandle
bshd
=
GetShellHandle
();
if
(
bshd
==
nullptr
)
{
return
;
}
const
char
*
args
[]
=
{
"paramshell"
,
"
\n
"
};
const
ParamInfo
*
param
=
BShellEnvGetReservedParam
(
bshd
,
PARAM_REVERESD_NAME_CURR_PARAMETER
);
int
ret
=
BShellEnvSetParam
(
bshd
,
param
->
name
,
param
->
desc
,
param
->
type
,
(
void
*
)
""
);
EXPECT_EQ
(
ret
,
0
);
SetParamShellPrompt
(
bshd
,
args
[
1
]);
BShellParamCmdRegister
(
bshd
,
1
);
BShellEnvStart
(
bshd
);
ret
=
BShellEnvOutputPrompt
(
bshd
,
"testprompt"
);
BShellEnvOutputByte
(
bshd
,
'o'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellCmd
()
{
BShellHandle
bshd
=
GetShellHandle
();
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\n'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"cd const"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"cat aaa"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testnotcmd"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
// test param start with "
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"
\"
ls"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
// test argc is 0
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
",ls"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"$test$"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"exit"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellCmd1
()
{
BShellHandle
bshd
=
GetShellHandle
();
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\n'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"pwd"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"help"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"dump"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"dump verbose"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellcmdEndkey
()
{
BShellHandle
bshd
=
GetShellHandle
();
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\b'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testbbackspace"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
bshd
->
cursor
=
strlen
(
"testb"
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\b'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testbbackspace"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
bshd
->
cursor
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\b'
);
EXPECT_EQ
(
ret
,
0
);
key
=
BShellEnvGetDefaultKey
(
'\t'
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testtab"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\t'
);
EXPECT_NE
(
key
,
nullptr
);
BShellEnvProcessInput
(
bshd
,
(
char
)
3
);
// 3 is ctrl c
BShellEnvProcessInput
(
bshd
,
'\e'
);
}
};
HWTEST_F
(
ParamShellUnitTest
,
TestInitParamShell
,
TestSize
.
Level1
)
{
ParamShellUnitTest
test
;
test
.
TestInitParamShell
();
test
.
TestParamShellCmd
();
test
.
TestParamShellCmd1
();
}
HWTEST_F
(
ParamShellUnitTest
,
TestParamShellInput
,
TestSize
.
Level1
)
{
BShellHandle
bshd
=
GetShellHandle
();
BShellEnvProcessInput
(
bshd
,
'\n'
);
BShellEnvProcessInput
(
bshd
,
'l'
);
bshd
->
length
=
BSH_COMMAND_MAX_LENGTH
;
BShellEnvProcessInput
(
bshd
,
'l'
);
bshd
->
length
=
sizeof
(
'l'
);
bshd
->
cursor
=
0
;
BShellEnvProcessInput
(
bshd
,
's'
);
BShellEnvProcessInput
(
bshd
,
'\n'
);
BShellEnvProcessInput
(
bshd
,
'\n'
);
// test bshd buff length is 0
int
ret
=
BShellEnvRegisterKeyHandle
(
bshd
,
'z'
,
(
BShellkeyHandle
)(
void
*
)
0x409600
);
// 0x409600 construct address
EXPECT_EQ
(
ret
,
0
);
}
HWTEST_F
(
ParamShellUnitTest
,
TestParamShellcmd2
,
TestSize
.
Level1
)
{
BShellHandle
bshd
=
GetShellHandle
();
ParamShellUnitTest
test
;
test
.
TestParamShellcmdEndkey
();
BShellEnvDestory
(
bshd
);
}
}
// namespace init_ut
test/unittest/param/param_unittest.cpp
浏览文件 @
122ad013
...
...
@@ -18,9 +18,17 @@
#include "init_unittest.h"
#include "param_stub.h"
#include "trigger_manager.h"
#include "param_message.h"
#include "param_utils.h"
using
namespace
testing
::
ext
;
using
namespace
std
;
static
void
OnClose
(
ParamTaskPtr
client
)
{
UNUSED
(
client
);
}
static
int
CheckServerParamValue
(
const
char
*
name
,
const
char
*
expectValue
)
{
char
tmp
[
PARAM_BUFFER_SIZE
]
=
{
0
};
...
...
@@ -304,7 +312,7 @@ public:
ParamStreamInfo
info
=
{};
info
.
flags
=
PARAM_TEST_FLAGS
;
info
.
server
=
NULL
;
info
.
close
=
NULL
;
info
.
close
=
OnClose
;
info
.
recvMessage
=
ProcessMessage
;
info
.
incomingConnect
=
NULL
;
ParamTaskPtr
client
=
NULL
;
...
...
@@ -353,7 +361,6 @@ public:
ProcessMessage
((
const
ParamTaskPtr
)
g_worker
,
(
const
ParamMessage
*
)
request
);
}
while
(
0
);
free
(
request
);
CheckServerParamValue
(
name
,
value
);
RegisterSecurityOps
(
paramSecurityOps
,
1
);
return
0
;
}
...
...
@@ -630,7 +637,7 @@ HWTEST_F(ParamUnitTest, TestServiceCtrl, TestSize.Level0)
{
ParamUnitTest
test
;
int
ret
=
test
.
TestServiceCtrl
(
"server1"
,
0770
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
ret
=
test
.
TestServiceCtrl
(
"server2"
,
0772
);
EXPECT_EQ
(
ret
,
0
);
}
...
...
@@ -639,19 +646,19 @@ HWTEST_F(ParamUnitTest, TestPowerCtrl, TestSize.Level0)
{
ParamUnitTest
test
;
int
ret
=
test
.
TestPowerCtrl
(
"reboot,shutdown"
,
0770
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
ret
=
test
.
TestPowerCtrl
(
"reboot,shutdown"
,
0772
);
EXPECT_EQ
(
ret
,
0
);
ret
=
test
.
TestPowerCtrl
(
"reboot,updater"
,
0770
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
ret
=
test
.
TestPowerCtrl
(
"reboot,updater"
,
0772
);
EXPECT_EQ
(
ret
,
0
);
ret
=
test
.
TestPowerCtrl
(
"reboot,flash"
,
0770
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
ret
=
test
.
TestPowerCtrl
(
"reboot,flash"
,
0772
);
EXPECT_EQ
(
ret
,
0
);
ret
=
test
.
TestPowerCtrl
(
"reboot"
,
0770
);
EXPECT_
NE
(
ret
,
0
);
EXPECT_
EQ
(
ret
,
0
);
ret
=
test
.
TestPowerCtrl
(
"reboot"
,
0772
);
EXPECT_EQ
(
ret
,
0
);
}
\ No newline at end of file
test/unittest/tools/prepare_testdata.sh
浏览文件 @
122ad013
...
...
@@ -111,7 +111,7 @@ hdc_push_cmd ${ohos_root}/base/startup/init_lite/test/unittest/test_data/trigger
sleep
0.2
hdc_push_cmd
${
ohos_root
}
/base/startup/init_lite/test/unittest/test_data/proc/cmdline /data/init_ut/proc/cmdline
sleep
0.25
hdc file send
${
ohos_root
}
/out/
ohos-arm-release/exe.unstripped
/tests/unittest/startup/init/init_ut /data/init_ut/init_ut
hdc file send
${
ohos_root
}
/out/
rk3568
/tests/unittest/startup/init/init_ut /data/init_ut/init_ut
sleep
0.25
hdc_shell_cmd
"cp /data/init_ut/init_ut /bin/init_ut"
...
...
@@ -119,7 +119,7 @@ hdc_shell_cmd "chmod 777 /data/init_ut/* -R"
sleep
0.2
hdc_shell_cmd
"chmod 777 /bin/init_ut"
hdc_shell_cmd
"export GCOV_PREFIX=
${
ut_target_path
}
/coverage&&export GCOV_PREFIX_STRIP=
20
&&init_ut"
hdc_shell_cmd
"export GCOV_PREFIX=
${
ut_target_path
}
/coverage&&export GCOV_PREFIX_STRIP=
15
&&init_ut"
sleep
0.2
if
[
$?
-ne
0
]
;
then
...
...
@@ -140,7 +140,7 @@ done
echo
"Find out all gcno files and copy to
${
ohos_init
}
"
find
${
ohos_root
}
/out/
ohos-arm-release/obj
/
-name
"*.gcno"
-type
f
-exec
cp
{}
.
\;
find
${
ohos_root
}
/out/
rk3568/obj/base/startup
/
-name
"*.gcno"
-type
f
-exec
cp
{}
.
\;
if
[
$?
-ne
0
]
;
then
echo
"find gcno failed."
popd
2>&1
>
/dev/null
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录