Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
b747afbf
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
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看板
未验证
提交
b747afbf
编写于
2月 09, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 09, 2023
浏览文件
操作
浏览文件
下载
差异文件
!1753 解决覆盖率版本ut退出时崩溃
Merge pull request !1753 from 熊磊/master_cc_fix_ut
上级
b7d80364
b70ec053
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
17 addition
and
157 deletion
+17
-157
test/unittest/BUILD.gn
test/unittest/BUILD.gn
+0
-1
test/unittest/init/cmds_unittest.cpp
test/unittest/init/cmds_unittest.cpp
+0
-38
test/unittest/init/group_unittest.cpp
test/unittest/init/group_unittest.cpp
+1
-1
test/unittest/init/service_unittest.cpp
test/unittest/init/service_unittest.cpp
+3
-8
test/unittest/innerkits/innerkits_unittest.cpp
test/unittest/innerkits/innerkits_unittest.cpp
+6
-4
test/unittest/innerkits/modulemgr_unittest.cpp
test/unittest/innerkits/modulemgr_unittest.cpp
+0
-84
test/unittest/loopevent/loopevent_unittest.cpp
test/unittest/loopevent/loopevent_unittest.cpp
+0
-14
test/unittest/modules/modules_unittest.cpp
test/unittest/modules/modules_unittest.cpp
+5
-5
test/unittest/param/param_shell_unittest.cpp
test/unittest/param/param_shell_unittest.cpp
+1
-1
test/unittest/param/trigger_unittest.cpp
test/unittest/param/trigger_unittest.cpp
+1
-1
未找到文件。
test/unittest/BUILD.gn
浏览文件 @
b747afbf
...
...
@@ -177,7 +177,6 @@ ohos_unittest("init_unittest") {
"init/utils_unittest.cpp",
"innerkits/innerkits_unittest.cpp",
"loopevent/loopevent_unittest.cpp",
"loopevent/loopserver_unittest.cpp",
"loopevent/loopsignal_unittest.cpp",
"modules/modules_unittest.cpp",
"param/client_unittest.cpp",
...
...
test/unittest/init/cmds_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -36,44 +36,6 @@ public:
void
TearDown
()
{};
};
HWTEST_F
(
CmdsUnitTest
,
TestCmdExecByName
,
TestSize
.
Level1
)
{
DoCmdByName
(
"load_param "
,
" /system/etc/param onlyadd"
);
DoCmdByName
(
"symlink "
,
"/proc/self/fd/0 /dev/stdin"
);
DoCmdByName
(
"symlink "
,
"/notfile "
);
DoCmdByName
(
"insmod "
,
"libdemo.z.so anony=1 mmz_allocator=hisi mmz=anonymous,0,0xA8000000,384M || report_error"
);
DoCmdByName
(
"insmod "
,
"/vendor/modules/hi_irq.ko"
);
DoCmdByName
(
"insmod "
,
STARTUP_INIT_UT_PATH
"/test_insmod"
);
DoCmdByName
(
"setparam "
,
"sys.usb.config ${persist.sys.usb.config}"
);
DoCmdByName
(
"load_persist_params "
,
""
);
DoCmdByName
(
"trigger "
,
""
);
DoCmdByName
(
"domainname "
,
"localdomain"
);
DoCmdByName
(
"hostname "
,
"localhost"
);
DoCmdByName
(
"sleep "
,
"1"
);
DoCmdByName
(
"setrlimit "
,
"RLIMIT_NICE 40 40"
);
DoCmdByName
(
"setrlimit "
,
"RLIMIT_NICE unlimited unlimited"
);
DoCmdByName
(
"setrlimit "
,
"RLIMIT_NICE2 40 40"
);
DoCmdByName
(
"start "
,
"init_ut"
);
DoCmdByName
(
"stop "
,
"init_ut"
);
DoCmdByName
(
"reset "
,
"init_ut"
);
DoCmdByName
(
"reboot "
,
""
);
DoCmdByName
(
"ifup "
,
"lo"
);
DoCmdByName
(
"mknode "
,
"/dev/null b 0666 1 3"
);
DoCmdByName
(
"mknode "
,
"/dev/null C 0666 1 3"
);
DoCmdByName
(
"mknode "
,
"/dev/null F 0666 1 3"
);
DoCmdByName
(
"mknode "
,
"/dev/null A 0666 1 3"
);
DoCmdByName
(
"makedev "
,
"999 999"
);
DoCmdByName
(
"mount_fstab "
,
"/wwwwwww"
);
DoCmdByName
(
"umount_fstab "
,
"/wwwwwww"
);
DoCmdByName
(
"mksandbox "
,
"system chipset"
);
DoCmdByName
(
"mksandbox "
,
"system"
);
DoCmdByName
(
"mksandbox "
,
"notsupport"
);
DoCmdByName
(
"mksandbox "
,
""
);
DoCmdByName
(
"mksandbox "
,
nullptr
);
}
HWTEST_F
(
CmdsUnitTest
,
TestCmdExecByName1
,
TestSize
.
Level1
)
{
DoCmdByName
(
"timer_start "
,
"media_service|5000"
);
...
...
test/unittest/init/group_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -343,7 +343,7 @@ HWTEST_F(InitGroupManagerUnitTest, TestUpdaterServiceFds, TestSize.Level1)
{
Service
*
service
=
AddService
(
"test_service8"
);
ASSERT_NE
(
nullptr
,
service
);
int
*
fds
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
1
)
;
// ServiceStop will release fds
int
fds
[
1
]
=
{
-
1
}
;
// ServiceStop will release fds
UpdaterServiceFds
(
nullptr
,
nullptr
,
0
);
UpdaterServiceFds
(
service
,
fds
,
1
);
UpdaterServiceFds
(
service
,
fds
,
0
);
...
...
test/unittest/init/service_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -87,8 +87,7 @@ HWTEST_F(ServiceUnitTest, case02, TestSize.Level1)
int
ret
=
ParseOneService
(
serviceItem
,
service
);
EXPECT_EQ
(
ret
,
0
);
int
*
fds
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
1
);
// ServiceStop will release fds
ASSERT_NE
(
nullptr
,
fds
);
int
fds
[
1
]
=
{
-
1
};
// ServiceStop will release fds
UpdaterServiceFds
(
service
,
fds
,
1
);
service
->
attribute
=
SERVICE_ATTR_ONDEMAND
;
ret
=
ServiceStart
(
service
);
...
...
@@ -130,16 +129,12 @@ HWTEST_F(ServiceUnitTest, TestServiceStartAbnormal, TestSize.Level1)
int
ret
=
ParseOneService
(
serviceItem
,
service
);
EXPECT_EQ
(
ret
,
0
);
const
char
*
path
=
"/data/init_ut/test_service_unused"
;
ret
=
strncpy_s
(
service
->
pathArgs
.
argv
[
0
],
strlen
(
path
)
+
1
,
path
,
strlen
(
path
));
EXPECT_EQ
(
ret
,
0
);
ret
=
ServiceStart
(
service
);
EXPECT_EQ
(
ret
,
-
1
);
EXPECT_EQ
(
ret
,
0
);
service
->
attribute
&=
SERVICE_ATTR_INVALID
;
ret
=
ServiceStart
(
service
);
EXPECT_EQ
(
ret
,
-
1
);
EXPECT_EQ
(
ret
,
0
);
service
->
pid
=
-
1
;
ret
=
ServiceStop
(
service
);
...
...
test/unittest/innerkits/innerkits_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -246,7 +246,7 @@ HWTEST_F(InnerkitsUnitTest, MountAllWithFstabFile_unittest, TestSize.Level1)
EXPECT_EQ
(
MountAllWithFstabFile
(
"/testErrorFile"
,
0
),
-
1
);
EXPECT_EQ
(
MountAllWithFstabFile
(
nullptr
,
0
),
-
1
);
EXPECT_EQ
(
GetMountStatusForMountPoint
(
nullptr
),
-
1
);
FstabItem
fstabItem
;
FstabItem
fstabItem
=
{}
;
fstabItem
.
fsType
=
strdup
(
"notSupport"
);
EXPECT_EQ
(
MountOneItem
(
nullptr
),
-
1
);
EXPECT_EQ
(
MountOneItem
(
&
fstabItem
),
0
);
...
...
@@ -349,7 +349,9 @@ HWTEST_F(InnerkitsUnitTest, TestControlFd, TestSize.Level1)
ProcessPtyWrite
(
nullptr
,
STDERR_FILENO
,
&
events
,
nullptr
);
close
(
fd
);
CmdOnClose
(
agent
->
task
);
if
(
agent
)
{
CmdOnClose
(
agent
->
task
);
}
}
HWTEST_F
(
InnerkitsUnitTest
,
TestControlFdServer
,
TestSize
.
Level1
)
...
...
@@ -361,7 +363,7 @@ HWTEST_F(InnerkitsUnitTest, TestControlFdServer, TestSize.Level1)
UNUSED
(
context
);
},
LE_GetDefaultLoop
());
TaskHandle
testServer
;
TaskHandle
testServer
=
NULL
;
LE_StreamServerInfo
info
=
{};
info
.
baseInfo
.
flags
=
TASK_STREAM
|
TASK_SERVER
|
TASK_PIPE
|
TASK_TEST
;
info
.
server
=
(
char
*
)
"/data/testSock1"
;
...
...
@@ -432,7 +434,7 @@ HWTEST_F(InnerkitsUnitTest, TestHoldFd2, TestSize.Level1)
int
*
fds
=
nullptr
;
char
buffer
[
MAX_FD_HOLDER_BUFFER
+
1
]
=
{};
pid_t
requestPid
=
-
1
;
struct
msghdr
msghdr
;
struct
msghdr
msghdr
=
{}
;
GetFdsFromMsg
(
&
fdCount
,
&
requestPid
,
msghdr
);
msghdr
.
msg_flags
=
MSG_TRUNC
;
GetFdsFromMsg
(
&
fdCount
,
&
requestPid
,
msghdr
);
...
...
test/unittest/innerkits/modulemgr_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -83,63 +83,6 @@ HWTEST_F(ModuleMgrUnitTest, PluginAddCmd, TestSize.Level1)
RemoveCmdExecutor
(
"testCmd4"
,
cmdExecId4
);
}
HWTEST_F
(
ModuleMgrUnitTest
,
ModuleInstallTest
,
TestSize
.
Level1
)
{
int
ret
;
int
cnt
;
// Create module manager
ASSERT_EQ
(
ModuleMgrCreate
(
nullptr
),
nullptr
);
ModuleMgrDestroy
(
nullptr
);
MODULE_MGR
*
moduleMgr
=
ModuleMgrCreate
(
"init"
);
ASSERT_NE
(
moduleMgr
,
nullptr
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
// Install one module
#ifdef SUPPORT_64BIT
ret
=
ModuleMgrInstall
(
moduleMgr
,
"/system/lib64/init/libbootchart"
,
0
,
NULL
);
#else
ret
=
ModuleMgrInstall
(
moduleMgr
,
"/system/lib/init/libbootchart"
,
0
,
NULL
);
#endif
ASSERT_EQ
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
// Uninstall the module
ModuleMgrUninstall
(
moduleMgr
,
"bootchart"
);
InitModuleMgrUnInstall
(
"bootchart"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
// Install two module
ret
=
ModuleMgrInstall
(
moduleMgr
,
"bootchart"
,
0
,
NULL
);
ASSERT_EQ
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
ret
=
ModuleMgrInstall
(
moduleMgr
,
"notexist"
,
0
,
NULL
);
ASSERT_NE
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
// Uninstall the module
ModuleMgrUninstall
(
moduleMgr
,
"bootchart"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrUninstall
(
moduleMgr
,
"notexist"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrDestroy
(
moduleMgr
);
// test updater mode
int
fd
=
open
(
"/bin/updater"
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_CLOEXEC
,
S_IRWXU
);
ASSERT_NE
(
fd
,
0
);
ModuleMgrScan
(
"init/autorun"
);
unlink
(
"/bin/updater"
);
close
(
fd
);
}
static
void
TestModuleDump
(
const
MODULE_INFO
*
moduleInfo
)
{
printf
(
"%s
\n
"
,
moduleInfo
->
name
);
...
...
@@ -176,31 +119,4 @@ HWTEST_F(ModuleMgrUnitTest, ModuleTraversalTest, TestSize.Level1)
ModuleMgrGetArgs
();
ModuleMgrDestroy
(
moduleMgr
);
}
HWTEST_F
(
ModuleMgrUnitTest
,
ModuleScanTest
,
TestSize
.
Level1
)
{
// Scan all modules test init
MODULE_MGR
*
moduleMgr
=
ModuleMgrScan
(
"init"
);
ASSERT_NE
(
moduleMgr
,
nullptr
);
int
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_GE
(
cnt
,
1
);
ModuleMgrUninstall
(
nullptr
,
nullptr
);
ModuleMgrUninstall
(
moduleMgr
,
NULL
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrDestroy
(
moduleMgr
);
// scan /lib/init/
#ifdef SUPPORT_64BIT
moduleMgr
=
ModuleMgrScan
(
"/lib64/init"
);
#else
moduleMgr
=
ModuleMgrScan
(
"/lib/init"
);
#endif
ASSERT_NE
(
moduleMgr
,
nullptr
);
ModuleMgrGetCnt
(
nullptr
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ModuleMgrDestroy
(
moduleMgr
);
EXPECT_EQ
(
InitModuleMgrInstall
(
nullptr
),
-
1
);
}
}
// namespace init_ut
test/unittest/loopevent/loopevent_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -244,20 +244,6 @@ private:
ParamTaskPtr
serverTask_
=
NULL
;
};
HWTEST_F
(
LoopEventUnittest
,
StreamTaskTest
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
loopevtest
.
CreateServerTask
();
loopevtest
.
StreamTaskTest
();
LE_StreamInfo
streamInfo
=
{};
streamInfo
.
recvMessage
=
OnReceiveRequest
;
streamInfo
.
baseInfo
.
flags
=
TASK_PIPE
|
TASK_CONNECT
;
streamInfo
.
server
=
(
char
*
)
PIPE_NAME
;
TaskHandle
clientTaskHandlec
=
nullptr
;
LE_CreateStreamClient
(
LE_GetDefaultLoop
(),
&
clientTaskHandlec
,
&
streamInfo
);
EXPECT_NE
(
clientTaskHandlec
,
nullptr
);
}
HWTEST_F
(
LoopEventUnittest
,
LeTaskTest
,
TestSize
.
Level1
)
{
LoopEventUnittest
loopevtest
=
LoopEventUnittest
();
...
...
test/unittest/modules/modules_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -67,8 +67,8 @@ HWTEST_F(ModulesUnitTest, TestBootchartLogFile, TestSize.Level1)
{
DoBootchartStart
();
FILE
*
log
=
fopen
(
"/data/init_ut/ModulesTest.log"
,
"w"
);
BootchartLogFile
(
log
,
"/proc/stat"
);
if
(
log
!=
NULL
)
{
if
(
log
)
{
BootchartLogFile
(
log
,
"/proc/stat"
);
(
void
)
fflush
(
log
);
(
void
)
fclose
(
log
);
}
...
...
@@ -78,8 +78,8 @@ HWTEST_F(ModulesUnitTest, TestBootchartLogProcessStat, TestSize.Level1)
{
FILE
*
log
=
fopen
(
"/data/init_ut/ModulesTest.log"
,
"w"
);
pid_t
selfPid
=
getpid
();
BootchartLogProcessStat
(
log
,
selfPid
);
if
(
log
!=
NULL
)
{
BootchartLogProcessStat
(
log
,
selfPid
);
(
void
)
fflush
(
log
);
(
void
)
fclose
(
log
);
}
...
...
@@ -88,8 +88,8 @@ HWTEST_F(ModulesUnitTest, TestBootchartLogProcessStat, TestSize.Level1)
HWTEST_F
(
ModulesUnitTest
,
TestbootchartLogProcess
,
TestSize
.
Level1
)
{
FILE
*
log
=
fopen
(
"/data/init_ut/ModulesTest.log"
,
"w"
);
bootchartLogProcess
(
log
);
if
(
log
!=
NULL
)
{
if
(
log
)
{
bootchartLogProcess
(
log
);
(
void
)
fflush
(
log
);
(
void
)
fclose
(
log
);
}
...
...
test/unittest/param/param_shell_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -213,6 +213,6 @@ HWTEST_F(ParamShellUnitTest, TestParamShellcmd2, TestSize.Level1)
BShellEnvLoop
(
nullptr
);
BShellEnvErrString
(
GetShellHandle
(),
1
);
BShellEnvOutputResult
(
GetShellHandle
(),
1
);
demoExit
();
}
}
// namespace init_ut
test/unittest/param/trigger_unittest.cpp
浏览文件 @
b747afbf
...
...
@@ -601,5 +601,5 @@ HWTEST_F(TriggerUnitTest, TestExecuteParamTrigger6, TestSize.Level0)
{
TriggerUnitTest
test
;
test
.
TestDumpTrigger
();
CloseTriggerWorkSpace
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录