• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2021 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("//build/test.gni")
16import("test_ts.gni")
17
18if (target == "test") {
19  ohos_unittest("trace_streamer_ut") {
20    sources = [
21      "unittest/binder_filter_test.cpp",
22      "unittest/bio_parser_test.cpp",
23      "unittest/bytrace_parser_test.cpp",
24      "unittest/clock_filter_test.cpp",
25      "unittest/cpu_filter_test.cpp",
26      "unittest/ebpf_file_system_test.cpp",
27      "unittest/ebpf_parser_test.cpp",
28      "unittest/event_parser_test.cpp",
29      "unittest/filter_filter_test.cpp",
30      "unittest/hidump_parser_test.cpp",
31      "unittest/hilog_parser_test.cpp",
32      "unittest/hisys_event_parser_test.cpp",
33      "unittest/htrace_binder_event_test.cpp",
34      "unittest/htrace_cpu_data_parser_test.cpp",
35      "unittest/htrace_cpu_detail_parser_test.cpp",
36      "unittest/htrace_diskio_parser_test.cpp",
37      "unittest/htrace_event_parser_test.cpp",
38      "unittest/htrace_irq_event_test.cpp",
39      "unittest/htrace_mem_parser_test.cpp",
40      "unittest/htrace_network_parser_test.cpp",
41      "unittest/htrace_process_parser_test.cpp",
42      "unittest/htrace_sys_mem_parser_test.cpp",
43      "unittest/htrace_sys_vmem_parser_test.cpp",
44      "unittest/http_server_test.cpp",
45      "unittest/irq_filter_test.cpp",
46      "unittest/measure_filter_test.cpp",
47      "unittest/native_hook_parser_test.cpp",
48      "unittest/paged_memory_parser_test.cpp",
49      "unittest/parser_test.cpp",
50      "unittest/process_filter_test.cpp",
51      "unittest/rpc_server_test.cpp",
52      "unittest/slice_filter_test.cpp",
53      "unittest/smaps_parser_test.cpp",
54      "unittest/span_join_test.cpp",
55      "unittest/table_test.cpp",
56      "unittest/wasm_func_test.cpp",
57    ]
58    deps = [
59      "../src:trace_streamer_source",
60      "//prebuilts/protos:ts_proto_data_cpp",
61      "//third_party/googletest:gtest",
62      "//third_party/googletest:gtest_main",
63      "//third_party/protobuf:protobuf",
64      "//third_party/protobuf:protobuf_lite",
65      "//third_party/sqlite:sqlite",
66    ]
67    include_dirs = [
68      "../src",
69      "../src/trace_data",
70      "../src/table",
71      "../src/filter",
72      "../src/base",
73      "../src/rpc",
74      "../src/include",
75      "../src/trace_streamer",
76      "../src/parser/bytrace_parser",
77      "../src/parser",
78      "../src/cfg",
79      "../src/parser/htrace_parser",
80      "../src/parser/htrace_parser/htrace_event_parser",
81      "../src/parser/htrace_parser/htrace_cpu_parser",
82      "../src/parser/ebpf_parser",
83      "../prebuilts/emsdk/emsdk/emscripten/system/include",
84      "..",
85      "//third_party/googletest/googletest/include/gtest",
86      "//third_party/protobuf/src",
87      "//third_party/json-master/include",
88      "//third_party/json-master/include/nlohmann",
89      "${OHOS_PROTO_GEN}",
90      "${OHOS_FTRACE_PROTO_DIR}",
91      "${OHOS_MEMORY_PROTO_DIR}",
92      "${OHOS_HILOG_PROTO_DIR}",
93      "${OHOS_NATIVE_HOOK_PROTO_DIR}",
94      "${OHOS_HIDUMP_PROTO_DIR}",
95      "${OHOS_NETWORK_PROTO_DIR}",
96      "${OHOS_DISKIO_PROTO_DIR}",
97      "${OHOS_CPUDATA_PROTO_DIR}",
98      "${OHOS_PROCESS_PROTO_DIR}",
99      "${OHOS_SERVICE_PROTO_DIR}",
100    ]
101    cflags = [
102      "-Wno-inconsistent-missing-override",
103      "-Dprivate=public",  #allow test code access private members
104      "-Dprotected=public",  #allow test code access protect members
105      "-fprofile-arcs",
106      "-ftest-coverage",
107      "-Wno-unused-command-line-argument",
108      "-Wno-format",
109      "-Wno-unused-const-variable",
110      "-Wno-unused-variable",
111      "-Wno-used-but-marked-unused",
112    ]
113    ldflags = [
114      "-fprofile-arcs",
115      "-ftest-coverage",
116      "--coverage",
117    ]
118    cflags += [
119      # clang coverage options:
120      "--coverage",
121      "-mllvm",
122      "-limited-coverage-experimental=true",
123      "-fno-use-cxa-atexit",
124      "-DUT_MAC",
125    ]
126    if (is_macx) {
127      lib_dirs = [ "/usr/local/opt/llvm/lib" ]
128    }
129    libs = [ "LLVMCore" ]
130  }
131}
132
133# this is the dest for ohos.build
134if (target == "test") {
135  group("unittest") {
136    testonly = true
137    deps = [ ":trace_streamer_ut" ]
138  }
139} else if (target == "fuzz") {
140  group("fuzztest") {
141    testonly = true
142    deps = [
143      "test_fuzzer/bytrace_fuzzer:fuzztest",
144      "test_fuzzer/htrace_fuzzer:fuzztest",
145      "test_fuzzer/selector_fuzzer:fuzztest",
146    ]
147  }
148}
149