Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
5b377482
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,发现更多精彩内容 >>
提交
5b377482
编写于
10月 11, 2022
作者:
C
cheng_jinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改memset_s返回值判断
Signed-off-by:
N
cheng_jinsong
<
chengjinsong2@huawei.com
>
上级
dbc36d86
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
13 deletion
+15
-13
test/unittest/lite/cmd_func_test.cpp
test/unittest/lite/cmd_func_test.cpp
+15
-13
未找到文件。
test/unittest/lite/cmd_func_test.cpp
浏览文件 @
5b377482
...
...
@@ -124,7 +124,7 @@ public:
}
void
SetUp
()
{
EnableInitLog
(
INIT_FATAL
);
EnableInitLog
();
}
void
TearDown
()
{}
};
...
...
@@ -180,7 +180,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_001, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncParseCmdTest_002
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
ParseCmdLine
(
nullptr
,
&
curCmdLine
);
EXPECT_EQ
(
0
,
strlen
(
curCmdLine
.
name
));
...
...
@@ -207,7 +207,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_002, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncParseCmdTest_003
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
for
(
size_t
i
=
0
;
i
<
g_supportedCmds
.
size
();
++
i
)
{
ParseCmdLine
(
g_supportedCmds
[
i
].
c_str
(),
&
curCmdLine
);
...
...
@@ -224,10 +224,12 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_003, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncParseCmdTest_004
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
char
toLongContent
[
MAX_CMD_CONTENT_LEN
+
10
];
memset_s
(
toLongContent
,
MAX_CMD_CONTENT_LEN
+
10
,
'x'
,
MAX_CMD_CONTENT_LEN
+
9
);
int
ret
=
memset_s
(
toLongContent
,
MAX_CMD_CONTENT_LEN
+
10
,
'x'
,
MAX_CMD_CONTENT_LEN
+
9
);
EXPECT_EQ
(
0
,
ret
);
toLongContent
[
MAX_CMD_CONTENT_LEN
+
9
]
=
'\0'
;
for
(
size_t
i
=
0
;
i
<
g_supportedCmds
.
size
();
++
i
)
{
size_t
curCmdLen
=
g_supportedCmds
[
i
].
length
();
...
...
@@ -262,7 +264,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_004, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncParseCmdTest_005
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
ParseCmdLine
(
"start InitTestService"
,
&
curCmdLine
);
EXPECT_EQ
(
0
,
strcmp
(
"start "
,
curCmdLine
.
name
));
...
...
@@ -304,7 +306,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_001, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncDoCmdTest_002
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
std
::
string
cmdStr
=
"start "
;
std
::
string
cmdContentStr
=
"NameNotExist"
;
...
...
@@ -323,7 +325,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_002, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncDoCmdTest_003
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
std
::
string
cmdStr
=
"mkdir "
;
std
::
string
cmdContentStr
=
"/DirNotExist/DirNotExist/DirNotExist"
;
...
...
@@ -368,7 +370,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_003, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncDoCmdTest_004
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
std
::
string
cmdStr
=
"chmod "
;
std
::
string
cmdContentStr
=
"755 "
+
TEST_FILE
;
// should be 0755, wrong format here
...
...
@@ -424,7 +426,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_004, TestSize.Level0)
HWTEST_F
(
StartupInitUTest
,
cmdFuncDoCmdTest_005
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
std
::
string
cmdStr
=
"chown "
;
std
::
string
cmdContentStr
=
"888 "
+
TEST_FILE
;
// uid or gid missing, wrong format here
...
...
@@ -829,7 +831,7 @@ static void CreateIllegalCfg()
HWTEST_F
(
StartupInitUTest
,
cmdFuncDoLoadCfgTest_001
,
TestSize
.
Level0
)
{
TestCmdLine
curCmdLine
;
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
ParseCmdLine
(
"loadcfg /patch/fstab.cfg"
,
&
curCmdLine
);
EXPECT_EQ
(
0
,
strcmp
(
"loadcfg "
,
curCmdLine
.
name
));
...
...
@@ -848,7 +850,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_002, TestSize.Level0)
std
::
string
cmdContentStr
=
"/patch/file_not_exist.cfg"
;
struct
stat
testCfgStat
=
{
0
};
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
std
::
string
command
=
cmdStr
+
cmdContentStr
;
ParseCmdLine
(
command
.
c_str
(),
&
curCmdLine
);
EXPECT_EQ
(
0
,
strcmp
(
cmdStr
.
c_str
(),
curCmdLine
.
name
));
...
...
@@ -859,7 +861,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_002, TestSize.Level0)
cmdContentStr
=
TEST_CFG_ILLEGAL
;
CreateIllegalCfg
();
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
(
void
)
memset_s
(
&
curCmdLine
,
sizeof
(
curCmdLine
),
0
,
sizeof
(
curCmdLine
));
command
=
cmdStr
+
cmdContentStr
;
ParseCmdLine
(
command
.
c_str
(),
&
curCmdLine
);
EXPECT_EQ
(
0
,
strcmp
(
cmdStr
.
c_str
(),
curCmdLine
.
name
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录