Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
83d6df46
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看板
提交
83d6df46
编写于
4月 20, 2023
作者:
C
cheng_jinsong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add init trace
Signed-off-by:
N
cheng_jinsong
<
chengjinsong2@huawei.com
>
上级
ba5ad488
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
1474 addition
and
10 deletion
+1474
-10
services/etc/init.cfg
services/etc/init.cfg
+8
-1
services/modules/BUILD.gn
services/modules/BUILD.gn
+6
-1
services/modules/bootevent/bootevent.c
services/modules/bootevent/bootevent.c
+4
-5
services/modules/init_hook/init_hook.c
services/modules/init_hook/init_hook.c
+10
-0
services/modules/init_hook/param_hook.c
services/modules/init_hook/param_hook.c
+3
-0
services/modules/plugin_adapter.h
services/modules/plugin_adapter.h
+5
-2
services/modules/trace/BUILD.gn
services/modules/trace/BUILD.gn
+63
-0
services/modules/trace/init_trace.c
services/modules/trace/init_trace.c
+575
-0
services/modules/trace/init_trace.cfg
services/modules/trace/init_trace.cfg
+596
-0
services/modules/trace/init_trace_static.c
services/modules/trace/init_trace_static.c
+35
-0
services/param/manager/param_manager.c
services/param/manager/param_manager.c
+1
-1
test/unittest/BUILD.gn
test/unittest/BUILD.gn
+8
-0
test/unittest/modules/trace_unittest.cpp
test/unittest/modules/trace_unittest.cpp
+160
-0
未找到文件。
services/etc/init.cfg
浏览文件 @
83d6df46
...
...
@@ -26,7 +26,9 @@
"load_persist_params ",
"bootchart start",
"chown access_token access_token /dev/access_token_id",
"chmod 0666 /dev/access_token_id"
"chmod 0666 /dev/access_token_id",
"trigger init-hitrace",
"trigger init-trace"
]
}, {
"name" : "init",
...
...
@@ -191,6 +193,11 @@
"chmod 0773 /data/misc/trace",
"chmod 0775 /data/misc/wmtrace"
]
}, {
"name" : "init-trace",
"cmds" : [
"init_trace start"
]
}
]
}
services/modules/BUILD.gn
浏览文件 @
83d6df46
# Copyright (c) 202
0-2022
Huawei Device Co., Ltd.
# Copyright (c) 202
3
Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
...
...
@@ -27,6 +27,10 @@ group("static_modules") {
if (build_selinux) {
deps += [ "selinux:libselinuxadp_static" ]
}
deps += [
"trace:inittrace_cfg",
"trace:libinittrace_static",
]
}
}
...
...
@@ -35,6 +39,7 @@ group("modulesgroup") {
deps = [
"bootchart:bootchart",
"reboot:rebootmodule",
"trace:inittrace",
"udid:udidmodule",
]
if (build_seccomp) {
...
...
services/modules/bootevent/bootevent.c
浏览文件 @
83d6df46
...
...
@@ -189,7 +189,7 @@ static int BootEventTraversal(ListNode *node, void *root)
static
int
SaveServiceBootEvent
()
{
if
(
g_bootEventEnable
==
0
)
{
if
(
!
GetBootEventEnable
()
)
{
return
0
;
}
time_t
nowTime
=
time
(
NULL
);
...
...
@@ -408,13 +408,13 @@ static void SetServiceBootEventFork(SERVICE_INFO_CTX *serviceCtx)
return
;
}
static
int
GetBootEventFlag
(
const
HOOK_INFO
*
info
,
void
*
cookie
)
int
GetBootEventEnable
(
void
)
{
char
bootEventOpen
[
6
]
=
""
;
// 6 is length of bool value
uint32_t
len
=
sizeof
(
bootEventOpen
);
SystemReadParam
(
"persist.init.bootevent.enable"
,
bootEventOpen
,
&
len
);
if
(
strcmp
(
bootEventOpen
,
"true"
)
!
=
0
)
{
g_bootEventEnable
=
0
;
if
(
strcmp
(
bootEventOpen
,
"true"
)
==
0
||
strcmp
(
bootEventOpen
,
"1"
)
=
=
0
)
{
return
1
;
}
return
0
;
}
...
...
@@ -435,5 +435,4 @@ MODULE_CONSTRUCTOR(void)
InitAddClearServiceHook
(
ClearServiceBootEvent
);
InitAddServiceParseHook
(
ServiceParseBootEventHook
);
InitAddGlobalInitHook
(
0
,
ParamSetBootEventHook
);
InitAddPostPersistParamLoadHook
(
0
,
GetBootEventFlag
);
}
services/modules/init_hook/init_hook.c
浏览文件 @
83d6df46
...
...
@@ -245,6 +245,10 @@ static int BootCompleteCmd(const HOOK_INFO *hookInfo, void *executionContext)
HookMgrDel
(
GetBootStageHookMgr
(),
INIT_JOB_PARSE
,
NULL
);
// clear cmd
RemoveCmdExecutor
(
"loadSelinuxPolicy"
,
-
1
);
PluginExecCmdByName
(
"init_trace"
,
"stop"
);
// uninstall module of inittrace
InitModuleMgrUnInstall
(
"inittrace"
);
return
0
;
}
...
...
@@ -255,3 +259,9 @@ MODULE_CONSTRUCTOR(void)
// Depends on parameter service
InitAddPostPersistParamLoadHook
(
0
,
InitDebugHook
);
}
MODULE_DESTRUCTOR
(
void
)
{
const
char
*
clearBootEventArgv
[]
=
{
"bootevent"
};
PluginExecCmd
(
"clear"
,
ARRAY_LENGTH
(
clearBootEventArgv
),
clearBootEventArgv
);
}
services/modules/init_hook/param_hook.c
浏览文件 @
83d6df46
...
...
@@ -65,6 +65,7 @@ const ParamCmdInfo *GetServiceCtl(size_t *size)
{
"ohos.servicectrl.uninstall"
,
"uninstall"
,
"uninstall"
},
{
"ohos.servicectrl.clear"
,
"clear"
,
"clear"
},
{
"ohos.servicectrl.bootchart"
,
"bootchart"
,
"bootchart"
},
{
"ohos.servicectrl.init_trace"
,
"init_trace"
,
"init_trace"
},
{
"ohos.servicectrl.timer_start"
,
"timer_start"
,
"timer_start "
},
{
"ohos.servicectrl.timer_stop"
,
"timer_stop"
,
"timer_stop"
},
{
"ohos.servicectrl.cmd"
,
"cmd"
,
"initcmd"
},
...
...
@@ -93,6 +94,8 @@ const ParamCmdInfo *GetOtherSpecial(size_t *size)
static
const
ParamCmdInfo
other
[]
=
{
{
"bootevent."
,
"bootevent."
,
"bootevent"
},
{
"persist.init.debug."
,
"persist.init.debug."
,
"setloglevel"
},
// for hitrace start, need interrupt init trace
{
"debug.hitrace.enable.state"
,
"debug.hitrace.enable.state."
,
"init_trace"
},
};
*
size
=
ARRAY_LENGTH
(
other
);
return
other
;
...
...
services/modules/plugin_adapter.h
浏览文件 @
83d6df46
...
...
@@ -35,15 +35,16 @@
#define PLUGIN_LOGI(fmt, ...) STARTUP_LOGI(PLUGIN_DOMAIN, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGE(fmt, ...) STARTUP_LOGE(PLUGIN_DOMAIN, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGV(fmt, ...) STARTUP_LOGV(PLUGIN_DOMAIN, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_LOGW(fmt, ...) STARTUP_LOGW(PLUGIN_DOMAIN, PLUGIN_LABEL, fmt, ##__VA_ARGS__)
#define PLUGIN_CHECK(ret, exper, ...) \
if
(
!
(
ret
))
{
\
PLUGIN_LOGE
(
__VA_ARGS__
);
\
exper
;
\
}
#define PLUGIN_ONLY_
CHECK(ret, exper
, ...) \
#define PLUGIN_ONLY_
LOG(ret
, ...) \
if
(
!
(
ret
))
{
\
exper
;
\
PLUGIN_LOGE
(
__VA_ARGS__
)
;
\
}
#define HOOKID(name) HOOK_ID_##name
...
...
@@ -53,4 +54,6 @@ enum HOOK_ID_ {
HOOKID
(
BOOTEVENT
),
HOOKID
(
BOOTEVENT_MAX
)
=
HOOK_ID_BOOTEVENT
+
10
,
};
int
GetBootEventEnable
(
void
);
#endif
services/modules/trace/BUILD.gn
0 → 100644
浏览文件 @
83d6df46
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//base/startup/init/begetd.gni")
import("//build/ohos.gni")
comm_include = [
".",
"..",
"../../include",
"../../include/param",
]
ohos_shared_library("inittrace") {
sources = [ "init_trace.c" ]
include_dirs = comm_include
include_dirs += [ "//third_party/zlib" ]
deps = [
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/cJSON:cjson",
"//third_party/zlib:libz",
]
external_deps = [ "init:libinit_module_engine" ]
part_name = "init"
subsystem_name = "startup"
if (target_cpu == "arm64") {
module_install_dir = "lib64/init"
} else {
module_install_dir = "lib/init"
}
}
config("inittrace_static_config") {
include_dirs = comm_include
}
ohos_prebuilt_etc("inittrace_cfg") {
source = "init_trace.cfg"
part_name = "init"
subsystem_name = "startup"
}
ohos_source_set("libinittrace_static") {
sources = [ "init_trace_static.c" ]
include_dirs = comm_include
public_configs = [ ":inittrace_static_config" ]
public_configs += [ "../../../interfaces/innerkits/init_module_engine:init_module_engine_exported_config" ]
part_name = "init"
subsystem_name = "startup"
}
services/modules/trace/init_trace.c
0 → 100644
浏览文件 @
83d6df46
此差异已折叠。
点击以展开。
services/modules/trace/init_trace.cfg
0 → 100644
浏览文件 @
83d6df46
{
"compress" : false,
"KERNEL" : [
{
"name" : "disk",
"description" : "Disk I/O",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/f2fs/f2fs_sync_file_enter/enable",
"events/f2fs/f2fs_sync_file_exit/enable",
"events/f2fs/f2fs_write_begin/enable",
"events/f2fs/f2fs_write_end/enable",
"events/ext4/ext4_da_write_begin/enable",
"events/ext4/ext4_da_write_end/enable",
"events/ext4/ext4_sync_file_enter/enable",
"events/ext4/ext4_sync_file_exit/enable",
"events/block/block_rq_issue/enable",
"events/block/block_rq_complete/enable"
]
},
{
"name" : "mmc",
"description" : "eMMC commands",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/mmc/enable"
]
},
{
"name" : "zbinder",
"description" : "OpenHarmony binder communication",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/zbinder/enable"
]
},
{
"name" : "ufs",
"description" : "UFS commands",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/ufs/enable"
]
},
{
"name" : "irq",
"description" : "IRQ Events",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/irq/enable",
"events/ipi/enable"
]
},
{
"name" : "irqoff",
"description" : "IRQ-disabled code section tracing",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/preemptirq/irq_enable/enable",
"events/preemptirq/irq_disable/enable"
]
},
{
"name" : "i2c",
"description" : "I2C Events",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/i2c/enable" ,
"events/i2c/i2c_read/enable" ,
"events/i2c/i2c_write/enable" ,
"events/i2c/i2c_result/enable" ,
"events/i2c/i2c_reply/enable" ,
"events/i2c/smbus_read/enable" ,
"events/i2c/smbus_write/enable" ,
"events/i2c/smbus_result/enable" ,
"events/i2c/smbus_reply/enable"
]
},
{
"name" : "regulators",
"description" : "Voltage and Current Regulators",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/regulator/enable"
]
},
{
"name" : "membus",
"description" : "Memory Bus Utilization",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/memory_bus/enable"
]
},
{
"name" : "freq",
"description" : "CPU Frequency",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/power/cpu_frequency/enable",
"events/power/clock_set_rate/enable",
"events/power/clock_disable/enable",
"events/power/clock_enable/enable",
"events/clk/clk_set_rate/enable",
"events/clk/clk_disable/enable",
"events/clk/clk_enable/enable",
"events/power/cpu_frequency_limits/enable"
]
},
{
"name" : "idle",
"description" : "CPU Idle",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/power/cpu_idle/enable"
]
},
{
"name" : "load",
"description" : "CPU Load",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/cpufreq_interactive/enable"
]
},
{
"name" : "sched",
"description" : "CPU Scheduling",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/sched/sched_switch/enable",
"events/sched/sched_wakeup/enable",
"events/sched/sched_wakeup_new/enable",
"events/sched/sched_waking/enable",
"events/sched/sched_blocked_reason/enable",
"events/sched/sched_pi_setprio/enable",
"events/sched/sched_process_exit/enable",
"events/cgroup/enable",
"events/oom/oom_score_adj_update/enable",
"events/task/task_rename/enable",
"events/task/task_newtask/enable"
]
},
{
"name" : "preemptoff",
"description" : "Preempt-disabled code section tracing",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/preemptirq/preempt_enable/enable",
"events/preemptirq/preempt_disable/enable"
]
},
{
"name" : "binder",
"description" : "Binder kernel Info",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/binder/binder_transaction/enable",
"events/binder/binder_transaction_received/enable",
"events/binder/binder_transaction_alloc_buf/enable",
"events/binder/binder_set_priority/enable",
"events/binder/binder_lock/enable",
"events/binder/binder_locked/enable",
"events/binder/binder_unlock/enable"
]
},
{
"name" : "sync",
"description" : "Synchronization",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/dma_fence/enable"
]
},
{
"name" : "workq",
"description" : "Kernel Workqueues",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/workqueue/enable"
]
},
{
"name" : "memreclaim",
"description" : "Kernel Memory Reclaim",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/vmscan/mm_vmscan_direct_reclaim_begin/enable",
"events/vmscan/mm_vmscan_direct_reclaim_end/enable",
"events/vmscan/mm_vmscan_kswapd_wake/enable",
"events/vmscan/mm_vmscan_kswapd_sleep/enable",
"events/lowmemorykiller/enable"
]
},
{
"name" : "pagecache",
"description" : "Page cache",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/filemap/enable"
]
},
{
"name" : "memory",
"description" : "memory",
"tag" : 0,
"type" : "KERNEL",
"sys-files" : [
"events/kmem/rss_stat/enable",
"events/kmem/ion_heap_grow/enable",
"events/kmem/ion_heap_shrink/enable"
]
}
],
"USER" : [
{
"name" : "ohos",
"description" : "OpenHarmony",
"tag" : 30,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "ability",
"description" : "Ability Manager",
"tag" : 31,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "zcamera",
"description" : "OpenHarmony Camera Module",
"tag" : 32,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "zmedia",
"description" : "OpenHarmony Media Module",
"tag" : 33,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "zimage",
"description" : "OpenHarmony Image Module",
"tag" : 34,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "zaudio",
"description" : "OpenHarmony Audio Module",
"tag" : 35,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "distributeddatamgr",
"description" : "Distributed Data Manager",
"tag" : 36,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "mdfs",
"description" : "Mobile Distributed File System",
"tag" : 37,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "graphic",
"description" : "Graphic Module",
"tag" : 38,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "ace",
"description" : "ACE development framework",
"tag" : 39,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "notification",
"description" : "Notification Module",
"tag" : 40,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "misc",
"description" : "misc Module",
"tag" : 41,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "multimodalinput",
"description" : "Multimodal Input Module",
"tag" : 42,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "sensors",
"description" : "Sensors Module",
"tag" : 43,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "msdp",
"description" : "Multimodal Sensor Data Platform",
"tag" : 44,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dsoftbus",
"description" : "Distributed Softbus",
"tag" : 45,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "rpc",
"description" : "RPC and IPC",
"tag" : 46,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "ark",
"description" : "ARK Module",
"tag" : 47,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "window",
"description" : "Window Manager",
"tag" : 48,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "accessibility",
"description" : "Accessibility Manager",
"tag" : 61,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "account",
"description" : "Account Manager",
"tag" : 49,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dhfwk",
"description" : "Distributed Hardware FWK",
"tag" : 52,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dscreen",
"description" : "Distributed Screen",
"tag" : 50,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "daudio",
"description" : "Distributed Audio",
"tag" : 27,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dinput",
"description" : "Distributed Input",
"tag" : 59,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "devicemanager",
"description" : "Device Manager",
"tag" : 54,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "samgr",
"description" : "samgr",
"tag" : 55,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dsched",
"description" : "Distributed Schedule",
"tag" : 57,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "deviceprofile",
"description" : "Device Profile",
"tag" : 58,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "huks",
"description" : "Universal KeyStore",
"tag" : 25,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dlpcre",
"description" : "Dlp Credential Service",
"tag" : 21,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "app",
"description" : "APP Module",
"tag" : 62,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dcamera",
"description" : "Distributed Camera",
"tag" : 51,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "gresource",
"description" : "Global Resource Manager",
"tag" : 53,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "power",
"description" : "power Manager",
"tag" : 56,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "bluetooth",
"description" : "communicatio bluetooth",
"tag" : 60,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "filemanagement",
"description" : "filemanagement",
"tag" : 29,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "dslm",
"description" : "device security level",
"tag" : 28,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "useriam",
"description" : "useriam",
"tag" : 26,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "nweb",
"description" : "nweb",
"tag" : 24,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "net",
"description" : "net",
"tag" : 23,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "accesscontrol",
"description" : "Access Control Module",
"tag" : 22,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "interconn",
"description" : "Interconnection subsystem",
"tag" : 20,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "usb",
"description" : "usb subsystem",
"tag" : 19,
"type" : "USER",
"sys-files" : [
]
},
{
"name" : "hdf",
"description" : "hdf subsystem",
"tag" : 18,
"type" : "USER",
"sys-files" : [
]
}
]
}
services/modules/trace/init_trace_static.c
0 → 100644
浏览文件 @
83d6df46
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <string.h>
#include "init_module_engine.h"
#include "plugin_adapter.h"
static
int
InitTraceEarlyHook
(
const
HOOK_INFO
*
info
,
void
*
cookie
)
{
if
(
GetBootEventEnable
())
{
PLUGIN_LOGI
(
"init trace enabled."
);
#ifndef STARTUP_INIT_TEST
InitModuleMgrInstall
(
"inittrace"
);
#endif
return
0
;
}
return
0
;
}
MODULE_CONSTRUCTOR
(
void
)
{
// Depends on parameter service
InitAddPostPersistParamLoadHook
(
0
,
InitTraceEarlyHook
);
}
services/param/manager/param_manager.c
浏览文件 @
83d6df46
...
...
@@ -336,7 +336,7 @@ INIT_LOCAL_API int GetServiceCtrlInfo(const char *name, const char *value, Servi
const
ParamCmdInfo
*
other
=
GetOtherSpecial
(
&
size
);
for
(
size_t
i
=
0
;
i
<
size
;
i
++
)
{
if
(
strncmp
(
name
,
other
[
i
].
name
,
strlen
(
other
[
i
].
name
))
==
0
)
{
return
CreateCtrlInfo
(
ctrlInfo
,
other
[
i
].
cmd
,
strlen
(
other
[
i
].
nam
e
),
0
,
"%s.%s"
,
name
,
value
);
return
CreateCtrlInfo
(
ctrlInfo
,
other
[
i
].
cmd
,
strlen
(
other
[
i
].
replac
e
),
0
,
"%s.%s"
,
name
,
value
);
}
}
return
0
;
...
...
test/unittest/BUILD.gn
浏览文件 @
83d6df46
...
...
@@ -255,6 +255,7 @@ ohos_unittest("init_unittest") {
"//utils/system/safwk/native/include",
"//third_party/bounds_checking_function/include",
"//third_party/cJSON",
"//third_party/zlib",
"//base/security/access_token/interfaces/innerkits/token_setproc/include",
"//base/security/access_token/interfaces/innerkits/nativetoken/include",
"//base/startup/init/services/sandbox/include",
...
...
@@ -271,6 +272,7 @@ ohos_unittest("init_unittest") {
"//third_party/googletest:gmock",
"//third_party/googletest:gtest",
"//third_party/mbedtls:mbedtls_shared",
"//third_party/zlib:libz",
]
defines = [
...
...
@@ -371,5 +373,11 @@ ohos_unittest("init_unittest") {
defines += [ "PARAM_FEATURE_DEVICEINFO" ]
}
sources += [
"//base/startup/init/services/modules/trace/init_trace.c",
"//base/startup/init/services/modules/trace/init_trace_static.c",
"//base/startup/init/test/unittest/modules/trace_unittest.cpp",
]
cflags_cc = [ "-fexceptions" ]
}
test/unittest/modules/trace_unittest.cpp
0 → 100644
浏览文件 @
83d6df46
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bootstage.h"
#include "init_utils.h"
#include "init_cmds.h"
#include "init_cmdexecutor.h"
#include "param_stub.h"
#include "securec.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
init_ut
{
static
const
char
*
g_content
=
"
\"
KERNEL
\"
: ["
"{"
"
\"
name
\"
:
\"
disk
\"
,"
"
\"
description
\"
:
\"
Disk I/O
\"
,"
"
\"
tag
\"
: 0,"
"
\"
type
\"
:
\"
KERNEL
\"
,"
"
\"
sys-files
\"
: ["
"
\"
events/f2fs/f2fs_sync_file_enter/enable
\"
,"
"
\"
events/f2fs/f2fs_sync_file_exit/enable
\"
,"
"
\"
events/f2fs/f2fs_write_begin/enable
\"
,"
"
\"
events/f2fs/f2fs_write_end/enable
\"
,"
"
\"
events/ext4/ext4_da_write_begin/enable
\"
,"
"
\"
events/ext4/ext4_da_write_end/enable
\"
,"
"
\"
events/ext4/ext4_sync_file_enter/enable
\"
,"
"
\"
events/ext4/ext4_sync_file_exit/enable
\"
,"
"
\"
events/block/block_rq_issue/enable
\"
,"
"
\"
events/block/block_rq_complete/enable
\"
"
"]"
"},"
"{"
"
\"
name
\"
:
\"
mmc
\"
,"
"
\"
description
\"
:
\"
eMMC commands
\"
,"
"
\"
tag
\"
: 0,"
"
\"
type
\"
:
\"
KERNEL
\"
,"
"
\"
sys-files
\"
: ["
"
\"
events/mmc/enable
\"
"
"]"
"}"
"],"
"
\"
USER
\"
: ["
"{"
"
\"
name
\"
:
\"
ohos
\"
,"
"
\"
description
\"
:
\"
OpenHarmony
\"
,"
"
\"
tag
\"
: 30,"
"
\"
type
\"
:
\"
USER
\"
,"
"
\"
sys-files
\"
: ["
"]"
"},"
"{"
"
\"
name
\"
:
\"
ability
\"
,"
"
\"
description
\"
:
\"
Ability Manager
\"
,"
"
\"
tag
\"
: 31,"
"
\"
type
\"
:
\"
USER
\"
,"
"
\"
sys-files
\"
: ["
"]"
"},"
"{"
"
\"
name
\"
:
\"
usb
\"
,"
"
\"
description
\"
:
\"
usb subsystem
\"
,"
"
\"
tag
\"
: 19,"
"
\"
type
\"
:
\"
USER
\"
,"
"
\"
sys-files
\"
: ["
"]"
"}"
"]"
"}"
;
void
CreateInitTraceConfig
(
int
compress
)
{
std
::
string
config
=
"{
\"
compress
\"
: "
;
if
(
!
compress
)
{
config
+=
"false,"
;
}
else
{
config
+=
"true, "
;
}
config
+=
g_content
;
// create trace cfg
CreateTestFile
(
STARTUP_INIT_UT_PATH
"/system/etc/init_trace.cfg"
,
config
.
c_str
());
}
class
TraceUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
()
{};
void
TearDown
()
{};
};
HWTEST_F
(
TraceUnitTest
,
TraceTest_001
,
TestSize
.
Level1
)
{
// open switch for trace
uint32_t
dataIndex
=
0
;
WriteParam
(
"persist.init.bootevent.enable"
,
"true"
,
&
dataIndex
,
0
);
HookMgrExecute
(
GetBootStageHookMgr
(),
INIT_POST_PERSIST_PARAM_LOAD
,
NULL
,
NULL
);
// close switch for trace
WriteParam
(
"persist.init.bootevent.enable"
,
"false"
,
&
dataIndex
,
0
);
HookMgrExecute
(
GetBootStageHookMgr
(),
INIT_POST_PERSIST_PARAM_LOAD
,
NULL
,
NULL
);
}
HWTEST_F
(
TraceUnitTest
,
TraceTest_002
,
TestSize
.
Level1
)
{
CreateInitTraceConfig
(
1
);
// start trace
PluginExecCmdByName
(
"init_trace"
,
"start"
);
// for run 1 s
sleep
(
1
);
// stop trace
PluginExecCmdByName
(
"init_trace"
,
"stop"
);
}
HWTEST_F
(
TraceUnitTest
,
TraceTest_003
,
TestSize
.
Level1
)
{
CreateInitTraceConfig
(
0
);
// start trace
PluginExecCmdByName
(
"init_trace"
,
"start"
);
// for run 1 s
sleep
(
1
);
// stop trace
PluginExecCmdByName
(
"init_trace"
,
"stop"
);
}
HWTEST_F
(
TraceUnitTest
,
TraceTest_004
,
TestSize
.
Level1
)
{
std
::
string
cmdArgs
=
"/system/etc/init_trace.cfg "
;
cmdArgs
+=
STARTUP_INIT_UT_PATH
"/system/etc/init_trace.cfg"
;
DoCmdByName
(
"copy "
,
cmdArgs
.
c_str
());
// start trace
PluginExecCmdByName
(
"init_trace"
,
"start"
);
// for run 1 s
sleep
(
1
);
// stop trace
PluginExecCmdByName
(
"init_trace"
,
"stop"
);
}
HWTEST_F
(
TraceUnitTest
,
TraceTest_005
,
TestSize
.
Level1
)
{
// start trace
PluginExecCmdByName
(
"init_trace"
,
"start"
);
// for run 1 s
sleep
(
1
);
// interrupt trace
PluginExecCmdByName
(
"init_trace"
,
"1"
);
}
}
// namespace init_ut
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录