Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
cdf6f6d1
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cdf6f6d1
编写于
12月 01, 2021
作者:
X
xionglei6
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init ut
Signed-off-by:
N
xionglei6
<
xionglei6@huawei.com
>
上级
235e009d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
1 addition
and
92 deletion
+1
-92
test/unittest/BUILD.gn
test/unittest/BUILD.gn
+0
-1
test/unittest/init/cmds_unittest.cpp
test/unittest/init/cmds_unittest.cpp
+1
-29
test/unittest/param/dac_unittest.cpp
test/unittest/param/dac_unittest.cpp
+0
-21
test/unittest/param/param_unittest.cpp
test/unittest/param/param_unittest.cpp
+0
-20
test/unittest/param/selinux_unittest.cpp
test/unittest/param/selinux_unittest.cpp
+0
-21
未找到文件。
test/unittest/BUILD.gn
浏览文件 @
cdf6f6d1
...
@@ -95,7 +95,6 @@ ohos_unittest("init_ut") {
...
@@ -95,7 +95,6 @@ ohos_unittest("init_ut") {
"init/service_socket_unittest.cpp",
"init/service_socket_unittest.cpp",
"init/service_unittest.cpp",
"init/service_unittest.cpp",
"init/utils_unittest.cpp",
"init/utils_unittest.cpp",
"innerkits/innerkits_unittest.cpp",
"param/client_unittest.cpp",
"param/client_unittest.cpp",
"param/dac_unittest.cpp",
"param/dac_unittest.cpp",
"param/param_unittest.cpp",
"param/param_unittest.cpp",
...
...
test/unittest/init/cmds_unittest.cpp
浏览文件 @
cdf6f6d1
...
@@ -30,41 +30,13 @@ public:
...
@@ -30,41 +30,13 @@ public:
static
void
SetUpTestCase
(
void
)
static
void
SetUpTestCase
(
void
)
{
{
InitParamService
();
InitParamService
();
mkdir
(
"/data/init_ut"
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
};
};
static
void
TearDownTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
()
{};
void
SetUp
()
{};
void
TearDown
()
{};
void
TearDown
()
{};
};
};
HWTEST_F
(
CmdsUnitTest
,
TestGetValueForCmd
,
TestSize
.
Level1
)
{
// 1, test one param
SystemWriteParam
(
"ro.test.1111.2222"
,
"2.3.4.5.6.7.8"
);
char
*
tmpParamValue
=
(
char
*
)
malloc
(
PARAM_VALUE_LEN_MAX
+
1
);
if
(
tmpParamValue
==
nullptr
)
{
EXPECT_EQ
(
1
,
0
);
return
;
}
tmpParamValue
[
0
]
=
'\0'
;
const
char
*
cmd1
=
"init.${ro.test.1111.2222}.usb.cfg"
;
GetParamValue
(
cmd1
,
strlen
(
cmd1
),
tmpParamValue
,
PARAM_VALUE_LEN_MAX
);
printf
(
"Tmp value %s
\n
"
,
tmpParamValue
);
EXPECT_EQ
(
strcmp
(
"init.2.3.4.5.6.7.8.usb.cfg"
,
tmpParamValue
),
0
);
// 2, test two param
const
char
*
cmd2
=
"init.${ro.test.1111.2222}.usb.${ro.test.1111.2222}"
;
GetParamValue
(
cmd2
,
strlen
(
cmd2
),
tmpParamValue
,
PARAM_VALUE_LEN_MAX
);
printf
(
"Tmp value %s
\n
"
,
tmpParamValue
);
EXPECT_EQ
(
strcmp
(
"init.2.3.4.5.6.7.8.usb.2.3.4.5.6.7.8"
,
tmpParamValue
),
0
);
// 3, test two param
const
char
*
cmd3
=
"${ro.test.1111.2222}.init.${ro.test.1111.2222}.usb.${ro.test.1111.2222}"
;
GetParamValue
(
cmd3
,
strlen
(
cmd3
),
tmpParamValue
,
PARAM_VALUE_LEN_MAX
);
printf
(
"Tmp value %s
\n
"
,
tmpParamValue
);
EXPECT_EQ
(
strcmp
(
"2.3.4.5.6.7.8.init.2.3.4.5.6.7.8.usb.2.3.4.5.6.7.8"
,
tmpParamValue
),
0
);
free
(
tmpParamValue
);
}
HWTEST_F
(
CmdsUnitTest
,
TestCmdExecByName
,
TestSize
.
Level1
)
HWTEST_F
(
CmdsUnitTest
,
TestCmdExecByName
,
TestSize
.
Level1
)
{
{
SetInitLogLevel
(
INIT_INFO
);
SetInitLogLevel
(
INIT_INFO
);
...
...
test/unittest/param/dac_unittest.cpp
浏览文件 @
cdf6f6d1
...
@@ -43,21 +43,6 @@ public:
...
@@ -43,21 +43,6 @@ public:
void
TearDown
()
{}
void
TearDown
()
{}
void
TestBody
()
{}
void
TestBody
()
{}
int
TestDacGetLabel
()
{
int
ret
=
RegisterSecurityDacOps
(
&
initParamSercurityOps
,
LABEL_INIT_FOR_INIT
);
EXPECT_EQ
(
ret
,
0
);
if
(
initParamSercurityOps
.
securityGetLabel
==
nullptr
)
{
EXPECT_EQ
(
1
,
0
);
return
-
1
;
}
ret
=
initParamSercurityOps
.
securityGetLabel
(
SecurityLabelGet
,
PARAM_DEFAULT_PATH
"/system/etc/param"
,
nullptr
);
EXPECT_EQ
(
ret
,
0
);
return
0
;
}
int
TestDacInitLocalLabel
()
int
TestDacInitLocalLabel
()
{
{
int
ret
=
RegisterSecurityDacOps
(
&
initParamSercurityOps
,
LABEL_INIT_FOR_INIT
);
int
ret
=
RegisterSecurityDacOps
(
&
initParamSercurityOps
,
LABEL_INIT_FOR_INIT
);
...
@@ -185,12 +170,6 @@ private:
...
@@ -185,12 +170,6 @@ private:
ParamSecurityOps
clientParamSercurityOps
{};
ParamSecurityOps
clientParamSercurityOps
{};
};
};
HWTEST_F
(
DacUnitTest
,
TestDacGetLabel
,
TestSize
.
Level0
)
{
DacUnitTest
test
;
test
.
TestDacGetLabel
();
}
HWTEST_F
(
DacUnitTest
,
TestDacInitLocalLabel
,
TestSize
.
Level0
)
HWTEST_F
(
DacUnitTest
,
TestDacInitLocalLabel
,
TestSize
.
Level0
)
{
{
DacUnitTest
test
;
DacUnitTest
test
;
...
...
test/unittest/param/param_unittest.cpp
浏览文件 @
cdf6f6d1
...
@@ -48,20 +48,6 @@ public:
...
@@ -48,20 +48,6 @@ public:
void
TearDown
()
{}
void
TearDown
()
{}
void
TestBody
()
{}
void
TestBody
()
{}
int
TestParamServiceInit
()
{
InitParamService
();
// parse parameters
LoadDefaultParams
(
PARAM_DEFAULT_PATH
"/system/etc/param/ohos_const"
,
LOAD_PARAM_NORMAL
);
LoadDefaultParams
(
PARAM_DEFAULT_PATH
"/vendor/etc/param"
,
LOAD_PARAM_NORMAL
);
LoadDefaultParams
(
PARAM_DEFAULT_PATH
"/system/etc/param"
,
LOAD_PARAM_ONLY_ADD
);
CheckServerParamValue
(
"const.actionable_compatible_property.enabled"
,
"false"
);
CheckServerParamValue
(
"build_version"
,
"2.0"
);
CheckServerParamValue
(
"ohos.boot.hardware"
,
"Hi3516DV300"
);
LoadPersistParams
();
return
0
;
}
int
TestSetParams
(
const
char
*
params
[][
1
+
1
],
int
num
)
int
TestSetParams
(
const
char
*
params
[][
1
+
1
],
int
num
)
{
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num
;
i
++
)
{
...
@@ -485,12 +471,6 @@ public:
...
@@ -485,12 +471,6 @@ public:
}
}
};
};
HWTEST_F
(
ParamUnitTest
,
TestParamServiceInit
,
TestSize
.
Level0
)
{
ParamUnitTest
test
;
test
.
TestParamServiceInit
();
}
HWTEST_F
(
ParamUnitTest
,
TestPersistParam
,
TestSize
.
Level0
)
HWTEST_F
(
ParamUnitTest
,
TestPersistParam
,
TestSize
.
Level0
)
{
{
ParamUnitTest
test
;
ParamUnitTest
test
;
...
...
test/unittest/param/selinux_unittest.cpp
浏览文件 @
cdf6f6d1
...
@@ -44,21 +44,6 @@ public:
...
@@ -44,21 +44,6 @@ public:
void
TearDown
()
{}
void
TearDown
()
{}
void
TestBody
()
{}
void
TestBody
()
{}
int
TestSelinuxGetLabel
()
{
int
ret
=
RegisterSecuritySelinuxOps
(
&
initParamSercurityOps
,
LABEL_INIT_FOR_INIT
);
EXPECT_EQ
(
ret
,
0
);
if
(
initParamSercurityOps
.
securityGetLabel
==
nullptr
)
{
EXPECT_EQ
(
1
,
0
);
return
-
1
;
}
ret
=
initParamSercurityOps
.
securityGetLabel
(
SecurityLabelGet
,
PARAM_DEFAULT_PATH
"/system/etc/param"
,
nullptr
);
EXPECT_EQ
(
ret
,
0
);
return
0
;
}
int
TestSelinuxInitLocalLabel
()
int
TestSelinuxInitLocalLabel
()
{
{
int
ret
=
RegisterSecuritySelinuxOps
(
&
initParamSercurityOps
,
LABEL_INIT_FOR_INIT
);
int
ret
=
RegisterSecuritySelinuxOps
(
&
initParamSercurityOps
,
LABEL_INIT_FOR_INIT
);
...
@@ -240,12 +225,6 @@ private:
...
@@ -240,12 +225,6 @@ private:
ParamSecurityOps
clientParamSercurityOps
{};
ParamSecurityOps
clientParamSercurityOps
{};
};
};
HWTEST_F
(
SelinuxUnitTest
,
TestSelinuxGetLabel
,
TestSize
.
Level0
)
{
SelinuxUnitTest
test
;
test
.
TestSelinuxGetLabel
();
}
HWTEST_F
(
SelinuxUnitTest
,
TestSelinuxInitLocalLabel
,
TestSize
.
Level0
)
HWTEST_F
(
SelinuxUnitTest
,
TestSelinuxInitLocalLabel
,
TestSize
.
Level0
)
{
{
SelinuxUnitTest
test
;
SelinuxUnitTest
test
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录