Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
fcd918fd
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看板
未验证
提交
fcd918fd
编写于
6月 08, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 08, 2023
浏览文件
操作
浏览文件
下载
差异文件
!2026 fix codex
Merge pull request !2026 from cheng_jinsong/master_cc
上级
836ccc39
3a08fb96
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
51 deletion
+51
-51
interfaces/innerkits/include/service_watcher.h
interfaces/innerkits/include/service_watcher.h
+1
-1
interfaces/innerkits/reboot/init_reboot_innerkits.c
interfaces/innerkits/reboot/init_reboot_innerkits.c
+6
-6
services/modules/sysevent/startup_time_event.c
services/modules/sysevent/startup_time_event.c
+1
-1
services/param/manager/param_server.c
services/param/manager/param_server.c
+7
-7
test/unittest/modules/eng_unittest.cpp
test/unittest/modules/eng_unittest.cpp
+36
-36
未找到文件。
interfaces/innerkits/include/service_watcher.h
浏览文件 @
fcd918fd
...
...
@@ -28,7 +28,7 @@ extern "C" {
#define INVALID_PID 0
typedef
struct
serviceInfo_
{
typedef
struct
{
ServiceStatus
status
;
pid_t
pid
;
}
ServiceInfo
;
...
...
interfaces/innerkits/reboot/init_reboot_innerkits.c
浏览文件 @
fcd918fd
...
...
@@ -30,7 +30,7 @@
#define DOREBOOT_PARAM "reboot.ut"
#endif
static
int
DoReboot
_
(
const
char
*
mode
,
const
char
*
option
)
static
int
DoReboot
ByInitPlugin
(
const
char
*
mode
,
const
char
*
option
)
{
char
value
[
MAX_REBOOT_OPTION_SIZE
];
int
ret
=
0
;
...
...
@@ -56,7 +56,7 @@ static int DoReboot_(const char *mode, const char *option)
return
0
;
}
static
int
ExecReboot
_
(
const
char
*
mode
,
const
char
*
option
)
static
int
ExecReboot
(
const
char
*
mode
,
const
char
*
option
)
{
// check if param set ok
#ifndef STARTUP_INIT_TEST
...
...
@@ -65,7 +65,7 @@ static int ExecReboot_(const char *mode, const char *option)
const
int
maxCount
=
1
;
#endif
int
count
=
0
;
DoReboot
_
(
mode
,
option
);
DoReboot
ByInitPlugin
(
mode
,
option
);
while
(
count
<
maxCount
)
{
usleep
(
100
*
1000
);
// 100 * 1000 wait 100ms
char
result
[
10
]
=
{
0
};
// 10 stop len
...
...
@@ -76,7 +76,7 @@ static int ExecReboot_(const char *mode, const char *option)
return
0
;
}
count
++
;
DoReboot
_
(
mode
,
option
);
DoReboot
ByInitPlugin
(
mode
,
option
);
}
BEGET_LOGE
(
"Failed to reboot system"
);
return
0
;
...
...
@@ -84,10 +84,10 @@ static int ExecReboot_(const char *mode, const char *option)
int
DoReboot
(
const
char
*
option
)
{
return
ExecReboot
_
(
NULL
,
option
);
return
ExecReboot
(
NULL
,
option
);
}
int
DoRebootExt
(
const
char
*
mode
,
const
char
*
option
)
{
return
ExecReboot
_
(
mode
,
option
);
return
ExecReboot
(
mode
,
option
);
}
\ No newline at end of file
services/modules/sysevent/startup_time_event.c
浏览文件 @
fcd918fd
...
...
@@ -57,7 +57,7 @@ static int TraversalEvent(ListNode *node, void *root)
int
len
=
GetServiceName
(
item
->
paramName
,
args
->
buffer
+
args
->
currLen
,
args
->
bufferLen
-
args
->
currLen
);
PLUGIN_CHECK
(
len
>
0
&&
(((
uint32_t
)
len
+
args
->
currLen
)
<
args
->
bufferLen
),
return
-
1
,
"Failed to format service name %s"
,
item
->
paramName
);
args
->
currLen
+=
len
;
args
->
currLen
+=
(
uint32_t
)
len
;
len
=
sprintf_s
(
args
->
buffer
+
args
->
currLen
,
args
->
bufferLen
-
args
->
currLen
,
",%u:%u,%u:%u;"
,
(
uint32_t
)
item
->
timestamp
[
BOOTEVENT_FORK
].
tv_sec
,
...
...
services/param/manager/param_server.c
浏览文件 @
fcd918fd
...
...
@@ -110,7 +110,7 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
char
fullName
[
PARAM_NAME_LEN_MAX
];
cmdLineIteratorCtx
*
ctx
=
(
cmdLineIteratorCtx
*
)
context
;
char
*
data
=
(
char
*
)
ctx
->
cmdline
;
static
const
cmdLineInfo
cmdLines
[]
=
{
static
const
cmdLineInfo
CMDLINES
[]
=
{
{
"hardware"
,
CommonDealFun
},
{
"bootgroup"
,
CommonDealFun
},
{
"reboot_reason"
,
CommonDealFun
},
...
...
@@ -131,11 +131,11 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
}
// Matching reserved cmdlines
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
cmdLines
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
ARRAY_LENGTH
(
CMDLINES
);
i
++
)
{
// Check exact match
if
(
strcmp
(
name
,
cmdLines
[
i
].
name
)
!=
0
)
{
if
(
strcmp
(
name
,
CMDLINES
[
i
].
name
)
!=
0
)
{
// Check if contains ".xxx" for compatibility
ret
=
snprintf_s
(
fullName
,
sizeof
(
fullName
),
sizeof
(
fullName
)
-
1
,
".%s"
,
cmdLines
[
i
].
name
);
ret
=
snprintf_s
(
fullName
,
sizeof
(
fullName
),
sizeof
(
fullName
)
-
1
,
".%s"
,
CMDLINES
[
i
].
name
);
matched
=
strstr
(
name
,
fullName
);
if
(
matched
==
NULL
)
{
continue
;
...
...
@@ -146,13 +146,13 @@ static void CmdlineIterator(const NAME_VALUE_PAIR *nv, void *context)
}
}
ret
=
snprintf_s
(
fullName
,
sizeof
(
fullName
),
sizeof
(
fullName
)
-
1
,
OHOS_CMDLINE_PARA_PREFIX
"%s"
,
cmdLines
[
i
].
name
);
OHOS_CMDLINE_PARA_PREFIX
"%s"
,
CMDLINES
[
i
].
name
);
if
(
ret
<=
0
)
{
continue
;
}
PARAM_LOGV
(
"proc cmdline %s matched."
,
fullName
);
ret
=
cmdLines
[
i
].
processor
(
fullName
,
nv
->
value
);
if
((
ret
==
0
)
&&
(
SnDealFun
==
cmdLines
[
i
].
processor
))
{
ret
=
CMDLINES
[
i
].
processor
(
fullName
,
nv
->
value
);
if
((
ret
==
0
)
&&
(
SnDealFun
==
CMDLINES
[
i
].
processor
))
{
ctx
->
gotSn
=
true
;
}
return
;
...
...
test/unittest/modules/eng_unittest.cpp
浏览文件 @
fcd918fd
...
...
@@ -39,9 +39,9 @@ void BuildMountCmd(char *buffer, size_t len, const char *mp, const char *dev, co
bool
IsFileExistWithType
(
const
char
*
file
,
FileType
type
);
}
static
const
std
::
string
g_srcFilePath
=
STARTUP_INIT_UT_PATH
"/eng/source/test.txt"
;
static
const
std
::
string
g_targetPath
=
STARTUP_INIT_UT_PATH
"/eng/link_name"
;
static
const
std
::
string
g_engRootPath
=
STARTUP_INIT_UT_PATH
"/eng/"
;
static
const
std
::
string
SRC_FILE_PATH
=
STARTUP_INIT_UT_PATH
"/eng/source/test.txt"
;
static
const
std
::
string
TARGET_PATH
=
STARTUP_INIT_UT_PATH
"/eng/link_name"
;
static
const
std
::
string
ENG_ROOT_PATH
=
STARTUP_INIT_UT_PATH
"/eng/"
;
static
bool
RemoveDir
(
const
std
::
string
&
path
)
{
...
...
@@ -111,37 +111,37 @@ public:
HWTEST_F
(
EngUnitTest
,
TestFilesOverlay
,
TestSize
.
Level1
)
{
bool
isDel
=
false
;
bool
isExist
=
IsDirExist
(
g_engRootPath
.
c_str
());
bool
isExist
=
IsDirExist
(
ENG_ROOT_PATH
.
c_str
());
if
(
isExist
)
{
isDel
=
RemoveDir
(
g_engRootPath
.
c_str
());
isDel
=
RemoveDir
(
ENG_ROOT_PATH
.
c_str
());
EXPECT_EQ
(
isDel
,
true
);
}
isExist
=
IsDirExist
(
g_targetPath
.
c_str
());
isExist
=
IsDirExist
(
TARGET_PATH
.
c_str
());
if
(
isExist
)
{
isDel
=
RemoveDir
(
g_targetPath
.
c_str
());
isDel
=
RemoveDir
(
TARGET_PATH
.
c_str
());
EXPECT_EQ
(
isDel
,
true
);
}
DebugFilesOverlay
(
g_engRootPath
.
c_str
(),
g_targetPath
.
c_str
());
DebugFilesOverlay
(
ENG_ROOT_PATH
.
c_str
(),
TARGET_PATH
.
c_str
());
CreateTestFile
(
g_srcFilePath
.
c_str
(),
"test"
);
isExist
=
IsFileExist
(
g_srcFilePath
.
c_str
());
CreateTestFile
(
SRC_FILE_PATH
.
c_str
(),
"test"
);
isExist
=
IsFileExist
(
SRC_FILE_PATH
.
c_str
());
EXPECT_EQ
(
isExist
,
true
);
DebugFilesOverlay
(
g_srcFilePath
.
c_str
(),
g_targetPath
.
c_str
());
isExist
=
IsFileExistWithType
(
g_srcFilePath
.
c_str
(),
TYPE_REG
);
DebugFilesOverlay
(
SRC_FILE_PATH
.
c_str
(),
TARGET_PATH
.
c_str
());
isExist
=
IsFileExistWithType
(
SRC_FILE_PATH
.
c_str
(),
TYPE_REG
);
EXPECT_EQ
(
isExist
,
true
);
if
(
IsFileExistWithType
(
g_targetPath
.
c_str
(),
TYPE_LINK
))
{
if
(
unlink
(
g_targetPath
.
c_str
())
<
0
)
{
if
(
IsFileExistWithType
(
TARGET_PATH
.
c_str
(),
TYPE_LINK
))
{
if
(
unlink
(
TARGET_PATH
.
c_str
())
<
0
)
{
EXPECT_TRUE
(
false
);
}
}
int
ret
=
symlink
(
g_engRootPath
.
c_str
(),
g_targetPath
.
c_str
());
int
ret
=
symlink
(
ENG_ROOT_PATH
.
c_str
(),
TARGET_PATH
.
c_str
());
EXPECT_EQ
(
ret
,
0
);
isExist
=
IsFileExistWithType
(
g_targetPath
.
c_str
(),
TYPE_LINK
);
isExist
=
IsFileExistWithType
(
TARGET_PATH
.
c_str
(),
TYPE_LINK
);
EXPECT_EQ
(
isExist
,
true
);
DebugFilesOverlay
(
g_targetPath
.
c_str
(),
g_engRootPath
.
c_str
());
DebugFilesOverlay
(
TARGET_PATH
.
c_str
(),
ENG_ROOT_PATH
.
c_str
());
EXPECT_EQ
(
ret
,
0
);
}
...
...
@@ -153,38 +153,38 @@ HWTEST_F(EngUnitTest, TestBindMountFile, TestSize.Level1)
BindMountFile
(
"/data/init_ut"
,
"/"
);
bool
isExist
=
false
;
if
(
!
IsFileExist
(
g_srcFilePath
.
c_str
()))
{
CreateTestFile
(
g_srcFilePath
.
c_str
(),
"test reg file mount"
);
isExist
=
IsFileExist
(
g_srcFilePath
.
c_str
());
if
(
!
IsFileExist
(
SRC_FILE_PATH
.
c_str
()))
{
CreateTestFile
(
SRC_FILE_PATH
.
c_str
(),
"test reg file mount"
);
isExist
=
IsFileExist
(
SRC_FILE_PATH
.
c_str
());
EXPECT_EQ
(
isExist
,
true
);
BindMountFile
(
g_srcFilePath
.
c_str
(),
"/"
);
BindMountFile
(
SRC_FILE_PATH
.
c_str
(),
"/"
);
}
if
(
IsFileExist
(
g_srcFilePath
.
c_str
()))
{
if
(
IsFileExist
(
SRC_FILE_PATH
.
c_str
()))
{
RemoveDir
(
STARTUP_INIT_UT_PATH
"/eng/source"
);
isExist
=
IsFileExist
(
g_srcFilePath
.
c_str
());
isExist
=
IsFileExist
(
SRC_FILE_PATH
.
c_str
());
EXPECT_EQ
(
isExist
,
false
);
}
if
(
IsFileExistWithType
(
g_targetPath
.
c_str
(),
TYPE_LINK
))
{
if
(
unlink
(
g_targetPath
.
c_str
())
<
0
)
{
if
(
IsFileExistWithType
(
TARGET_PATH
.
c_str
(),
TYPE_LINK
))
{
if
(
unlink
(
TARGET_PATH
.
c_str
())
<
0
)
{
EXPECT_TRUE
(
false
);
}
}
bool
isLinkFile
=
IsFileExist
(
g_targetPath
.
c_str
());
bool
isLinkFile
=
IsFileExist
(
TARGET_PATH
.
c_str
());
EXPECT_EQ
(
isLinkFile
,
false
);
BindMountFile
(
g_srcFilePath
.
c_str
(),
g_targetPath
.
c_str
());
BindMountFile
(
SRC_FILE_PATH
.
c_str
(),
TARGET_PATH
.
c_str
());
int
ret
=
symlink
(
g_srcFilePath
.
c_str
(),
g_targetPath
.
c_str
());
int
ret
=
symlink
(
SRC_FILE_PATH
.
c_str
(),
TARGET_PATH
.
c_str
());
EXPECT_EQ
(
ret
,
0
);
isLinkFile
=
IsFileExistWithType
(
g_targetPath
.
c_str
(),
TYPE_LINK
);
isLinkFile
=
IsFileExistWithType
(
TARGET_PATH
.
c_str
(),
TYPE_LINK
);
EXPECT_EQ
(
isLinkFile
,
true
);
BindMountFile
(
g_srcFilePath
.
c_str
(),
g_targetPath
.
c_str
());
BindMountFile
(
SRC_FILE_PATH
.
c_str
(),
TARGET_PATH
.
c_str
());
if
(
!
IsDirExist
(
g_engRootPath
.
c_str
()))
{
if
(
!
IsDirExist
(
ENG_ROOT_PATH
.
c_str
()))
{
CheckAndCreateDir
(
STARTUP_INIT_UT_PATH
"/eng/"
);
}
BindMountFile
(
g_engRootPath
.
c_str
(),
g_targetPath
.
c_str
());
BindMountFile
(
ENG_ROOT_PATH
.
c_str
(),
TARGET_PATH
.
c_str
());
}
HWTEST_F
(
EngUnitTest
,
TestMountCmd
,
TestSize
.
Level1
)
...
...
@@ -200,14 +200,14 @@ HWTEST_F(EngUnitTest, TestFileType, TestSize.Level1)
std
::
string
linkName
=
"/data/init_ut/eng/link_name_test"
;
bool
isExist
=
false
;
if
(
!
IsFileExist
(
g_srcFilePath
.
c_str
()))
{
CreateTestFile
(
g_srcFilePath
.
c_str
(),
"test"
);
isExist
=
IsFileExist
(
g_srcFilePath
.
c_str
());
if
(
!
IsFileExist
(
SRC_FILE_PATH
.
c_str
()))
{
CreateTestFile
(
SRC_FILE_PATH
.
c_str
(),
"test"
);
isExist
=
IsFileExist
(
SRC_FILE_PATH
.
c_str
());
EXPECT_EQ
(
isExist
,
true
);
}
EXPECT_EQ
(
IsFileExistWithType
(
STARTUP_INIT_UT_PATH
"/eng"
,
TYPE_DIR
),
true
);
EXPECT_EQ
(
IsFileExistWithType
(
g_srcFilePath
.
c_str
(),
TYPE_REG
),
true
);
EXPECT_EQ
(
IsFileExistWithType
(
SRC_FILE_PATH
.
c_str
(),
TYPE_REG
),
true
);
if
(
IsFileExist
(
targetFile
))
{
if
(
unlink
(
targetFile
.
c_str
())
<
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录