!5 update hiperf

Merge pull request !5 from chuxuezhe11/master
This commit is contained in:
openharmony_sig_ci 2021-12-25 10:19:49 +00:00 committed by Gitee
commit 87ecacbb21
14 changed files with 212 additions and 198 deletions

229
BUILD.gn
View File

@ -14,8 +14,7 @@
import("//build/ohos.gni")
import("//developtools/hiperf/hiperf.gni")
function_disable_define = [
]
function_disable_define = []
config("hiperf_inner_config") {
visibility = [ ":*" ]
@ -23,32 +22,40 @@ config("hiperf_inner_config") {
cflags = code_check_flag
defines = function_disable_define
if(hiperf_code_analyze && is_ohos) {
if (hiperf_code_analyze && is_ohos) {
cflags += code_analyze_flag
cflags -= [ "-Werror" ]
}
if(is_mingw) {
if (is_mingw) {
# lld: error: unable to find library -latomic
# lld: error: unable to find library -ldl
# lld: error: unable to find library -lrt
ldflags += [ "-Wl,--whole-archive", "-lpthread", "-Wl,--no-whole-archive"]
} else if(is_linux) {
ldflags += [ "-Wl,--whole-archive", "-lpthread", "-latomic", "-ldl", "-lrt", "-Wl,--no-whole-archive"]
ldflags += [
"-Wl,--whole-archive",
"-lpthread",
"-Wl,--no-whole-archive",
]
} else if (is_linux) {
ldflags += [
"-Wl,--whole-archive",
"-lpthread",
"-latomic",
"-ldl",
"-lrt",
"-Wl,--no-whole-archive",
]
}
include_dirs = [
"${hiperf_path}/include",
]
include_dirs = [ "${hiperf_path}/include" ]
# debug link
# ldflags += [ "-v"]
if(hiperf_debug) {
if (hiperf_debug) {
defines += [
"HIPERF_DEBUG",
"HIPERF_DEBUG_PRINTF", # if u want to see printf in the log ?
"HIPERF_DEBUG_PRINTF", # if u want to see printf in the log ?
]
} else {
# some value just for debug, but also can be opt by clang ,don't as error
@ -56,37 +63,41 @@ config("hiperf_inner_config") {
cflags += [ "-Wno-unused-variable" ]
}
if(hiperf_check_time) {
defines += [ "HIPERF_DEBUG_TIME", ]
if (hiperf_check_time) {
defines += [ "HIPERF_DEBUG_TIME" ]
}
cflags += [ "-std=c++17" ]
if(is_linux) {
cflags += [ "-g" ] # we need debug info when it crash.
if (is_linux) {
cflags += [ "-g" ] # we need debug info when it crash.
}
defines += [ "is_mingw=${is_mingw}" ]
defines += [ "is_linux=${is_linux}" ]
defines += [ "is_ohos=${is_ohos}" ]
defines += [ "is_double_framework=${is_double_framework}" ]
if(hiperf_target_host) {
if (hiperf_target_host) {
defines += [ "target_cpu_${host_cpu}" ]
} else {
defines += [ "target_cpu_${target_cpu}" ]
}
if(is_mingw) {
if (is_mingw) {
cflags += [ "-includeMingW64Fix.h" ]
cflags += [ "-Wno-inconsistent-dllimport" ] # in mingw some sec api will overwrite by utilsecurec
defines +=[ "WIN32_LEAN_AND_MEAN" ]
cflags += [ "-Wno-inconsistent-dllimport" ] # in mingw some sec api will
# overwrite by utilsecurec
defines += [ "WIN32_LEAN_AND_MEAN" ]
include_dirs += [
"${hiperf_path}/include/nonlinux/",
"//third_party/Linux_Kernel/include/uapi"
"//third_party/Linux_Kernel/include/uapi",
]
}
if(hiperf_test_coverage && is_ohos) {
cflags += [ "-fprofile-arcs", "-ftest-coverage" ]
if (hiperf_test_coverage && is_ohos) {
cflags += [
"-fprofile-arcs",
"-ftest-coverage",
]
ldflags += [ "--coverage" ]
}
}
@ -117,7 +128,7 @@ sources_platform_common = [
"./src/callstack.cpp",
]
if(hiperf_debug) {
if (hiperf_debug) {
sources_platform_common += [
"./src/debug_logger.cpp",
"./src/option_debug.cpp",
@ -135,39 +146,41 @@ sources_platform_linux = [
]
common_deps = [
"//utils/native/base:utilsecurec",
"//third_party/zlib:libz",
":support_elf",
":support_protobuf",
":support_libunwind"
":support_elf",
":support_libunwind",
":support_protobuf",
"//third_party/zlib:libz",
"//utils/native/base:utilsecurec",
]
if(!hiperf_use_libunwind) {
common_deps -= [ ":support_libunwind" ]
if (!hiperf_use_libunwind) {
common_deps -= [ ":support_libunwind" ]
}
if (is_ohos) {
common_deps += [ "//utils/native/base:utilsecurec_shared" ]
common_deps -= [ "//utils/native/base:utilsecurec" ]
common_deps += [ "//utils/native/base:utilsecurec_shared" ]
common_deps -= [ "//utils/native/base:utilsecurec" ]
}
if(hiperf_target_static) {
if (hiperf_target_static) {
common_deps -= [ ":support_protobuf" ]
}
common_configs = [
":hiperf_inner_config",
"//utils/native/base:utils_config",
"//third_party/googletest:gtest_config",
":hiperf_inner_config",
"//utils/native/base:utils_config",
"//third_party/googletest:gtest_config",
]
config("hiperf_syspara_config") {
defines = [ "CONFIG_HAS_SYSPARA" ]
}
if(is_ohos && hiperf_use_syspara) {
if (is_ohos && hiperf_use_syspara) {
common_configs += [ ":hiperf_syspara_config" ]
common_deps += [ "//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara" ]
common_deps += [
"//base/startup/syspara_lite/interfaces/innerkits/native/syspara:syspara",
]
}
ohos_source_set("hiperf_platform_common") {
@ -176,18 +189,16 @@ ohos_source_set("hiperf_platform_common") {
public_configs = common_configs
defines = []
if(is_ohos) {
external_deps = [
"hiviewdfx_hilog_native:libhilog",
]
if (is_ohos) {
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
} else {
defines += [ "CONFIG_NO_HILOG" ]
defines += [ "CONFIG_NO_HILOG" ]
}
sources = sources_platform_common
}
config("platform_linux_config") {
defines = ["SUPPORT_PERF_EVENT"]
defines = [ "SUPPORT_PERF_EVENT" ]
}
ohos_source_set("hiperf_platform_linux") {
@ -207,10 +218,8 @@ config("unwind_config") {
ohos_source_set("support_libunwind") {
public_configs = common_configs
public_configs += [
":unwind_config",
]
if(hiperf_target_host) {
public_configs += [ ":unwind_config" ]
if (hiperf_target_host) {
public_deps = [ "//third_party/libunwind:unwind_source_${host_cpu}" ]
} else {
public_deps = [ "//third_party/libunwind:unwind_source_${target_cpu}" ]
@ -220,32 +229,29 @@ ohos_source_set("support_libunwind") {
config("elf_config") {
}
ohos_source_set("support_elf") {
public_configs = common_configs
public_configs += [
":elf_config",
]
public_configs = common_configs
public_configs += [ ":elf_config" ]
}
config("protobuf_config") {
defines = [ "HAVE_PROTOBUF=1" ]
cflags = [ "-Wno-unused-parameter" ] # proto buf head build error
cflags = [ "-Wno-unused-parameter" ] # proto buf head build error
include_dirs = [
"//third_party/protobuf/src",
"//third_party/protobuf/src/google",
"//third_party/protobuf/src/google/protobuf"
"//third_party/protobuf/src/google/protobuf",
]
}
ohos_source_set("support_protobuf") {
use_exceptions = true
#protobuf
public_configs = common_configs
public_configs += [
":protobuf_config",
]
public_configs += [ ":protobuf_config" ]
public_deps = [
":proto_file_cpp",
"//utils/native/base:utilsecurec"
"//utils/native/base:utilsecurec",
]
sources = [ "./src/report_protobuf_file.cpp" ]
@ -254,7 +260,7 @@ ohos_source_set("support_protobuf") {
#protobuf {
proto_file_defines = [
# add your proto file here
"report_sample"
"report_sample",
]
proto_base_dir = "proto"
@ -268,26 +274,22 @@ foreach(proto_file, proto_file_defines) {
"$proto_out_dir" + "/" + "$proto_file.pb.h",
"$proto_out_dir" + "/" + "$proto_file.pb.cc",
]
proto_file_sources += [
"$proto_base_dir" + "/" + "$proto_file.proto"
]
proto_file_sources += [ "$proto_base_dir" + "/" + "$proto_file.proto" ]
}
# this is so bad , but someone config the protoc's subsystem_name
# the better way is build system need provider host tools path or prebuild tools path
if(is_double_framework) {
protoc_subsystem_out_path = "developtools/profiler"
} else {
protoc_subsystem_out_path = "developtools/profiler"
}
if(default_toolchain == current_toolchain) {
protoc_subsystem_out_path = "developtools/profiler"
if (default_toolchain == current_toolchain) {
#if target build
host_out_path = "/" + get_label_info(host_toolchain,"name")
host_out_path = "/" + get_label_info(host_toolchain, "name")
} else {
#if host build (for some linke mingw)
host_out_path = "/../" + get_label_info(host_toolchain,"name")
host_out_path = "/../" + get_label_info(host_toolchain, "name")
}
host_protoc_path = root_out_dir + host_out_path + "/" + protoc_subsystem_out_path + "/protoc"
host_protoc_path =
root_out_dir + host_out_path + "/" + protoc_subsystem_out_path + "/protoc"
action("hiperf_host_build_proto") {
deps = [ "//third_party/protobuf:protoc(//build/toolchain/linux:clang_x64)" ]
@ -297,8 +299,14 @@ action("hiperf_host_build_proto") {
script = "proto/build_proto.sh"
args += [ rebase_path(host_protoc_path) ]
args += [ "--proto_path", rebase_path(proto_base_dir) ]
args += [ "--cpp_out",rebase_path(proto_out_dir)]
args += [
"--proto_path",
rebase_path(proto_base_dir),
]
args += [
"--cpp_out",
rebase_path(proto_out_dir),
]
foreach(proto_file_source, proto_file_sources) {
#tell gn to check which files as source time
@ -308,20 +316,19 @@ action("hiperf_host_build_proto") {
}
config("proto_file_cpp_config") {
include_dirs = [
proto_out_dir
]
include_dirs = [ proto_out_dir ]
}
ohos_source_set("proto_file_cpp") {
cflags = []
deps = [ ":hiperf_host_build_proto"]
deps = [ ":hiperf_host_build_proto" ]
public_deps = [ "//third_party/protobuf:protobuf_lite_static" ]
sources = proto_file_codegen
public_configs = [ ":proto_file_cpp_config" ]
}
#protobuf }
ohos_executable("hiperf") {
@ -332,11 +339,11 @@ ohos_executable("hiperf") {
":hiperf_platform_linux",
]
if(hiperf_target_static) {
if (hiperf_target_static) {
static_link = true
}
if(is_linux || is_mingw) {
if (is_linux || is_mingw) {
# ld.lld: error: attempted static link of dynamic object hiviewdfx/hilog_native/libhilog.so
static_link = true
}
@ -397,10 +404,10 @@ ohos_source_set("hiperf_code_analyze") {
}
group("hiperf_target") {
if(hiperf_target_host) {
if (hiperf_target_host) {
deps = [ ":hiperf(${host_toolchain})" ]
} else {
deps = [ ":hiperf"]
deps = [ ":hiperf" ]
}
}
@ -410,66 +417,54 @@ group("hiperf_test_target") {
}
group("hiperf_target_all") {
if(is_double_framework) {
deps = [
":hiperf_target"
]
if (is_double_framework) {
deps = [ ":hiperf_target" ]
} else {
deps = [
":hiperf_target",
":hiperf_host(//build/toolchain/linux:clang_x64)", # host linux
":hiperf_host(//build/toolchain/mingw:mingw_x86_64)", # host mingw
":hiperf_host_lib_demo(//build/toolchain/linux:clang_x64)", # host linux
":hiperf_host_lib(//build/toolchain/linux:clang_x64)", # host linux
":hiperf_host_lib(//build/toolchain/mingw:mingw_x86_64)", # host mingw
":hiperf_host(//build/toolchain/linux:clang_x64)", # host linux
":hiperf_host(//build/toolchain/mingw:mingw_x86_64)", # host mingw
":hiperf_host_lib(//build/toolchain/linux:clang_x64)", # host linux
":hiperf_host_lib(//build/toolchain/mingw:mingw_x86_64)", # host mingw
":hiperf_host_lib_demo(//build/toolchain/linux:clang_x64)", # host linux
":hiperf_host_python",
"interfaces/innerkits/native:hiperf_client", # c++ api
]
if(is_ohos) {
deps += [ "interfaces/kits/js/napi:hiperf_client_napi", ] # js api
":hiperf_target",
"interfaces/innerkits/native:hiperf_client", # c++ api
]
if (is_ohos) {
deps += [ "interfaces/kits/js/napi:hiperf_client_napi" ] # js api
}
}
}
group("hiperf_demo") {
if(hiperf_target_host) {
deps = [
"demo/cpp:hiperf_demo(${host_toolchain})",
]
if (hiperf_target_host) {
deps = [ "demo/cpp:hiperf_demo(${host_toolchain})" ]
} else {
deps = [
"demo/cpp:hiperf_demo",
]
deps = [ "demo/cpp:hiperf_demo" ]
}
}
group("hiperf_example_cmd") {
if(hiperf_target_host) {
deps = [
"demo/cpp:hiperf_example_cmd(${host_toolchain})",
]
if (hiperf_target_host) {
deps = [ "demo/cpp:hiperf_example_cmd(${host_toolchain})" ]
} else {
deps = [
"demo/cpp:hiperf_example_cmd",
]
deps = [ "demo/cpp:hiperf_example_cmd" ]
}
}
group("hiperf_all") {
testonly = true
if (hiperf_code_analyze) {
deps = [
":hiperf_code_analyze"
]
deps = [ ":hiperf_code_analyze" ]
} else {
deps = [
":hiperf_target_all",
":hiperf_example_cmd",
":hiperf_target_all",
]
if(!is_double_framework) {
if (!is_double_framework) {
deps += [
":hiperf_demo",
":hiperf_test_target",
":hiperf_demo"
]
}
}

View File

@ -1,3 +1,18 @@
/*
* Copyright (c) 2021 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.
*/
export default {
onCreate() {
console.info("Application onCreate");

View File

@ -20,6 +20,7 @@ export default {
clickTimes: 0,
total: 20,
output: '',
sleepTicks: 0,
},
onInit() {
@ -28,8 +29,8 @@ export default {
sleep(delay) {
let start = (new Date()).getTime();
while ((new Date()).getTime() - start < delay) {
continue;
while (((new Date()).getTime() - start) < delay) {
this.sleepTicks++;
}
},
@ -116,7 +117,7 @@ export default {
return;
}
hiperf.setup("/data/accounts/account_0/appdata/com.example.hiperfdemo/files");
result = hiperf.setup("/data/accounts/account_0/appdata/com.example.hiperfdemo/files");
this.output += ('Setup: ' + result+ '\n');
if(!result) {

View File

@ -1,3 +1,18 @@
/*
* Copyright (c) 2021 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 router from '@system.router'
export default {

View File

@ -18,16 +18,16 @@ innerkits_path = "${hiperf_path}/interfaces/innerkits"
kits_path = "${hiperf_path}/interfaces/kits"
declare_args() {
hiperf_target_host=false
hiperf_target_static=false
hiperf_test_coverage=false
hiperf_sanitize=false
hiperf_check_time=false
hiperf_use_libunwind=true
hiperf_debug=true
hiperf_code_analyze=false
hiperf_use_syspara=true
have_common_tools=true
hiperf_target_host = false
hiperf_target_static = false
hiperf_test_coverage = false
hiperf_sanitize = false
hiperf_check_time = false
hiperf_use_libunwind = true
hiperf_debug = true
hiperf_code_analyze = false
hiperf_use_syspara = true
have_common_tools = true
}
code_check_flag = [
@ -63,10 +63,9 @@ code_analyze_flag = [
"-analyzer-checker=unix",
]
if(is_double_framework && target_cpu == "arm64") {
# format specifies type 'long' but the argument has type
# 'std::__1::chrono::duration<long long, std::__1::ratio<1, 1000> >::rep' (aka 'long long')
# [-Werror,-Wformat]
code_check_flag += ["-Wno-format"]
}
if (is_double_framework && target_cpu == "arm64") {
# format specifies type 'long' but the argument has type
# 'std::__1::chrono::duration<long long, std::__1::ratio<1, 1000> >::rep' (aka 'long long')
# [-Werror,-Wformat]
code_check_flag += [ "-Wno-format" ]
}

View File

@ -14,11 +14,10 @@
import("//build/ohos.gni")
import("//developtools/hiperf/hiperf.gni")
config("hiperf_client_config") {
visibility = [ ":*" ]
include_dirs = [
"include" ,
"include",
"${hiperf_path}/include",
]
}
@ -28,12 +27,10 @@ ohos_shared_library("hiperf_client") {
public_configs = [ ":hiperf_client_config" ]
sources = [ "src/hiperf_client.cpp" ]
defines = []
if(is_linux) {
if (is_linux) {
defines += [ "CONFIG_NO_HILOG" ]
} else {
external_deps = [
"hiviewdfx_hilog_native:libhilog",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
}
subsystem_name = "developtools"

View File

@ -266,6 +266,7 @@ Client::Client(const std::string &outputDir)
// review: maybe change to some nice check , not just ign th pipe broken?
signal(SIGPIPE, SIG_IGN);
signal(SIGCHLD, SIG_IGN);
}
bool Client::Setup(std::string outputDir)
@ -490,7 +491,7 @@ void Client::KillChild()
close(serverToClientFd_);
}
if (hperfPid_ > 0) {
kill(hperfPid_, SIGINT);
kill(hperfPid_, SIGKILL);
}
}

View File

@ -29,13 +29,11 @@ ohos_shared_library("hiperf_client_napi") {
configs = [ ":hiperf_client_napi_config" ]
sources = [ "hiperf_client_napi.cpp" ]
deps = [
"//foundation/ace/napi:ace_napi",
"${innerkits_path}/native:hiperf_client",
"//foundation/ace/napi:ace_napi",
]
external_deps = [
"hiviewdfx_hilog_native:libhilog",
]
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
output_name = "hiperf_napi"
relative_install_dir = "module"

View File

@ -3,7 +3,8 @@
"parts": {
"hiperf": {
"module_list": [
"//developtools/hiperf/:hiperf_target"
"//developtools/hiperf/:hiperf_target",
"//developtools/hiperf/:hiperf_target_all"
],
"inner_kits": [
{

View File

@ -642,10 +642,11 @@ bool SubCommandRecord::SetPerfMaxSampleRate()
{
int rate = 0;
if (ReadIntFromProcFile("/proc/sys/kernel/perf_event_max_sample_rate", rate)) {
if (rate >= frequency_) {
int frequency = frequency_ != 0 ? frequency_ : PerfEvents::DEFAULT_SAMPLE_FREQUNCY;
if (rate >= frequency) {
return true;
}
return WriteIntToProcFile("/proc/sys/kernel/perf_event_max_sample_rate", frequency_);
return WriteIntToProcFile("/proc/sys/kernel/perf_event_max_sample_rate", frequency);
} else {
if (!IsRoot()) {
printf("root privillege is needed to change perf_event_max_sample_rate\n");

View File

@ -41,16 +41,16 @@ sources_base = [
"unittest/common/native/subcommand_dump_test.cpp",
"unittest/common/native/hashlist_test.cpp",
"unittest/common/native/report_test.cpp",
"unittest/common/native/report_json_file_test.cpp"
"unittest/common/native/report_json_file_test.cpp",
]
if(hiperf_debug) {
sources_base += [ "unittest/common/native/debug_logger_test.cpp" ]
sources_base += [ "unittest/common/native/option_debug_test.cpp" ]
if (hiperf_debug) {
sources_base += [ "unittest/common/native/debug_logger_test.cpp" ]
sources_base += [ "unittest/common/native/option_debug_test.cpp" ]
}
if(!hiperf_target_static) {
sources_base += [ "unittest/common/native/report_protobuf_file_test.cpp" ]
if (!hiperf_target_static) {
sources_base += [ "unittest/common/native/report_protobuf_file_test.cpp" ]
}
sources_interface = [
@ -61,12 +61,12 @@ sources_interface = [
]
common_deps = [
"//third_party/googletest:gtest_main",
"//third_party/googletest:gmock_main",
"${hiperf_path}/:hiperf_platform_common",
"${hiperf_path}/:hiperf_platform_linux",
"${hiperf_path}/:hiperf_platform_host",
"${hiperf_path}/:hiperf_platform_linux",
"${hiperf_path}/interfaces/innerkits/native:hiperf_client",
"//third_party/googletest:gmock_main",
"//third_party/googletest:gtest_main",
]
config("hiperf_test_config") {
@ -74,26 +74,26 @@ config("hiperf_test_config") {
ldflags = []
defines = []
if(hiperf_test_coverage && is_ohos) {
if (hiperf_test_coverage && is_ohos) {
defines += [ "TEST_COVERAGE" ]
cflags += [ "-fprofile-arcs", "-ftest-coverage" ]
cflags += [
"-fprofile-arcs",
"-ftest-coverage",
]
ldflags += [ "--coverage" ]
}
defines += [ "DEFAULT_LOG_LEVEL=LEVEL_VERBOSE" ]
configs = [
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_pub_config",
"//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog_pub_config",
]
include_dirs = [
"${hiperf_path}/test/unittest/common/native/include",
]
include_dirs = [ "${hiperf_path}/test/unittest/common/native/include" ]
}
ohos_unittest("hiperf_unittest") {
configs = [":hiperf_test_config"]
configs = [ ":hiperf_test_config" ]
module_out_path = module_output_path
resource_config_file = "unittest/resource/ohos_test.xml"
deps = common_deps
@ -114,84 +114,76 @@ fuzz_cflags = [
ohos_fuzztest("hiperf_commandline_fuzztest") {
module_out_path = module_output_path
configs = [":hiperf_test_config"]
configs = [ ":hiperf_test_config" ]
cflags = fuzz_cflags
deps = common_deps
defines = [ "FUZZER_TEST" ]
sources = [
"${hiperf_path}/src/main.cpp",
"fuzztest/CommandLine_fuzzer/CommandLine_fuzzer.cpp",
"${hiperf_path}/src/main.cpp"
]
}
ohos_fuzztest("hiperf_libreport_fuzztest") {
module_out_path = module_output_path
configs = [":hiperf_test_config"]
configs = [ ":hiperf_test_config" ]
cflags = fuzz_cflags
deps = common_deps
defines = [ "FUZZER_TEST" ]
sources = [
"fuzztest/LibReport_fuzzer/LibReport_fuzzer.cpp",
]
sources = [ "fuzztest/LibReport_fuzzer/LibReport_fuzzer.cpp" ]
}
ohos_fuzztest("hiperf_client_api_fuzztest") {
module_out_path = module_output_path
configs = [":hiperf_test_config"]
configs = [ ":hiperf_test_config" ]
cflags = fuzz_cflags
deps = common_deps
defines = [ "FUZZER_TEST" ]
sources = [
"fuzztest/ClientApi_fuzzer/ClientApi_fuzzer.cpp",
]
sources = [ "fuzztest/ClientApi_fuzzer/ClientApi_fuzzer.cpp" ]
}
ohos_fuzztest("hiperf_perf_file_fuzztest") {
module_out_path = module_output_path
resource_config_file = "fuzztest/resource/ohos_test.xml"
configs = [":hiperf_test_config"]
configs = [ ":hiperf_test_config" ]
cflags = fuzz_cflags
deps = common_deps
defines = [ "FUZZER_TEST" ]
sources = [
"fuzztest/PerfFile_fuzzer/PerfFile_fuzzer.cpp",
]
sources = [ "fuzztest/PerfFile_fuzzer/PerfFile_fuzzer.cpp" ]
}
ohos_fuzztest("hiperf_elf_parser_fuzztest") {
module_out_path = module_output_path
resource_config_file = "fuzztest/resource/ohos_test.xml"
configs = [":hiperf_test_config"]
configs = [ ":hiperf_test_config" ]
cflags = fuzz_cflags
deps = common_deps
defines = [ "FUZZER_TEST" ]
sources = [
"fuzztest/ElfParser_fuzzer/ElfParser_fuzzer.cpp",
]
sources = [ "fuzztest/ElfParser_fuzzer/ElfParser_fuzzer.cpp" ]
}
group("hiperf_fuzztest") {
testonly = true
deps = [
":hiperf_commandline_fuzztest",
":hiperf_libreport_fuzztest",
":hiperf_client_api_fuzztest",
":hiperf_commandline_fuzztest",
":hiperf_elf_parser_fuzztest",
":hiperf_libreport_fuzztest",
":hiperf_perf_file_fuzztest",
":hiperf_elf_parser_fuzztest"
]
}
group("hiperf_test") {
testonly = true
if(hiperf_target_host) {
if (hiperf_target_host) {
deps = [
":hiperf_fuzztest(${host_toolchain})",
":hiperf_unittest(${host_toolchain})",
":hiperf_fuzztest(${host_toolchain})"
]
} else {
deps = [
":hiperf_fuzztest",
":hiperf_unittest",
":hiperf_fuzztest"
]
}
}

View File

@ -127,7 +127,7 @@ void HiperfLibReportTest::UnwindJsonContentCheck(const std::string &content, boo
ASSERT_EQ(content.front(), '{');
ASSERT_EQ(content.back(), '}');
// CallStack10(int, Option const&) will count nothing in disable unwind
ASSERT_EQ(content.find("{\"symbol\":8,\"counts\":[0,0,186952]}") != std::string::npos,
ASSERT_EQ(content.find("{\"symbol\":8,\"counts\":[0,0,797933]}") != std::string::npos,
haveUnwind);
}

View File

@ -181,22 +181,22 @@ HWTEST_F(SubCommandRecordTest, SelectCpuInputErr, TestSize.Level1)
// cpu percent
HWTEST_F(SubCommandRecordTest, CpuLimitMin, TestSize.Level1)
{
TestRecordCommand("-d 2 -f 1 --cpu-limit 1 ");
TestRecordCommand("-d 2 --cpu-limit 1 ");
}
HWTEST_F(SubCommandRecordTest, CpuLimitErr, TestSize.Level1)
{
TestRecordCommand("-d 2 -f 1 --cpu-limit 0 ", false);
TestRecordCommand("-d 2 --cpu-limit 0 ", false);
}
HWTEST_F(SubCommandRecordTest, CpuLimitMax, TestSize.Level1)
{
TestRecordCommand("-d 2 -f 100000 --cpu-limit 100 ");
TestRecordCommand("-d 2 --cpu-limit 100 ");
}
HWTEST_F(SubCommandRecordTest, CpuLimitMaxErr, TestSize.Level1)
{
TestRecordCommand("-d 2 -f 100000 --cpu-limit 101 ", false);
TestRecordCommand("-d 2 --cpu-limit 101 ", false);
}
HWTEST_F(SubCommandRecordTest, CpuLimitInputErr, TestSize.Level1)

View File

@ -71,7 +71,6 @@
<option name="push" value="testdata/report/hiperf_example_cmd -> /data/test/resource/testdata/report/" src="res"/>
<option name="push" value="testdata/report/perf.dwarf.data -> /data/test/resource/testdata/report/" src="res"/>
<option name="push" value="testdata/report/perf.dwarf.data.txt -> /data/test/resource/testdata/report/" src="res"/>
<option name="push" value="testdata/report/libc++.so -> /data/test/resource/testdata/report/" src="res"/>
<option name="push" value="testdata/perfnew.data -> /data/test/resource/testdata/" src="res"/>
<option name="push" value="testdata/report_test.data -> /data/test/resource/testdata/" src="res"/>