mirror of
https://gitee.com/openharmony/developtools_hiperf
synced 2024-11-30 11:10:30 +00:00
d21bf5f84d
Signed-off-by: wenlong_12 <wenlong12@huawei.com> Change-Id: I3218b519709298bb47b64cb47e9c19970dadbc14
206 lines
6.3 KiB
Plaintext
206 lines
6.3 KiB
Plaintext
# Copyright (C) 2021-2022 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("//build/test.gni")
|
|
import("../hiperf.gni")
|
|
|
|
module_output_path = "developtools/hiperf"
|
|
|
|
sources_base = [
|
|
"unittest/common/native/hiperf_client_test.cpp",
|
|
"unittest/common/native/command_test.cpp",
|
|
"unittest/common/native/cpu_usage_test.cpp",
|
|
"unittest/common/native/perf_events_test.cpp",
|
|
"unittest/common/native/perf_event_record_test.cpp",
|
|
"unittest/common/native/perf_file_format_test.cpp",
|
|
"unittest/common/native/perf_file_writer_test.cpp",
|
|
"unittest/common/native/subcommand_test.cpp",
|
|
"unittest/common/native/utilities_test.cpp",
|
|
"unittest/common/native/elf_parser_test.cpp",
|
|
"unittest/common/native/register_test.cpp",
|
|
"unittest/common/native/option_test.cpp",
|
|
"unittest/common/native/perf_file_reader_test.cpp",
|
|
"unittest/common/native/virtual_thread_test.cpp",
|
|
"unittest/common/native/virtual_runtime_test.cpp",
|
|
"unittest/common/native/callstack_test.cpp",
|
|
"unittest/common/native/ring_buffer_test.cpp",
|
|
"unittest/common/native/symbols_file_test.cpp",
|
|
"unittest/common/native/tracked_command_test.cpp",
|
|
"unittest/common/native/dwarf_test.cpp",
|
|
"unittest/common/native/subcommand_help_test.cpp",
|
|
"unittest/common/native/subcommand_list_test.cpp",
|
|
"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",
|
|
]
|
|
|
|
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" ]
|
|
}
|
|
|
|
sources_interface = [
|
|
"unittest/common/native/subcommand_record_test.cpp",
|
|
"unittest/common/native/subcommand_stat_test.cpp",
|
|
"unittest/common/native/subcommand_report_test.cpp",
|
|
"unittest/common/native/hiperf_libreport_test.cpp",
|
|
]
|
|
|
|
common_deps = [
|
|
"${hiperf_path}/:hiperf_platform_common",
|
|
"${hiperf_path}/:hiperf_platform_host",
|
|
"${hiperf_path}/:hiperf_platform_linux",
|
|
"${hiperf_path}/interfaces/innerkits/native:hiperf_client_static",
|
|
"//third_party/googletest:gmock_main",
|
|
"//third_party/googletest:gtest_main",
|
|
]
|
|
|
|
config("hiperf_test_config") {
|
|
cflags = code_check_flag
|
|
ldflags = []
|
|
defines = []
|
|
|
|
if (hiperf_test_coverage && is_ohos) {
|
|
defines += [ "TEST_COVERAGE" ]
|
|
cflags += [
|
|
"-fprofile-arcs",
|
|
"-ftest-coverage",
|
|
]
|
|
ldflags += [ "--coverage" ]
|
|
}
|
|
|
|
defines += [ "DEFAULT_LOG_LEVEL=LEVEL_INFO" ]
|
|
|
|
include_dirs = [ "${hiperf_path}/test/unittest/common/native/include" ]
|
|
}
|
|
|
|
ohos_unittest("hiperf_unittest") {
|
|
configs = [ ":hiperf_test_config" ]
|
|
module_out_path = module_output_path
|
|
resource_config_file = "unittest/resource/ohos_test.xml"
|
|
deps = common_deps
|
|
external_deps = [ "hilog:libhilog" ]
|
|
cflags = [
|
|
"-Dprivate=public", #allow test code access private members
|
|
]
|
|
|
|
sources = sources_interface
|
|
sources += sources_base
|
|
if (is_linux) {
|
|
static_link = false
|
|
}
|
|
}
|
|
|
|
fuzz_cflags = [
|
|
"-O0",
|
|
"-fno-omit-frame-pointer",
|
|
]
|
|
|
|
fuzz_deps = [
|
|
"${hiperf_path}/:hiperf_platform_common",
|
|
"${hiperf_path}/:hiperf_platform_host",
|
|
"${hiperf_path}/:hiperf_platform_linux",
|
|
"${hiperf_path}/interfaces/innerkits/native:hiperf_client_static",
|
|
]
|
|
|
|
ohos_fuzztest("CommandLineFuzzTest") {
|
|
module_out_path = hiperf_fuzz_test_output_path
|
|
fuzz_config_file = "${hiperf_path}/test/fuzztest/commandline_fuzzer"
|
|
configs = [ ":hiperf_test_config" ]
|
|
cflags = fuzz_cflags
|
|
deps = fuzz_deps
|
|
external_deps = [ "hilog:libhilog" ]
|
|
defines = [ "FUZZER_TEST" ]
|
|
sources = [
|
|
"${hiperf_path}/src/main.cpp",
|
|
"fuzztest/commandline_fuzzer/CommandLine_fuzzer.cpp",
|
|
]
|
|
}
|
|
|
|
ohos_fuzztest("LibReportFuzzTest") {
|
|
module_out_path = hiperf_fuzz_test_output_path
|
|
fuzz_config_file = "${hiperf_path}/test/fuzztest/libreport_fuzzer"
|
|
configs = [ ":hiperf_test_config" ]
|
|
cflags = fuzz_cflags
|
|
deps = fuzz_deps
|
|
external_deps = [ "hilog:libhilog" ]
|
|
defines = [ "FUZZER_TEST" ]
|
|
sources = [ "fuzztest/libreport_fuzzer/LibReport_fuzzer.cpp" ]
|
|
}
|
|
|
|
ohos_fuzztest("ClientApiFuzzTest") {
|
|
module_out_path = hiperf_fuzz_test_output_path
|
|
fuzz_config_file = "${hiperf_path}/test/fuzztest/clientapi_fuzzer"
|
|
configs = [ ":hiperf_test_config" ]
|
|
cflags = fuzz_cflags
|
|
deps = fuzz_deps
|
|
external_deps = [ "hilog:libhilog" ]
|
|
defines = [ "FUZZER_TEST" ]
|
|
sources = [ "fuzztest/clientapi_fuzzer/ClientApi_fuzzer.cpp" ]
|
|
}
|
|
|
|
ohos_fuzztest("PerfFileFuzzTest") {
|
|
module_out_path = hiperf_fuzz_test_output_path
|
|
fuzz_config_file = "${hiperf_path}/test/fuzztest/perffile_fuzzer"
|
|
resource_config_file = "fuzztest/resource/ohos_test.xml"
|
|
configs = [ ":hiperf_test_config" ]
|
|
cflags = fuzz_cflags
|
|
deps = fuzz_deps
|
|
external_deps = [ "hilog:libhilog" ]
|
|
defines = [ "FUZZER_TEST" ]
|
|
sources = [ "fuzztest/perffile_fuzzer/PerfFile_fuzzer.cpp" ]
|
|
}
|
|
|
|
ohos_fuzztest("ElfParserFuzzTest") {
|
|
module_out_path = hiperf_fuzz_test_output_path
|
|
fuzz_config_file = "${hiperf_path}/test/fuzztest/elfparser_fuzzer"
|
|
resource_config_file = "fuzztest/resource/ohos_test.xml"
|
|
configs = [ ":hiperf_test_config" ]
|
|
cflags = fuzz_cflags
|
|
deps = fuzz_deps
|
|
external_deps = [ "hilog:libhilog" ]
|
|
defines = [ "FUZZER_TEST" ]
|
|
sources = [ "fuzztest/elfparser_fuzzer/ElfParser_fuzzer.cpp" ]
|
|
}
|
|
|
|
group("hiperf_fuzztest") {
|
|
testonly = true
|
|
deps = [
|
|
":ClientApiFuzzTest",
|
|
":CommandLineFuzzTest",
|
|
":ElfParserFuzzTest",
|
|
":LibReportFuzzTest",
|
|
":PerfFileFuzzTest",
|
|
]
|
|
}
|
|
|
|
group("hiperf_test") {
|
|
testonly = true
|
|
if (hiperf_target_host) {
|
|
deps = [
|
|
":hiperf_fuzztest(${host_toolchain})",
|
|
":hiperf_unittest(${host_toolchain})",
|
|
]
|
|
} else {
|
|
deps = [ ":hiperf_unittest" ]
|
|
}
|
|
if (hiperf_test_fuzz) {
|
|
deps += [ ":hiperf_fuzztest" ]
|
|
}
|
|
}
|