Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
e65187e2
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看板
提交
e65187e2
编写于
10月 14, 2022
作者:
C
chengjinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
codex
Signed-off-by:
N
chengjinsong
<
chengjinsong2@huawei.com
>
上级
eedf9c49
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
142 addition
and
146 deletion
+142
-146
interfaces/innerkits/include/syspara/sysparam_errno.h
interfaces/innerkits/include/syspara/sysparam_errno.h
+6
-6
interfaces/innerkits/modulemgr/modulemgr.c
interfaces/innerkits/modulemgr/modulemgr.c
+4
-2
interfaces/innerkits/sandbox/include/sandbox.h
interfaces/innerkits/sandbox/include/sandbox.h
+3
-3
interfaces/innerkits/syspara/param_comm.c
interfaces/innerkits/syspara/param_comm.c
+2
-2
interfaces/kits/jskits/src/native_parameters_js.cpp
interfaces/kits/jskits/src/native_parameters_js.cpp
+6
-6
interfaces/kits/jskits/src/native_parameters_watch.cpp
interfaces/kits/jskits/src/native_parameters_watch.cpp
+7
-7
interfaces/kits/jskits/src_v9/native_parameters_js.cpp
interfaces/kits/jskits/src_v9/native_parameters_js.cpp
+1
-2
services/begetctl/misc_daemon.cpp
services/begetctl/misc_daemon.cpp
+3
-3
services/begetctl/partitionslot.cpp
services/begetctl/partitionslot.cpp
+12
-8
services/begetctl/sandbox.cpp
services/begetctl/sandbox.cpp
+6
-6
services/init/standard/init.c
services/init/standard/init.c
+4
-4
services/init/standard/init_cmdexecutor.c
services/init/standard/init_cmdexecutor.c
+2
-2
services/init/standard/switch_root.c
services/init/standard/switch_root.c
+2
-1
services/loopevent/task/le_asynctask.c
services/loopevent/task/le_asynctask.c
+7
-5
services/modules/seccomp/scripts/generate_code_from_policy.py
...ices/modules/seccomp/scripts/generate_code_from_policy.py
+2
-1
services/param/watcher/agent/watcher_manager_kits.h
services/param/watcher/agent/watcher_manager_kits.h
+1
-1
services/param/watcher/proxy/watcher_manager.h
services/param/watcher/proxy/watcher_manager.h
+1
-1
test/exec_test/sa_service_ondemand_test.cpp
test/exec_test/sa_service_ondemand_test.cpp
+2
-1
test/moduletest/hookmgr_moduletest.cpp
test/moduletest/hookmgr_moduletest.cpp
+1
-1
test/moduletest/service_watcher_moduleTest.cpp
test/moduletest/service_watcher_moduleTest.cpp
+4
-4
test/moduletest/syspara.cpp
test/moduletest/syspara.cpp
+17
-14
test/moduletest/syspara_moduleTest.cpp
test/moduletest/syspara_moduleTest.cpp
+43
-60
test/unittest/param/trigger_unittest.cpp
test/unittest/param/trigger_unittest.cpp
+5
-5
test/unittest/param/watcher_proxy_unittest.cpp
test/unittest/param/watcher_proxy_unittest.cpp
+1
-1
未找到文件。
interfaces/innerkits/include/syspara/sysparam_errno.h
浏览文件 @
e65187e2
...
...
@@ -29,12 +29,12 @@ enum OHOSStartUpSysParamErrorCode {
EC_INVALID
=
-
9
,
/* Invalid argument */
EC_SYSTEM_ERR
=
-
10
,
/* system error */
SYSPARAM_INVALID_INPUT
=
-
401
,
/*
Input parameter is missing or invalid
*/
SYSPARAM_NOT_FOUND
=
-
14700101
,
/*
System parameter can not be found.
*/
SYSPARAM_INVALID_VALUE
=
-
14700102
,
/*
System parameter value is invalid
*/
SYSPARAM_PERMISSION_DENIED
=
-
14700103
,
/*
System permission operation permission denied
*/
SYSPARAM_SYSTEM_ERROR
=
-
14700104
,
/* System internal error including out of memory, deadlock etc.*/
SYSPARAM_WAIT_TIMEOUT
=
-
14700105
,
/* System wait parameter value change time out.*/
SYSPARAM_INVALID_INPUT
=
-
401
,
/*
Input parameter is missing or invalid
*/
SYSPARAM_NOT_FOUND
=
-
14700101
,
/*
System parameter can not be found.
*/
SYSPARAM_INVALID_VALUE
=
-
14700102
,
/*
System parameter value is invalid
*/
SYSPARAM_PERMISSION_DENIED
=
-
14700103
,
/*
System permission operation permission denied
*/
SYSPARAM_SYSTEM_ERROR
=
-
14700104
,
/* System internal error including out of memory, deadlock etc.
*/
SYSPARAM_WAIT_TIMEOUT
=
-
14700105
,
/* System wait parameter value change time out.
*/
};
#ifdef __cplusplus
...
...
interfaces/innerkits/modulemgr/modulemgr.c
浏览文件 @
e65187e2
...
...
@@ -116,10 +116,12 @@ static void *ModuleInstall(MODULE_ITEM *module, int argc, const char *argv[])
}
}
BEGET_LOGV
(
"Module install path %s"
,
path
);
const
char
*
realPath
=
GetRealPath
(
path
);
BEGET_ERROR_CHECK
(
realPath
!=
NULL
,
return
NULL
,
"Failed to get real path"
);
currentInstallArgs
=
&
(
module
->
moduleMgr
->
installArgs
);
handle
=
dlopen
(
p
ath
,
RTLD_LAZY
|
RTLD_GLOBAL
);
handle
=
dlopen
(
realP
ath
,
RTLD_LAZY
|
RTLD_GLOBAL
);
currentInstallArgs
=
NULL
;
BEGET_CHECK_ONLY_ELOG
(
handle
!=
NULL
,
"ModuleInstall path %s fail %d"
,
p
ath
,
errno
);
BEGET_CHECK_ONLY_ELOG
(
handle
!=
NULL
,
"ModuleInstall path %s fail %d"
,
realP
ath
,
errno
);
return
handle
;
}
...
...
interfaces/innerkits/sandbox/include/sandbox.h
浏览文件 @
e65187e2
...
...
@@ -16,12 +16,12 @@
#ifndef BASE_STARTUP_INITLITE_SANDBOX_H
#define BASE_STARTUP_INITLITE_SANDBOX_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdbool.h>
#include "init_utils.h"
#include "list.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
enum
SandboxTag
{
SANDBOX_TAG_MOUNT_PATH
=
0
,
...
...
interfaces/innerkits/syspara/param_comm.c
浏览文件 @
e65187e2
...
...
@@ -33,7 +33,7 @@
INIT_LOCAL_API
int
GetSystemError
(
int
err
)
{
switch
(
err
)
{
switch
(
err
)
{
case
0
:
return
0
;
case
PARAM_CODE_INVALID_PARAM
:
...
...
@@ -194,7 +194,7 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size)
return
-
1
;
}
int
tmpSize
=
strlen
(
manufacture
)
+
strlen
(
model
)
+
strlen
(
sn
)
+
1
;
if
(
tmpSize
<=
0
||
tmpSize
>
DEV_BUF_MAX_LENGTH
)
{
if
(
tmpSize
<=
1
||
tmpSize
>
DEV_BUF_MAX_LENGTH
)
{
return
-
1
;
}
char
*
tmp
=
NULL
;
...
...
interfaces/kits/jskits/src/native_parameters_js.cpp
浏览文件 @
e65187e2
...
...
@@ -43,13 +43,13 @@ static void SetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_create_async_work
(
env
,
nullptr
,
resource
,
[](
napi_env
env
,
void
*
data
)
{
StorageAsyncContext
*
asyncContext
=
(
StorageAsyncContext
*
)
data
;
StorageAsyncContext
*
asyncContext
=
reinterpret_cast
<
StorageAsyncContext
*>
(
data
)
;
asyncContext
->
status
=
SetParameter
(
asyncContext
->
key
,
asyncContext
->
value
);
PARAM_JS_LOGV
(
"JSApp set::asyncContext-> status = %d, asyncContext->key = %s, asyncContext->value = %s."
,
asyncContext
->
status
,
asyncContext
->
key
,
asyncContext
->
value
);
},
[](
napi_env
env
,
napi_status
status
,
void
*
data
)
{
StorageAsyncContext
*
asyncContext
=
(
StorageAsyncContext
*
)
data
;
StorageAsyncContext
*
asyncContext
=
reinterpret_cast
<
StorageAsyncContext
*>
(
data
)
;
napi_value
result
[
ARGC_NUMBER
]
=
{
0
};
if
(
asyncContext
->
status
==
0
)
{
napi_get_undefined
(
env
,
&
result
[
0
]);
...
...
@@ -78,7 +78,7 @@ static void SetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_delete_async_work
(
env
,
asyncContext
->
work
);
delete
asyncContext
;
},
(
void
*
)
asyncContext
,
&
asyncContext
->
work
);
reinterpret_cast
<
void
*>
(
asyncContext
)
,
&
asyncContext
->
work
);
napi_queue_async_work
(
env
,
asyncContext
->
work
);
}
...
...
@@ -214,14 +214,14 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_create_async_work
(
env
,
nullptr
,
resource
,
[](
napi_env
env
,
void
*
data
)
{
StorageAsyncContext
*
asyncContext
=
(
StorageAsyncContext
*
)
data
;
StorageAsyncContext
*
asyncContext
=
reinterpret_cast
<
StorageAsyncContext
*>
(
data
)
;
asyncContext
->
status
=
OHOS
::
system
::
GetStringParameter
(
asyncContext
->
key
,
asyncContext
->
getValue
,
asyncContext
->
value
);
PARAM_JS_LOGV
(
"JSApp get status = %d, asyncContext->getValue = %s, asyncContext->key = %s, value = %s."
,
asyncContext
->
status
,
asyncContext
->
getValue
.
c_str
(),
asyncContext
->
key
,
asyncContext
->
value
);
},
[](
napi_env
env
,
napi_status
status
,
void
*
data
)
{
StorageAsyncContext
*
asyncContext
=
(
StorageAsyncContext
*
)
data
;
StorageAsyncContext
*
asyncContext
=
reinterpret_cast
<
StorageAsyncContext
*>
(
data
)
;
napi_value
result
[
ARGC_NUMBER
]
=
{
0
};
if
(
asyncContext
->
status
==
0
)
{
napi_get_undefined
(
env
,
&
result
[
0
]);
...
...
@@ -251,7 +251,7 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_delete_async_work
(
env
,
asyncContext
->
work
);
delete
asyncContext
;
},
(
void
*
)
asyncContext
,
&
asyncContext
->
work
);
reinterpret_cast
<
void
*>
(
asyncContext
)
,
&
asyncContext
->
work
);
napi_queue_async_work
(
env
,
asyncContext
->
work
);
}
...
...
interfaces/kits/jskits/src/native_parameters_watch.cpp
浏览文件 @
e65187e2
...
...
@@ -91,7 +91,7 @@ static int GetParamValue(napi_env env, napi_value arg, napi_valuetype valueType,
if
(
valueType
==
napi_string
)
{
status
=
napi_get_value_string_utf8
(
env
,
arg
,
buffer
,
buffLen
,
&
buffLen
);
}
else
if
(
valueType
==
napi_number
)
{
status
=
napi_get_value_int32
(
env
,
arg
,
(
int
*
)
buffer
);
status
=
napi_get_value_int32
(
env
,
arg
,
reinterpret_cast
<
int
*>
(
buffer
)
);
}
return
status
;
}
...
...
@@ -103,12 +103,12 @@ static void WaitCallbackWork(napi_env env, ParamAsyncContextPtr asyncContext)
napi_create_async_work
(
env
,
nullptr
,
resource
,
[](
napi_env
env
,
void
*
data
)
{
ParamAsyncContext
*
asyncContext
=
(
ParamAsyncContext
*
)
data
;
ParamAsyncContext
*
asyncContext
=
reinterpret_cast
<
ParamAsyncContext
*>
(
data
)
;
asyncContext
->
status
=
WaitParameter
(
asyncContext
->
key
,
asyncContext
->
value
,
asyncContext
->
timeout
);
PARAM_JS_LOGV
(
"JSApp Wait status: %d, key: %s"
,
asyncContext
->
status
,
asyncContext
->
key
);
},
[](
napi_env
env
,
napi_status
status
,
void
*
data
)
{
ParamAsyncContext
*
asyncContext
=
(
ParamAsyncContext
*
)
data
;
ParamAsyncContext
*
asyncContext
=
reinterpret_cast
<
ParamAsyncContext
*>
(
data
)
;
napi_value
result
[
ARGC_NUMBER
]
=
{
0
};
napi_value
message
=
nullptr
;
napi_create_object
(
env
,
&
result
[
0
]);
...
...
@@ -136,7 +136,7 @@ static void WaitCallbackWork(napi_env env, ParamAsyncContextPtr asyncContext)
napi_delete_async_work
(
env
,
asyncContext
->
work
);
delete
asyncContext
;
},
(
void
*
)
asyncContext
,
&
asyncContext
->
work
);
reinterpret_cast
<
void
*>
(
asyncContext
)
,
&
asyncContext
->
work
);
napi_queue_async_work
(
env
,
asyncContext
->
work
);
}
...
...
@@ -468,7 +468,7 @@ static void WatchCallbackWork(napi_env env, ParamWatcherPtr watcher)
napi_create_string_utf8
(
env
,
"JSStartupWatch"
,
NAPI_AUTO_LENGTH
,
&
resource
);
napi_create_async_work
(
env
,
nullptr
,
resource
,
[](
napi_env
env
,
void
*
data
)
{
ParamWatcherWork
*
worker
=
(
ParamWatcherWork
*
)
data
;
ParamWatcherWork
*
worker
=
reinterpret_cast
<
ParamWatcherWork
*>
(
data
)
;
PARAM_JS_CHECK
(
worker
!=
nullptr
&&
worker
->
watcher
!=
nullptr
,
return
,
"Invalid worker "
);
int
status
=
WatchParameter
(
worker
->
watcher
->
keyPrefix
,
worker
->
startWatch
?
ProcessParamChange
:
nullptr
,
worker
->
watcher
);
...
...
@@ -476,13 +476,13 @@ static void WatchCallbackWork(napi_env env, ParamWatcherPtr watcher)
worker
->
startWatch
?
"on"
:
"off"
,
status
,
worker
->
watcher
->
keyPrefix
);
},
[](
napi_env
env
,
napi_status
status
,
void
*
data
)
{
ParamWatcherWork
*
worker
=
(
ParamWatcherWork
*
)
data
;
ParamWatcherWork
*
worker
=
reinterpret_cast
<
ParamWatcherWork
*>
(
data
)
;
PARAM_JS_LOGV
(
"JSApp WatchCallbackWork delete %s key: %s"
,
worker
->
startWatch
?
"on"
:
"off"
,
worker
->
watcher
->
keyPrefix
);
napi_delete_async_work
(
env
,
worker
->
work
);
delete
worker
;
},
(
void
*
)
worker
,
&
worker
->
work
);
reinterpret_cast
<
void
*>
(
worker
)
,
&
worker
->
work
);
napi_queue_async_work
(
env
,
worker
->
work
);
}
...
...
interfaces/kits/jskits/src_v9/native_parameters_js.cpp
浏览文件 @
e65187e2
...
...
@@ -39,7 +39,7 @@ using StorageAsyncContextPtr = StorageAsyncContext *;
static
int
GetErrorInfo
(
int
status
,
std
::
string
&
errMsg
)
{
switch
(
status
)
{
switch
(
status
)
{
case
EC_FAILURE
:
case
EC_SYSTEM_ERR
:
case
SYSPARAM_SYSTEM_ERROR
:
...
...
@@ -67,7 +67,6 @@ static int GetErrorInfo(int status, std::string &errMsg)
static
napi_value
BusinessErrorCreate
(
napi_env
env
,
int
status
)
{
std
::
string
errMsg
=
""
;
int
ret
=
GetErrorInfo
(
status
,
errMsg
);
PARAM_JS_LOGV
(
"BusinessErrorCreate status %d err %d msg: %s"
,
status
,
ret
,
errMsg
.
c_str
());
...
...
services/begetctl/misc_daemon.cpp
浏览文件 @
e65187e2
...
...
@@ -74,7 +74,7 @@ static void WriteLogoContent(int fd, const std::string &logoPath, uint32_t size)
return
;
}
char
*
buffer
=
(
char
*
)
malloc
(
size
);
char
*
buffer
=
reinterpret_cast
<
char
*>
(
malloc
(
size
)
);
if
(
buffer
==
nullptr
)
{
(
void
)
fclose
(
rgbFile
);
return
;
...
...
@@ -219,8 +219,8 @@ MODULE_CONSTRUCTOR(void)
{
const
CmdInfo
infos
[]
=
{
{
(
char
*
)
"misc_daemon"
,
main_cmd
,
(
char
*
)
"write start logo"
,
(
char
*
)
"misc_daemon --write_logo xxx.rgb"
,
(
char
*
)
"misc_daemon --write_logo"
const_cast
<
char
*>
(
"misc_daemon"
),
main_cmd
,
const_cast
<
char
*>
(
"write start logo"
)
,
const_cast
<
char
*>
(
"misc_daemon --write_logo xxx.rgb"
),
const_cast
<
char
*>
(
"misc_daemon --write_logo"
)
}
};
for
(
size_t
i
=
0
;
i
<
sizeof
(
infos
)
/
sizeof
(
infos
[
0
]);
i
++
)
{
...
...
services/begetctl/partitionslot.cpp
浏览文件 @
e65187e2
...
...
@@ -138,20 +138,24 @@ MODULE_CONSTRUCTOR(void)
{
CmdInfo
infos
[]
=
{
{
(
char
*
)
"partitionslot"
,
GetSlot
,
(
char
*
)
"get the number of slots and current slot"
,
(
char
*
)
"partitionslot getslot"
,
(
char
*
)
"partitionslot getslot"
const_cast
<
char
*>
(
"partitionslot"
),
GetSlot
,
const_cast
<
char
*>
(
"get the number of slots and current slot"
),
const_cast
<
char
*>
(
"partitionslot getslot"
),
const_cast
<
char
*>
(
"partitionslot getslot"
)
},
{
(
char
*
)
"partitionslot"
,
GetSuffix
,
(
char
*
)
"get suffix that matches with the slot"
,
(
char
*
)
"partitionslot getsuffix [slot]"
,
(
char
*
)
"partitionslot getsuffix"
const_cast
<
char
*>
(
"partitionslot"
),
GetSuffix
,
const_cast
<
char
*>
(
"get suffix that matches with the slot"
),
const_cast
<
char
*>
(
"partitionslot getsuffix [slot]"
),
const_cast
<
char
*>
(
"partitionslot getsuffix"
)
},
{
(
char
*
)
"partitionslot"
,
SetActiveSlot
,
(
char
*
)
"set active slot"
,
(
char
*
)
"partitionslot setactive [slot]"
,
(
char
*
)
"partitionslot setactive"
const_cast
<
char
*>
(
"partitionslot"
),
SetActiveSlot
,
const_cast
<
char
*>
(
"set active slot"
),
const_cast
<
char
*>
(
"partitionslot setactive [slot]"
),
const_cast
<
char
*>
(
"partitionslot setactive"
)
},
{
(
char
*
)
"partitionslot"
,
SetUnbootSlot
,
(
char
*
)
"set unboot slot"
,
(
char
*
)
"partitionslot setunboot [slot]"
,
(
char
*
)
"partitionslot setunboot"
const_cast
<
char
*>
(
"partitionslot"
),
SetUnbootSlot
,
const_cast
<
char
*>
(
"set unboot slot"
),
const_cast
<
char
*>
(
"partitionslot setunboot [slot]"
),
const_cast
<
char
*>
(
"partitionslot setunboot"
)
}
};
for
(
size_t
i
=
sizeof
(
infos
)
/
sizeof
(
infos
[
0
]);
i
>
0
;
i
--
)
{
...
...
services/begetctl/sandbox.cpp
浏览文件 @
e65187e2
...
...
@@ -185,18 +185,18 @@ MODULE_CONSTRUCTOR(void)
{
const
CmdInfo
infos
[]
=
{
{
(
char
*
)
"sandbox"
,
main_cmd
,
(
char
*
)
"enter service sandbox"
,
(
char
*
)
"sandbox -s service_name"
,
const_cast
<
char
*>
(
"sandbox"
),
main_cmd
,
const_cast
<
char
*>
(
"enter service sandbox"
)
,
const_cast
<
char
*>
(
"sandbox -s service_name"
)
,
NULL
},
{
(
char
*
)
"sandbox"
,
main_cmd
,
(
char
*
)
"enter namespace, system, chipset etc."
,
(
char
*
)
"sandbox -n namespace_name [-p]"
,
const_cast
<
char
*>
(
"sandbox"
),
main_cmd
,
const_cast
<
char
*>
(
"enter namespace, system, chipset etc."
)
,
const_cast
<
char
*>
(
"sandbox -n namespace_name [-p]"
)
,
NULL
},
{
(
char
*
)
"sandbox"
,
main_cmd
,
(
char
*
)
"enter namespace and exec process"
,
(
char
*
)
"sandbox -p process_name"
,
const_cast
<
char
*>
(
"sandbox"
),
main_cmd
,
const_cast
<
char
*>
(
"enter namespace and exec process"
)
,
const_cast
<
char
*>
(
"sandbox -p process_name"
)
,
NULL
}
};
...
...
services/init/standard/init.c
浏览文件 @
e65187e2
...
...
@@ -302,8 +302,8 @@ static void InitPostHook(const HOOK_INFO *hookInfo, void *executionContext, int
INIT_TIMING_STAT
*
stat
=
(
INIT_TIMING_STAT
*
)
executionContext
;
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
stat
->
endTime
));
long
long
diff
=
InitDiffTime
(
stat
);
INIT_LOGI
(
"Executing hook [%d:%d
:%p
] cost [%lld]us, return %d."
,
hookInfo
->
stage
,
hookInfo
->
prio
,
hookInfo
->
hook
,
diff
,
executionRetVal
);
INIT_LOGI
(
"Executing hook [%d:%d] cost [%lld]us, return %d."
,
hookInfo
->
stage
,
hookInfo
->
prio
,
diff
,
executionRetVal
);
}
static
void
InitSysAdj
(
void
)
...
...
@@ -344,11 +344,11 @@ static void TriggerServices(int startMode)
continue
;
}
if
(
index
==
0
)
{
sprintf_s
(
jobName
,
sizeof
(
jobName
),
"boot-service:service-%d-%03d"
,
startMode
,
jobNum
);
(
void
)
sprintf_s
(
jobName
,
sizeof
(
jobName
),
"boot-service:service-%d-%03d"
,
startMode
,
jobNum
);
jobNum
++
;
}
index
++
;
sprintf_s
(
cmd
,
sizeof
(
cmd
),
"start %s"
,
service
->
name
);
(
void
)
sprintf_s
(
cmd
,
sizeof
(
cmd
),
"start %s"
,
service
->
name
);
AddCompleteJob
(
jobName
,
NULL
,
cmd
);
INIT_LOGV
(
"Add %s to job %s"
,
service
->
name
,
jobName
);
if
(
index
==
maxServiceInJob
)
{
...
...
services/init/standard/init_cmdexecutor.c
浏览文件 @
e65187e2
...
...
@@ -146,8 +146,8 @@ static int CompareCmdId(const HashNode *node, const void *key)
static
PluginCmd
*
GetPluginCmdByIndex
(
int
index
)
{
int
hashCode
=
((
index
>>
16
)
&
0x0000ffff
)
-
1
;
// 16 left shift
int
cmdId
=
(
index
&
0x0000ffff
);
int
hashCode
=
((
(
unsigned
int
)
index
>>
16
)
&
0x0000ffff
)
-
1
;
// 16 left shift
int
cmdId
=
(
(
unsigned
int
)
index
&
0x0000ffff
);
HashNode
*
node
=
OH_HashMapFind
(
GetGroupHashMap
(
NODE_TYPE_CMDS
),
hashCode
,
(
const
void
*
)
&
cmdId
,
CompareCmdId
);
if
(
node
==
NULL
)
{
...
...
services/init/standard/switch_root.c
浏览文件 @
e65187e2
...
...
@@ -84,8 +84,9 @@ static bool UnderBasicMountPoint(const char *path)
}
const
char
*
basicMountPoint
[]
=
{
"/dev/"
,
"/sys/"
,
"/proc/"
};
for
(
i
=
0
;
i
<
ARRAY_LENGTH
(
basicMountPoint
);
i
++
)
{
if
(
strncmp
(
path
,
basicMountPoint
[
i
],
strlen
(
basicMountPoint
[
i
]))
==
0
)
if
(
strncmp
(
path
,
basicMountPoint
[
i
],
strlen
(
basicMountPoint
[
i
]))
==
0
)
{
return
true
;
}
}
return
false
;
}
...
...
services/loopevent/task/le_asynctask.c
浏览文件 @
e65187e2
...
...
@@ -18,6 +18,9 @@
#include "le_loop.h"
#define MILLION_MICROSECOND 1000000
#define THOUSAND_MILLISECOND 1000
static
void
DoAsyncEvent_
(
const
LoopHandle
loopHandle
,
AsyncEventTask
*
asyncTask
)
{
LE_CHECK
(
loopHandle
!=
NULL
&&
asyncTask
!=
NULL
,
return
,
"Invalid parameters"
);
...
...
@@ -29,7 +32,7 @@ static void DoAsyncEvent_(const LoopHandle loopHandle, AsyncEventTask *asyncTask
#endif
StreamTask
*
task
=
&
asyncTask
->
stream
;
ListNode
*
node
=
task
->
buffHead
.
next
;
while
(
node
!=
&
task
->
buffHead
)
{
if
(
node
!=
&
task
->
buffHead
)
{
LE_Buffer
*
buffer
=
ListEntry
(
node
,
LE_Buffer
,
node
);
uint64_t
eventId
=
*
(
uint64_t
*
)(
buffer
->
data
);
if
(
asyncTask
->
processAsyncEvent
)
{
...
...
@@ -40,15 +43,14 @@ static void DoAsyncEvent_(const LoopHandle loopHandle, AsyncEventTask *asyncTask
free
(
buffer
);
#ifdef LOOP_DEBUG
clock_gettime
(
CLOCK_MONOTONIC
,
&
(
endTime
));
diff
=
(
long
long
)((
endTime
.
tv_sec
-
startTime
.
tv_sec
)
*
1000000
);
diff
=
(
long
long
)((
endTime
.
tv_sec
-
startTime
.
tv_sec
)
*
MILLION_MICROSECOND
);
if
(
endTime
.
tv_nsec
>
startTime
.
tv_nsec
)
{
diff
+=
(
endTime
.
tv_nsec
-
startTime
.
tv_nsec
)
/
1000
;
// 1000 ms
diff
+=
(
endTime
.
tv_nsec
-
startTime
.
tv_nsec
)
/
THOUSAND_MILLISECOND
;
// 1000 ms
}
else
{
diff
-=
(
endTime
.
tv_nsec
-
startTime
.
tv_nsec
)
/
1000
;
// 1000 ms
diff
-=
(
endTime
.
tv_nsec
-
startTime
.
tv_nsec
)
/
THOUSAND_MILLISECOND
;
// 1000 ms
}
LE_LOGI
(
"DoAsyncEvent_ diff %ld"
,
diff
);
#endif
break
;
}
}
...
...
services/modules/seccomp/scripts/generate_code_from_policy.py
浏览文件 @
e65187e2
...
...
@@ -556,7 +556,8 @@ class GenBpfPolicy:
return
operation_str
,
True
#gen bpf (argn & mask) == value
def
gen_mask_equal_bpf
(
self
,
arg_id
,
mask
,
value
,
cur_size
):
@
staticmethod
def
gen_mask_equal_bpf
(
arg_id
,
mask
,
value
,
cur_size
):
bpf_policy
=
[]
#high 4 bytes
bpf_policy
.
append
(
BPF_LOAD
.
format
(
20
+
arg_id
*
8
))
...
...
services/param/watcher/agent/watcher_manager_kits.h
浏览文件 @
e65187e2
...
...
@@ -46,7 +46,7 @@ private:
:
callback_
(
callback
),
context_
(
context
)
{}
~
ParameterChangeListener
()
=
default
;
bool
IsEqual
(
ParameterChangePtr
callback
,
void
*
context
)
const
bool
IsEqual
(
ParameterChangePtr
callback
,
const
void
*
context
)
const
{
return
(
callback
==
callback_
&&
context
==
context_
);
}
...
...
services/param/watcher/proxy/watcher_manager.h
浏览文件 @
e65187e2
...
...
@@ -163,7 +163,7 @@ private:
int
GetServerFd
(
bool
retry
);
int
GetWatcherId
(
uint32_t
&
watcherId
);
int
GetGroupId
(
uint32_t
&
groupId
);
void
DumpWatcherGroup
(
int
fd
,
const
WatcherGroupPtr
&
g
roup
);
void
DumpWatcherGroup
(
int
fd
,
const
WatcherGroupPtr
&
watchG
roup
);
private:
std
::
atomic
<
uint32_t
>
watcherId_
{
0
};
std
::
atomic
<
uint32_t
>
groupId_
{
0
};
...
...
test/exec_test/sa_service_ondemand_test.cpp
浏览文件 @
e65187e2
...
...
@@ -42,7 +42,7 @@ void OnDemandLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
cout
<<
"OnLoadSystemAbilityFail systemAbilityId:"
<<
systemAbilityId
<<
endl
;
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
const
argv
[])
{
std
::
map
<
string
,
int
>
saService
=
{
{
"updater_sa"
,
UPDATE_DISTRIBUTED_SERVICE_ID
},
...
...
@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
int
parameterNum
=
2
;
if
((
argc
!=
parameterNum
)
||
(
argv
[
1
]
==
nullptr
))
{
cout
<<
"Invalid parameter"
<<
endl
;
return
0
;
}
const
string
name
=
argv
[
1
];
int
abilityId
=
0
;
...
...
test/moduletest/hookmgr_moduletest.cpp
浏览文件 @
e65187e2
...
...
@@ -40,7 +40,7 @@ struct HookExecCtx {
int
retErr
;
};
void
HookExecFunc
(
int
n
)
void
HookExecFunc
(
int
n
)
{
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
HookMgrExecute
(
g_hookMgr
,
STAGE_TEST_ONE
,
nullptr
,
nullptr
);
...
...
test/moduletest/service_watcher_moduleTest.cpp
浏览文件 @
e65187e2
...
...
@@ -23,7 +23,7 @@
using
namespace
testing
::
ext
;
namespace
initModuleTest
{
class
s
erviceWatcherModuleTest
:
public
testing
::
Test
{
class
S
erviceWatcherModuleTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
...
...
@@ -36,7 +36,7 @@ static void ServiceStatusChange(const char *key, ServiceStatus status)
std
::
cout
<<
"service Name is: "
<<
key
<<
", ServiceStatus is: "
<<
status
<<
std
::
endl
;
}
HWTEST_F
(
serviceWatcherModuleTest
,
serviceWatcher_test_001
,
TestSize
.
Level0
)
HWTEST_F
(
ServiceWatcherModuleTest
,
serviceWatcher_test_001
,
TestSize
.
Level0
)
{
GTEST_LOG_
(
INFO
)
<<
"serviceWatcher_test_001 start"
;
string
serviceName
=
"test.Service"
;
...
...
@@ -47,14 +47,14 @@ HWTEST_F(serviceWatcherModuleTest,serviceWatcher_test_001, TestSize.Level0)
GTEST_LOG_
(
INFO
)
<<
"serviceWatcher_test_001 end"
;
}
HWTEST_F
(
serviceWatcherModuleTest
,
serviceWatcher_test_002
,
TestSize
.
Level0
)
HWTEST_F
(
ServiceWatcherModuleTest
,
serviceWatcher_test_002
,
TestSize
.
Level0
)
{
GTEST_LOG_
(
INFO
)
<<
"serviceWatcher_test_002 start"
;
string
serviceName
=
"media_service"
;
auto
status
=
GetServiceStatus
(
serviceName
);
if
(
status
==
"running"
)
{
int
ret
=
ServiceControl
(
serviceName
.
c_str
(),
STOP
);
ASSERT_EQ
(
ret
,
0
);
ASSERT_EQ
(
ret
,
0
);
}
else
if
(
status
!=
"created"
&&
status
!=
"stopped"
)
{
std
::
cout
<<
serviceName
<<
" in invalid status "
<<
status
<<
std
::
endl
;
ASSERT_TRUE
(
0
);
...
...
test/moduletest/syspara.cpp
浏览文件 @
e65187e2
...
...
@@ -59,38 +59,41 @@ static int32_t SysParaApiDumpCmd(BShellHandle shell, int32_t argc, char *argv[])
int
index
=
0
;
int
dumpInfoItemNum
=
(
sizeof
(
SYSPARA_LIST
)
/
sizeof
(
SYSPARA_LIST
[
0
]));
const
char
*
temp
=
nullptr
;
BShellEnvOutput
(
shell
,
(
char
*
)
"Begin dump syspara
\r\n
"
);
BShellEnvOutput
(
shell
,
(
char
*
)
"=======================
\r\n
"
);
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"Begin dump syspara
\r\n
"
)
);
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"=======================
\r\n
"
)
);
while
(
index
<
dumpInfoItemNum
)
{
temp
=
SYSPARA_LIST
[
index
].
getInfoValue
();
BShellEnvOutput
(
shell
,
(
char
*
)
"%s:%s
\r\n
"
,
SYSPARA_LIST
[
index
].
infoName
,
temp
);
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"%s:%s
\r\n
"
)
,
SYSPARA_LIST
[
index
].
infoName
,
temp
);
index
++
;
}
BShellEnvOutput
(
shell
,
(
char
*
)
"FirstApiVersion:%d
\r\n
"
,
GetFirstApiVersion
());
BShellEnvOutput
(
shell
,
(
char
*
)
"GetSerial:%s
\r\n
"
,
GetSerial
());
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"FirstApiVersion:%d
\r\n
"
)
,
GetFirstApiVersion
());
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"GetSerial:%s
\r\n
"
)
,
GetSerial
());
#ifndef OHOS_LITE
BShellEnvOutput
(
shell
,
(
char
*
)
"acl serial:%s
\r\n
"
,
AclGetSerial
());
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"acl serial:%s
\r\n
"
)
,
AclGetSerial
());
#endif
char
udid
[
65
]
=
{
0
};
GetDevUdid
(
udid
,
sizeof
(
udid
));
BShellEnvOutput
(
shell
,
(
char
*
)
"GetDevUdid:%s
\r\n
"
,
udid
);
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"GetDevUdid:%s
\r\n
"
)
,
udid
);
#ifndef OHOS_LITE
AclGetDevUdid
(
udid
,
sizeof
(
udid
));
BShellEnvOutput
(
shell
,
(
char
*
)
"Acl devUdid:%s
\r\n
"
,
udid
);
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"Acl devUdid:%s
\r\n
"
)
,
udid
);
#endif
BShellEnvOutput
(
shell
,
(
char
*
)
"Version:%d.%d.%d.%d
\r\n
"
,
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"Version:%d.%d.%d.%d
\r\n
"
)
,
GetMajorVersion
(),
GetSeniorVersion
(),
GetFeatureVersion
(),
GetBuildVersion
());
BShellEnvOutput
(
shell
,
(
char
*
)
"GetSdkApiVersion:%d
\r\n
"
,
GetSdkApiVersion
());
BShellEnvOutput
(
shell
,
(
char
*
)
"GetSystemCommitId:%lld
\r\n
"
,
GetSystemCommitId
());
BShellEnvOutput
(
shell
,
(
char
*
)
"=======================
\r\n
"
);
BShellEnvOutput
(
shell
,
(
char
*
)
"End dump syspara
\r\n
"
);
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"GetSdkApiVersion:%d
\r\n
"
)
,
GetSdkApiVersion
());
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"GetSystemCommitId:%lld
\r\n
"
)
,
GetSystemCommitId
());
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"=======================
\r\n
"
)
);
BShellEnvOutput
(
shell
,
const_cast
<
char
*>
(
"End dump syspara
\r\n
"
)
);
return
0
;
}
MODULE_CONSTRUCTOR
(
void
)
{
const
CmdInfo
infos
[]
=
{
{(
char
*
)
"dump"
,
SysParaApiDumpCmd
,
(
char
*
)
"dump api"
,
(
char
*
)
"dump api"
,
(
char
*
)
"dump api"
},
{
const_cast
<
char
*>
(
"dump"
),
SysParaApiDumpCmd
,
const_cast
<
char
*>
(
"dump api"
),
const_cast
<
char
*>
(
"dump api"
),
const_cast
<
char
*>
(
"dump api"
)
},
};
for
(
size_t
i
=
0
;
i
<
sizeof
(
infos
)
/
sizeof
(
infos
[
0
]);
i
++
)
{
BShellEnvRegisterCmd
(
GetShellHandle
(),
&
infos
[
i
]);
...
...
test/moduletest/syspara_moduleTest.cpp
浏览文件 @
e65187e2
...
...
@@ -15,7 +15,7 @@
#include <thread>
#include <gtest/gtest.h>
#include <
stdint.h
>
#include <
cstdint
>
#include "param_wrapper.h"
#include "parameter.h"
#include "parameters.h"
...
...
@@ -75,12 +75,12 @@ static void SetParameterTestFunc(const char *key, const char *value)
EXPECT_NE
(
handle
,
static_cast
<
unsigned
int
>
(
-
1
));
uint32_t
result
=
GetParameterCommitId
(
handle
);
EXPECT_NE
(
result
,
static_cast
<
unsigned
int
>
(
-
1
));
char
nameGet
[
64
]
=
{
0
};
int
ret
=
GetParameterName
(
handle
,
nameGet
,
64
);
char
nameGet
[
PARAM_NAME_LEN_MAX
]
=
{
0
};
int
ret
=
GetParameterName
(
handle
,
nameGet
,
PARAM_NAME_LEN_MAX
);
EXPECT_EQ
(
ret
,
strlen
(
nameGet
));
EXPECT_STREQ
(
key
,
nameGet
);
char
valueGet
[
64
]
=
{
0
};
ret
=
GetParameterValue
(
handle
,
valueGet
,
64
);
char
valueGet
[
PARAM_VALUE_LEN_MAX
]
=
{
0
};
ret
=
GetParameterValue
(
handle
,
valueGet
,
PARAM_VALUE_LEN_MAX
);
EXPECT_EQ
(
ret
,
strlen
(
valueGet
));
EXPECT_STREQ
(
value
,
valueGet
);
EXPECT_NE
(
GetSystemCommitId
(),
0
);
...
...
@@ -115,9 +115,9 @@ static void TestParameterChange(const char *key, const char *value, void *contex
static
void
TestParameterWatchChange
(
void
)
{
size_t
index
=
1
;
int
ret
=
WatchParameter
(
"test.param.watcher.test1"
,
TestParameterChange
,
(
void
*
)
index
);
int
ret
=
WatchParameter
(
"test.param.watcher.test1"
,
TestParameterChange
,
reinterpret_cast
<
void
*>
(
index
)
);
EXPECT_EQ
(
ret
,
0
);
ret
=
RemoveParameterWatcher
(
"test.param.watcher.test1"
,
TestParameterChange
,
(
void
*
)
index
);
ret
=
RemoveParameterWatcher
(
"test.param.watcher.test1"
,
TestParameterChange
,
reinterpret_cast
<
void
*>
(
index
)
);
EXPECT_EQ
(
ret
,
0
);
}
...
...
@@ -142,7 +142,7 @@ HWTEST_F(SysparaModuleTest, Syspara_SysVersion_test_001, TestSize.Level0)
HWTEST_F
(
SysparaModuleTest
,
Syspara_GetParam_test_002
,
TestSize
.
Level0
)
{
GTEST_LOG_
(
INFO
)
<<
"Syspara_GetParam_test_002 start"
;
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
std
::
thread
(
GetAllParameterTestFunc
).
join
();
}
GTEST_LOG_
(
INFO
)
<<
"Syspara_GetParam_test_002 end"
;
...
...
@@ -151,7 +151,7 @@ HWTEST_F(SysparaModuleTest, Syspara_GetParam_test_002, TestSize.Level0)
HWTEST_F
(
SysparaModuleTest
,
Syspara_GetUdid_test_003
,
TestSize
.
Level0
)
{
GTEST_LOG_
(
INFO
)
<<
"Syspara_GetUdid_test_003 start"
;
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
char
udid
[
UDID_LEN
]
=
{
0
};
std
::
thread
(
GetUdidTestFunc
,
udid
,
UDID_LEN
).
join
();
}
...
...
@@ -176,12 +176,12 @@ HWTEST_F(SysparaModuleTest, Syspara_SetParameter_test_004, TestSize.Level0)
HWTEST_F
(
SysparaModuleTest
,
Syspara_SetParameter_test_005
,
TestSize
.
Level0
)
{
GTEST_LOG_
(
INFO
)
<<
"Syspara_SetParameter_test_005 start"
;
//check param name length
//
check param name length
char
key1
[]
=
"test.param.name.xxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxx"
;
char
value
[]
=
"test.value.xxxx"
;
int
ret
=
SetParameter
(
key1
,
value
);
EXPECT_EQ
(
ret
,
EC_INVALID
);
//check param name, Illegal param name
//
check param name, Illegal param name
char
key2
[]
=
".test.param.name.xxxxx"
;
ret
=
SetParameter
(
key2
,
value
);
EXPECT_EQ
(
ret
,
EC_INVALID
);
...
...
@@ -191,7 +191,7 @@ HWTEST_F(SysparaModuleTest, Syspara_SetParameter_test_005, TestSize.Level0)
char
key4
[]
=
"test..param. .name"
;
ret
=
SetParameter
(
key4
,
value
);
EXPECT_EQ
(
ret
,
EC_INVALID
);
//check param name, legal param name
//
check param name, legal param name
char
key5
[]
=
"test.param.name.--__.:::"
;
ret
=
SetParameter
(
key5
,
value
);
EXPECT_EQ
(
ret
,
0
);
...
...
@@ -200,7 +200,7 @@ HWTEST_F(SysparaModuleTest, Syspara_SetParameter_test_005, TestSize.Level0)
ret
=
SetParameter
(
key6
,
value
);
EXPECT_EQ
(
ret
,
0
);
EXPECT_STREQ
(
value
,
"test.value.xxxx"
);
//not const param, check param value, bool 8, int 32, other 96
//
not const param, check param value, bool 8, int 32, other 96
char
key7
[]
=
"test.param.name.xxxx"
;
char
value1
[]
=
"test.value.xxxxxxxxx.xxxxxxxxxxxxx.xxxxxxxxxxxx.xxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxx"
;
ret
=
SetParameter
(
key7
,
value1
);
...
...
@@ -221,12 +221,12 @@ HWTEST_F(SysparaModuleTest, Syspara_Getparameter_test_006, TestSize.Level0)
EXPECT_TRUE
(
ret
);
string
testValue
=
system
::
GetParameter
(
key
,
""
);
EXPECT_STREQ
(
testValue
.
c_str
(),
value
.
c_str
());
//not read param value,the result is default
//
not read param value,the result is default
testValue
=
system
::
GetParameter
(
"test.param.set.002"
,
"aaa.aaa.aaa"
);
EXPECT_STREQ
(
testValue
.
c_str
(),
"aaa.aaa.aaa"
);
testValue
=
system
::
GetParameter
(
"test.param.set.003"
,
""
);
EXPECT_STREQ
(
testValue
.
c_str
(),
""
);
//correct set value
//
correct set value
string
key1
=
"test.param.set.bool"
;
ret
=
system
::
SetParameter
(
key1
,
"1"
);
EXPECT_TRUE
(
ret
);
...
...
@@ -258,7 +258,7 @@ HWTEST_F(SysparaModuleTest, Syspara_Getparameter_test_006, TestSize.Level0)
ret
=
system
::
SetParameter
(
key1
,
"false"
);
EXPECT_TRUE
(
ret
);
EXPECT_FALSE
(
system
::
GetBoolParameter
(
key1
,
true
));
//set value type not bool,the result get form def
//
set value type not bool,the result get form def
ret
=
system
::
SetParameter
(
key1
,
"test"
);
EXPECT_TRUE
(
ret
);
EXPECT_TRUE
(
system
::
GetBoolParameter
(
key1
,
true
));
...
...
@@ -276,7 +276,7 @@ HWTEST_F(SysparaModuleTest, Syspara_SetParameter_test_007, TestSize.Level0)
string
vRet
=
""
;
uint32_t
handle1
=
FindParameter
(
key1
.
c_str
());
cout
<<
"handle1 is: "
<<
handle1
<<
std
::
endl
;
if
(
handle1
==
(
uint32_t
)
-
1
)
{
if
(
handle1
==
static_cast
<
uint32_t
>
(
-
1
)
)
{
ret
=
SetParameter
(
key1
.
c_str
(),
value1
.
c_str
());
EXPECT_EQ
(
ret
,
0
);
vRet
=
system
::
GetParameter
(
key1
,
""
);
...
...
@@ -290,7 +290,7 @@ HWTEST_F(SysparaModuleTest, Syspara_SetParameter_test_007, TestSize.Level0)
string
value3
=
"test.param.value.003"
;
uint32_t
handle2
=
FindParameter
(
key2
.
c_str
());
cout
<<
"handle2 is: "
<<
handle2
<<
std
::
endl
;
if
(
handle2
==
(
uint32_t
)
-
1
)
{
if
(
handle2
==
static_cast
<
uint32_t
>
(
-
1
)
)
{
ret
=
SetParameter
(
key2
.
c_str
(),
value3
.
c_str
());
EXPECT_EQ
(
ret
,
0
);
vRet
=
system
::
GetParameter
(
key2
,
""
);
...
...
@@ -310,10 +310,10 @@ HWTEST_F(SysparaModuleTest, Syspara_GetParameterReIntOrStr_test_008, TestSize.Le
int
ret
=
SetParameter
(
key
.
c_str
(),
value
.
c_str
());
EXPECT_EQ
(
ret
,
0
);
char
retValue
[
PARAM_VALUE_LEN_MAX
]
=
{
0
};
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
std
::
thread
(
GetParameterTestReInt
,
key
.
c_str
(),
""
,
retValue
,
PARAM_VALUE_LEN_MAX
).
join
();
}
for
(
int
j
=
0
;
j
<
THREAD_NUM
;
++
j
)
{
for
(
int
j
=
0
;
j
<
THREAD_NUM
;
++
j
)
{
std
::
thread
(
GetParameterTestFuncReStr
,
key
,
""
).
join
();
}
GTEST_LOG_
(
INFO
)
<<
"Syspara_GetParameterReIntOrStr_test_008 end"
;
...
...
@@ -322,7 +322,7 @@ HWTEST_F(SysparaModuleTest, Syspara_GetParameterReIntOrStr_test_008, TestSize.Le
HWTEST_F
(
SysparaModuleTest
,
Syspara_WaitParameter_test_009
,
TestSize
.
Level0
)
{
GTEST_LOG_
(
INFO
)
<<
"Syspara_WaitParameter_test_009 start"
;
//param already set succeed,waitParamter succeed.
//
param already set succeed,waitParamter succeed.
char
key
[]
=
"test1.param.wait"
;
char
value
[]
=
"aaa.bbb.ccc"
;
int
ret
=
SetParameter
(
key
,
value
);
...
...
@@ -349,7 +349,7 @@ HWTEST_F(SysparaModuleTest, Syspara_WaitParameter_test_009, TestSize.Level0)
HWTEST_F
(
SysparaModuleTest
,
Syspara_watcherParameter_test_010
,
TestSize
.
Level0
)
{
GTEST_LOG_
(
INFO
)
<<
"Syspara_watcherParameter_test_010 start"
;
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
for
(
int
i
=
0
;
i
<
THREAD_NUM
;
++
i
)
{
std
::
thread
(
TestParameterWatchChange
).
join
();
}
...
...
@@ -364,60 +364,43 @@ HWTEST_F(SysparaModuleTest, Syspara_GetParameter_test_011, TestSize.Level0)
char
key1
[]
=
"test.param.int1"
;
char
value1
[]
=
"0x111111"
;
int
setRet
=
SetParameter
(
key1
,
value1
);
EXPECT_EQ
(
setRet
,
0
);
int32_t
getRet
=
GetIntParameter
(
key1
,
0
);
EXPECT_EQ
(
getRet
,
1118481
);
//0x111111 decimalism result
uint32_t
uRet
=
GetUintParameter
(
key1
,
0
);
EXPECT_EQ
(
uRet
,
1118481
);
EXPECT_EQ
(
SetParameter
(
key1
,
value1
),
0
);
EXPECT_EQ
(
GetIntParameter
(
key1
,
0
),
1118481
);
// 0x111111 decimalism result
EXPECT_EQ
(
GetUintParameter
(
key1
,
0
),
1118481
);
char
key2
[]
=
"test.param.int2"
;
char
value2
[]
=
"-0x111111"
;
setRet
=
SetParameter
(
key2
,
value2
);
EXPECT_EQ
(
setRet
,
0
);
getRet
=
GetIntParameter
(
key2
,
0
);
EXPECT_EQ
(
getRet
,
-
1118481
);
//0x111111 decimalism result
EXPECT_EQ
(
SetParameter
(
key2
,
value2
),
0
);
EXPECT_EQ
(
GetIntParameter
(
key2
,
0
),
-
1118481
);
// 0x111111 decimalism result
uRet
=
GetUintParameter
(
key2
,
0
);
GetUintParameter
(
key2
,
0
);
char
key3
[]
=
"test.param.int3"
;
char
value3
[]
=
"9999999"
;
setRet
=
SetParameter
(
key3
,
value3
);
EXPECT_EQ
(
setRet
,
0
);
getRet
=
GetIntParameter
(
key3
,
0
);
EXPECT_EQ
(
getRet
,
9999999
);
//value3 int result
uRet
=
GetUintParameter
(
key3
,
0
);
EXPECT_EQ
(
uRet
,
9999999
);
//value3 uint result
EXPECT_EQ
(
SetParameter
(
key3
,
value3
),
0
);
EXPECT_EQ
(
GetIntParameter
(
key3
,
0
),
9999999
);
// value3 int result
EXPECT_EQ
(
GetUintParameter
(
key3
,
0
),
9999999
);
// value3 uint result
char
key4
[]
=
"test.param.int4"
;
char
value4
[]
=
"-9999999"
;
setRet
=
SetParameter
(
key4
,
value4
);
EXPECT_EQ
(
setRet
,
0
);
getRet
=
GetIntParameter
(
key4
,
0
);
EXPECT_EQ
(
getRet
,
-
9999999
);
//value4 int result
uRet
=
GetUintParameter
(
key4
,
0
);
EXPECT_EQ
(
uRet
,
0
);
EXPECT_EQ
(
SetParameter
(
key4
,
value4
),
0
);
EXPECT_EQ
(
GetIntParameter
(
key4
,
0
),
-
9999999
);
// value4 int result
EXPECT_EQ
(
GetUintParameter
(
key4
,
0
),
0
);
char
key5
[]
=
"test.param.int5"
;
char
value5
[]
=
"-2147483648"
;
//INT32_MIN
setRet
=
SetParameter
(
key5
,
value5
);
EXPECT_EQ
(
setRet
,
0
);
getRet
=
GetIntParameter
(
key5
,
0
);
EXPECT_EQ
(
getRet
,
0
);
char
value5
[]
=
"-2147483648"
;
// INT32_MIN
EXPECT_EQ
(
SetParameter
(
key5
,
value5
),
0
);
EXPECT_EQ
(
GetIntParameter
(
key5
,
0
),
0
);
char
key6
[]
=
"test.param.int6"
;
char
value6
[]
=
"2147483647"
;
//INT32_MAX
setRet
=
SetParameter
(
key6
,
value6
);
EXPECT_EQ
(
setRet
,
0
);
getRet
=
GetIntParameter
(
key6
,
0
);
EXPECT_EQ
(
getRet
,
0
);
char
value6
[]
=
"2147483647"
;
// INT32_MAX
EXPECT_EQ
(
SetParameter
(
key6
,
value6
),
0
);
EXPECT_EQ
(
GetIntParameter
(
key6
,
0
),
0
);
char
key7
[]
=
"test.param.uint7"
;
char
value7
[]
=
"4294967295"
;
//UINT32_MAX
setRet
=
SetParameter
(
key7
,
value7
);
EXPECT_EQ
(
setRet
,
0
);
uRet
=
GetUintParameter
(
key7
,
0
);
EXPECT_EQ
(
uRet
,
0
);
char
value7
[]
=
"4294967295"
;
// UINT32_MAX
EXPECT_EQ
(
SetParameter
(
key7
,
value7
),
0
);
EXPECT_EQ
(
GetUintParameter
(
key7
,
0
),
0
);
GTEST_LOG_
(
INFO
)
<<
"Syspara_GetParameter_test_011 end"
;
}
...
...
test/unittest/param/trigger_unittest.cpp
浏览文件 @
e65187e2
...
...
@@ -45,17 +45,17 @@ static int TestCmdExec(const TriggerNode *trigger, const char *content, uint32_t
PARAM_CHECK
(
trigger
!=
NULL
,
return
-
1
,
"Invalid trigger"
);
PARAM_LOGI
(
"DoTriggerExecute_ trigger type: %d %s"
,
trigger
->
type
,
GetTriggerName
(
trigger
));
PARAM_CHECK
(
trigger
->
type
<=
TRIGGER_UNKNOW
,
return
-
1
,
"Invalid trigger type %d"
,
trigger
->
type
);
CommandNode
*
cmd
=
GetNextCmdNode
(
(
JobNode
*
)
trigger
,
NULL
);
CommandNode
*
cmd
=
GetNextCmdNode
(
reinterpret_cast
<
const
JobNode
*>
(
trigger
)
,
NULL
);
while
(
cmd
!=
NULL
)
{
g_execCmdId
=
cmd
->
cmdKeyIndex
;
cmd
=
GetNextCmdNode
(
(
JobNode
*
)
trigger
,
cmd
);
cmd
=
GetNextCmdNode
(
reinterpret_cast
<
const
JobNode
*>
(
trigger
)
,
cmd
);
}
return
0
;
}
static
int
TestTriggerExecute
(
TriggerNode
*
trigger
,
const
char
*
content
,
uint32_t
size
)
{
JobNode
*
node
=
(
JobNode
*
)
trigger
;
JobNode
*
node
=
reinterpret_cast
<
JobNode
*>
(
trigger
)
;
int
ret
=
memcpy_s
(
g_matchTriggerName
,
(
int
)
sizeof
(
g_matchTriggerName
)
-
1
,
node
->
name
,
strlen
(
node
->
name
));
EXPECT_EQ
(
ret
,
0
);
g_matchTriggerName
[
strlen
(
node
->
name
)]
=
'\0'
;
...
...
@@ -319,7 +319,7 @@ public:
int
TestComputeCondition
(
const
char
*
condition
)
{
u_int32_t
size
=
strlen
(
condition
)
+
CONDITION_EXTEND_LEN
;
char
*
prefix
=
(
char
*
)
malloc
(
size
);
char
*
prefix
=
reinterpret_cast
<
char
*>
(
malloc
(
size
)
);
if
(
prefix
==
nullptr
)
{
printf
(
"prefix is null.
\n
"
);
return
-
1
;
...
...
@@ -428,7 +428,7 @@ public:
SystemWriteParam
(
param
,
value
);
RegisterTriggerExec
(
TRIGGER_PARAM
,
TestCmdExec
);
FreeTrigger
(
GetTriggerWorkSpace
(),
(
TriggerNode
*
)
trigger
);
FreeTrigger
(
GetTriggerWorkSpace
(),
reinterpret_cast
<
TriggerNode
*>
(
trigger
)
);
LE_DoAsyncEvent
(
LE_GetDefaultLoop
(),
GetTriggerWorkSpace
()
->
eventHandle
);
EXPECT_NE
(
g_execCmdId
,
cmdIndex
);
trigger
=
GetTriggerByName
(
GetTriggerWorkSpace
(),
triggerName
);
...
...
test/unittest/param/watcher_proxy_unittest.cpp
浏览文件 @
e65187e2
...
...
@@ -102,7 +102,7 @@ public:
uint32_t
msgSize
=
sizeof
(
ParamMessage
)
+
sizeof
(
ParamMsgContent
)
+
value
.
size
();
msgSize
=
PARAM_ALIGN
(
msgSize
);
// align
std
::
vector
<
char
>
buffer
(
msgSize
,
0
);
ParamMessage
*
msg
=
(
ParamMessage
*
)
buffer
.
data
(
);
ParamMessage
*
msg
=
reinterpret_cast
<
ParamMessage
*>
(
buffer
.
data
()
);
WATCHER_CHECK
(
msg
!=
NULL
,
return
-
1
,
"Invalid msg"
);
msg
->
type
=
MSG_NOTIFY_PARAM
;
msg
->
msgSize
=
msgSize
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录