Primiano Tucci | de82dae | 2018-06-04 16:17:49 +0200 | [diff] [blame] | 1 | # Copyright (C) 2017 The Android Open Source Project |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import("../../../../gn/perfetto.gni") |
| 16 | import("../../../../gn/proto_library.gni") |
| 17 | import("../../../protozero/protozero_library.gni") |
| 18 | |
| 19 | # For use_libfuzzer. |
| 20 | if (!build_with_chromium) { |
| 21 | import("//gn/standalone/sanitizers/vars.gni") |
| 22 | } else { |
| 23 | import("//build/config/sanitizers/sanitizers.gni") |
| 24 | } |
| 25 | |
| 26 | source_set("test_support") { |
| 27 | testonly = true |
| 28 | deps = [ |
| 29 | ":ftrace", |
| 30 | "../../../../gn:default_deps", |
| 31 | "../../../protozero", |
| 32 | ] |
| 33 | public_deps = [ |
| 34 | "../../../protozero:test_support", |
| 35 | ] |
| 36 | |
| 37 | sources = [ |
| 38 | "test/cpu_reader_support.cc", |
| 39 | "test/cpu_reader_support.h", |
| 40 | ] |
| 41 | } |
| 42 | |
| 43 | source_set("unittests") { |
| 44 | testonly = true |
| 45 | deps = [ |
| 46 | ":ftrace", |
| 47 | ":test_messages_lite", |
| 48 | ":test_messages_zero", |
| 49 | ":test_support", |
| 50 | "../../../../gn:default_deps", |
| 51 | "../../../../gn:gtest_deps", |
| 52 | "../../../../protos/perfetto/trace/ftrace:lite", |
| 53 | "../../../base:test_support", |
| 54 | "../../../tracing:test_support", |
| 55 | ] |
| 56 | sources = [ |
| 57 | "cpu_reader_unittest.cc", |
| 58 | "cpu_stats_parser_unittest.cc", |
| 59 | "event_info_unittest.cc", |
| 60 | "format_parser_unittest.cc", |
| 61 | "ftrace_config_muxer_unittest.cc", |
| 62 | "ftrace_config_unittest.cc", |
| 63 | "ftrace_controller_unittest.cc", |
| 64 | "ftrace_procfs_unittest.cc", |
| 65 | "proto_translation_table_unittest.cc", |
| 66 | ] |
| 67 | } |
| 68 | |
| 69 | ftrace_reader_test_proto_sources = [ "test/test_messages.proto" ] |
| 70 | |
| 71 | protozero_library("test_messages_zero") { |
| 72 | sources = ftrace_reader_test_proto_sources |
| 73 | proto_in_dir = perfetto_root_path |
| 74 | proto_out_dir = perfetto_root_path |
| 75 | generator_plugin_options = "wrapper_namespace=pbzero" |
| 76 | } |
| 77 | |
| 78 | proto_library("test_messages_lite") { |
| 79 | generate_python = false |
| 80 | sources = ftrace_reader_test_proto_sources |
| 81 | proto_in_dir = perfetto_root_path |
| 82 | proto_out_dir = perfetto_root_path |
| 83 | } |
| 84 | |
| 85 | # These tests require access to a real ftrace implementation and must |
| 86 | # run with sudo. |
| 87 | source_set("integrationtests") { |
| 88 | testonly = true |
| 89 | deps = [ |
| 90 | ":ftrace", |
| 91 | ":test_support", |
| 92 | "../../../../gn:default_deps", |
| 93 | "../../../../gn:gtest_deps", |
| 94 | "../../../../protos/perfetto/trace/ftrace:lite", |
| 95 | "../../../base", |
| 96 | "../../../tracing", |
| 97 | ] |
| 98 | sources = [ |
| 99 | "end_to_end_integrationtest.cc", |
| 100 | "ftrace_procfs_integrationtest.cc", |
| 101 | ] |
| 102 | } |
| 103 | |
| 104 | source_set("ftrace") { |
| 105 | public_deps = [ |
| 106 | "../../../../gn:gtest_prod_config", |
| 107 | "../../../../protos/perfetto/trace/ftrace:zero", |
| 108 | "../../../tracing", |
| 109 | ] |
| 110 | deps = [ |
| 111 | "../../../../gn:default_deps", |
| 112 | "../../../../include/perfetto/traced", |
| 113 | "../../../base", |
| 114 | "../../../protozero", |
| 115 | ] |
| 116 | sources = [ |
| 117 | "atrace_wrapper.cc", |
| 118 | "atrace_wrapper.h", |
| 119 | "cpu_reader.cc", |
| 120 | "cpu_reader.h", |
| 121 | "cpu_stats_parser.cc", |
| 122 | "cpu_stats_parser.h", |
| 123 | "event_info.cc", |
| 124 | "event_info.h", |
| 125 | "event_info_constants.cc", |
| 126 | "event_info_constants.h", |
| 127 | "format_parser.cc", |
| 128 | "format_parser.h", |
| 129 | "ftrace_config.cc", |
| 130 | "ftrace_config.h", |
| 131 | "ftrace_config_muxer.cc", |
| 132 | "ftrace_config_muxer.h", |
| 133 | "ftrace_controller.cc", |
| 134 | "ftrace_controller.h", |
| 135 | "ftrace_procfs.cc", |
| 136 | "ftrace_procfs.h", |
| 137 | "proto_translation_table.cc", |
| 138 | "proto_translation_table.h", |
| 139 | ] |
| 140 | } |
| 141 | |
| 142 | if (!build_with_chromium) { |
| 143 | source_set("benchmarks") { |
| 144 | testonly = true |
| 145 | deps = [ |
| 146 | ":ftrace", |
| 147 | ":test_support", |
| 148 | "../../../../gn:default_deps", |
| 149 | "//buildtools:benchmark", |
| 150 | ] |
| 151 | sources = [ |
| 152 | "cpu_reader_benchmark.cc", |
| 153 | ] |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | if (use_libfuzzer && !build_with_chromium) { |
| 158 | executable("cpu_reader_fuzzer") { |
| 159 | testonly = true |
| 160 | sources = [ |
| 161 | "cpu_reader_fuzzer.cc", |
| 162 | ] |
| 163 | deps = [ |
| 164 | ":ftrace", |
| 165 | ":test_support", |
| 166 | "../../../../gn:default_deps", |
| 167 | ] |
| 168 | configs += [ "../../../../gn:fuzzer_config" ] |
| 169 | } |
| 170 | } |