Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
9febfb7f
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
提交
9febfb7f
编写于
11月 29, 2021
作者:
X
xionglei6
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init: fix codedex
Signed-off-by:
N
xionglei6
<
xionglei6@huawei.com
>
上级
dcac61fa
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
8 deletion
+18
-8
test/unittest/init/cmds_unittest.cpp
test/unittest/init/cmds_unittest.cpp
+6
-7
test/unittest/init/mount_unittest.cpp
test/unittest/init/mount_unittest.cpp
+1
-0
test/unittest/init/service_file_unittest.cpp
test/unittest/init/service_file_unittest.cpp
+3
-0
test/unittest/init/service_socket_unittest.cpp
test/unittest/init/service_socket_unittest.cpp
+2
-1
test/unittest/init/service_unittest.cpp
test/unittest/init/service_unittest.cpp
+6
-0
未找到文件。
test/unittest/init/cmds_unittest.cpp
浏览文件 @
9febfb7f
...
...
@@ -144,8 +144,8 @@ HWTEST_F(CmdsUnitTest, TestCommonChmod, TestSize.Level1)
EXPECT_EQ
(
testMode
,
testMode
&
info
.
st_mode
);
DoCmdByName
(
"chmod "
,
"777 /data/init_ut/test_dir0/test_file001"
);
fd
=
-
1
;
close
(
fd
);
fd
=
-
1
;
}
HWTEST_F
(
CmdsUnitTest
,
TestCommonCopy
,
TestSize
.
Level1
)
...
...
@@ -160,9 +160,8 @@ HWTEST_F(CmdsUnitTest, TestCommonCopy, TestSize.Level1)
DoCmdByName
(
"copy "
,
"/data/init_ut/test_dir0/test_file_copy1 /data/init_ut/test_dir0/test_file_copy2"
);
int
ret
=
access
(
testFile2
,
F_OK
);
EXPECT_EQ
(
ret
,
0
);
fd
=
-
1
;
close
(
fd
);
fd
=
-
1
;
// abnormal
DoCmdByName
(
"copy "
,
"/data/init_ut/test_dir0/test_file_copy1 /data/init_ut/test_dir0/test_file_copy1"
);
DoCmdByName
(
"copy "
,
"/data/init_ut/test_dir0/test_file_copy11 /data/init_ut/test_dir0/test_file_copy1"
);
...
...
@@ -178,11 +177,10 @@ HWTEST_F(CmdsUnitTest, TestCommonWrite, TestSize.Level1)
DoCmdByName
(
"write "
,
"/data/init_ut/test_dir0/test_file_write1 aaa"
);
const
int
bufLen
=
50
;
char
buffer
[
bufLen
];
int
length
=
read
(
fd
,
buffer
,
bufLen
);
EXPECT_EQ
(
length
,
strlen
(
"aaa"
));
fd
=
-
1
;
int
length
=
read
(
fd
,
buffer
,
bufLen
-
1
);
EXPECT_EQ
(
length
,
strlen
(
"aaa"
));
close
(
fd
);
fd
=
-
1
;
// abnormal
DoCmdByName
(
"write "
,
"/data/init_ut/test_dir0/test_file_write2 aaa"
);
}
...
...
@@ -252,6 +250,7 @@ HWTEST_F(CmdsUnitTest, TestGetCmdLinesFromJson, TestSize.Level1)
cJSON
*
cmdsItem1
=
cJSON_GetArrayItem
(
cmdsItem
,
0
);
ASSERT_NE
(
nullptr
,
cmdsItem1
);
CmdLines
**
cmdLines
=
(
CmdLines
**
)
calloc
(
1
,
1
);
ASSERT_NE
(
nullptr
,
cmdLines
);
int
ret
=
GetCmdLinesFromJson
(
cmdsItem1
,
cmdLines
);
EXPECT_EQ
(
ret
,
-
1
);
cJSON
*
cmdsItem2
=
cJSON_GetObjectItem
(
cmdsItem1
,
"cmds"
);
...
...
test/unittest/init/mount_unittest.cpp
浏览文件 @
9febfb7f
...
...
@@ -38,6 +38,7 @@ HWTEST_F(MountUnitTest, TestMountRequriedPartitions, TestSize.Level0)
if
(
fstab
!=
NULL
)
{
int
ret
=
MountRequriedPartitions
(
fstab
);
EXPECT_EQ
(
ret
,
-
1
);
ReleaseFstab
(
fstab
)
;
}
}
}
// namespace init_ut
test/unittest/init/service_file_unittest.cpp
浏览文件 @
9febfb7f
...
...
@@ -39,6 +39,7 @@ HWTEST_F(ServiceFileUnitTest, TestServiceFile, TestSize.Level1)
{
const
char
*
fileName
=
"/data/filetest"
;
ServiceFile
*
fileOpt
=
(
ServiceFile
*
)
calloc
(
1
,
sizeof
(
ServiceFile
)
+
strlen
(
fileName
)
+
1
);
ASSERT_NE
(
fileOpt
,
nullptr
);
fileOpt
->
next
=
NULL
;
fileOpt
->
flags
=
O_RDWR
;
fileOpt
->
uid
=
1000
;
...
...
@@ -47,6 +48,7 @@ HWTEST_F(ServiceFileUnitTest, TestServiceFile, TestSize.Level1)
fileOpt
->
perm
=
0770
;
if
(
strncpy_s
(
fileOpt
->
fileName
,
strlen
(
fileName
)
+
1
,
fileName
,
strlen
(
fileName
))
!=
0
)
{
free
(
fileOpt
);
fileOpt
=
nullptr
;
ASSERT_TRUE
(
1
);
}
CreateServiceFile
(
fileOpt
);
...
...
@@ -54,5 +56,6 @@ HWTEST_F(ServiceFileUnitTest, TestServiceFile, TestSize.Level1)
EXPECT_NE
(
ret
,
-
1
);
CloseServiceFile
(
fileOpt
);
free
(
fileOpt
);
fileOpt
=
nullptr
;
}
}
test/unittest/init/service_socket_unittest.cpp
浏览文件 @
9febfb7f
...
...
@@ -32,11 +32,12 @@ public:
HWTEST_F
(
ServiceSocketUnitTest
,
TestCreateSocket
,
TestSize
.
Level0
)
{
ServiceSocket
*
sockopt
=
(
ServiceSocket
*
)
calloc
(
1
,
sizeof
(
ServiceSocket
));
ASSERT_NE
(
sockopt
,
nullptr
);
sockopt
->
type
=
SOCK_SEQPACKET
;
sockopt
->
sockFd
=
-
1
;
sockopt
->
uid
=
1000
;
sockopt
->
gid
=
1000
;
sockopt
->
perm
=
660
;
sockopt
->
perm
=
0
660
;
sockopt
->
passcred
=
true
;
const
char
*
testSocName
=
"test_socket"
;
errno_t
ret
=
strncpy_s
(
sockopt
->
name
,
strlen
(
testSocName
)
+
1
,
testSocName
,
strlen
(
testSocName
));
...
...
test/unittest/init/service_unittest.cpp
浏览文件 @
9febfb7f
...
...
@@ -79,6 +79,7 @@ HWTEST_F(ServiceUnitTest, TestServiceStartAbnormal, TestSize.Level1)
cJSON
*
serviceItem
=
cJSON_GetObjectItem
(
jobItem
,
"services"
);
ASSERT_NE
(
nullptr
,
serviceItem
);
Service
*
service
=
(
Service
*
)
calloc
(
1
,
sizeof
(
Service
));
ASSERT_NE
(
nullptr
,
service
);
int
ret
=
ParseOneService
(
serviceItem
,
service
);
EXPECT_EQ
(
ret
,
0
);
...
...
@@ -105,10 +106,12 @@ HWTEST_F(ServiceUnitTest, TestServiceStartAbnormal, TestSize.Level1)
HWTEST_F
(
ServiceUnitTest
,
TestServiceReap
,
TestSize
.
Level1
)
{
Service
*
service
=
(
Service
*
)
calloc
(
1
,
sizeof
(
Service
));
ASSERT_NE
(
nullptr
,
service
);
ServiceReap
(
service
);
EXPECT_EQ
(
service
->
attribute
,
0
);
service
->
restartArg
=
(
CmdLines
*
)
calloc
(
1
,
sizeof
(
CmdLines
));
ASSERT_NE
(
nullptr
,
service
->
restartArg
);
ServiceReap
(
service
);
EXPECT_EQ
(
service
->
attribute
,
0
);
...
...
@@ -142,6 +145,7 @@ HWTEST_F(ServiceUnitTest, TestServiceReapOther, TestSize.Level1)
ASSERT_NE
(
nullptr
,
serviceItem
);
Service
*
service
=
(
Service
*
)
calloc
(
1
,
sizeof
(
Service
));
ASSERT_NE
(
nullptr
,
service
);
int
ret
=
GetCmdLinesFromJson
(
cJSON_GetObjectItem
(
serviceItem
,
"onrestart"
),
&
service
->
restartArg
);
EXPECT_EQ
(
ret
,
0
);
ret
=
ParseOneService
(
serviceItem
,
service
);
...
...
@@ -207,7 +211,9 @@ HWTEST_F(ServiceUnitTest, TestServiceManagerGetService, TestSize.Level1)
HWTEST_F
(
ServiceUnitTest
,
TestServiceExec
,
TestSize
.
Level1
)
{
Service
*
service
=
(
Service
*
)
malloc
(
sizeof
(
Service
));
ASSERT_NE
(
service
,
nullptr
);
service
->
pathArgs
.
argv
=
(
char
**
)
malloc
(
sizeof
(
char
*
));
ASSERT_NE
(
service
->
pathArgs
.
argv
,
nullptr
);
service
->
pathArgs
.
count
=
1
;
const
char
*
path
=
"/data/init_ut/test_service_release"
;
service
->
pathArgs
.
argv
[
0
]
=
strdup
(
path
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录