# Copyright (C) 2018 The Android Open Source Project
#
# 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("../gn/fuzzer.gni")
import("../gn/perfetto.gni")

if (!build_with_chromium && enable_perfetto_integration_tests) {
  source_set("perfetto_end_to_end_integrationtests") {
    testonly = true
    deps = [
      ":test_helper",
      "../gn:default_deps",
      "../gn:gtest_and_gmock",
      "../include/perfetto/ext/ipc",
      "../include/perfetto/ext/traced",
      "../include/perfetto/ext/tracing/core:test_support",
      "../include/perfetto/protozero",
      "../protos/perfetto/config:cpp",
      "../protos/perfetto/config:zero",
      "../protos/perfetto/config/power:zero",
      "../protos/perfetto/config/sys_stats:cpp",
      "../protos/perfetto/trace:cpp",
      "../protos/perfetto/trace:zero",
      "../protos/perfetto/trace/ftrace:cpp",
      "../protos/perfetto/trace/perfetto:cpp",
      "../protos/perfetto/trace/power:cpp",
      "../protos/perfetto/trace/sys_stats:cpp",
      "../src/base:base",
      "../src/base:test_support",
      "../src/perfetto_cmd:bugreport_path",
    ]
    if (enable_perfetto_traced_probes) {
      deps += [
        "../src/protozero/filtering:bytecode_generator",
        "../src/traced/probes/ftrace",
        "../src/traced/probes/ftrace:ftrace_procfs",
      ]
    }

    # These binaries are requires by the cmdline tests, which invoke perfetto
    # and trigger_perfetto via Subprocess.
    data_deps = [
      "../src/perfetto_cmd:perfetto",
      "../src/perfetto_cmd:trigger_perfetto",
    ]

    sources = [
      "android_integrationtest.cc",
      "cmdline_integrationtest.cc",
      "ftrace_integrationtest.cc",
      "traced_integrationtest.cc",
    ]
    if (start_daemons_for_testing) {
      # In CTS mode we use /syste/bin/perfetto for the cmdline tests and the
      # perfetto_cmd is not required. Outside of CTS mode, instead, we need to
      # build the cmdline code as part of the test executable.
      deps += [
        "../src/perfetto_cmd",
        "../src/perfetto_cmd:trigger_perfetto_cmd",
      ]
    }

    if (enable_perfetto_trace_processor &&
        enable_perfetto_trace_processor_sqlite &&
        !perfetto_build_with_android && !is_android) {
      sources += [ "trace_processor_shell_integrationtest.cc" ]
      data_deps += [ "../src/trace_processor:trace_processor_shell" ]
      deps += [ "../protos/perfetto/trace_processor:cpp" ]
    }
  }

  executable("client_api_example") {
    sources = [ "client_api_example.cc" ]
    deps = [
      "..:libperfetto_client_experimental",
      "../gn:default_deps",
      "../include/perfetto/tracing",
      "../protos/perfetto/config/gpu:zero",
      "../protos/perfetto/trace:zero",
      "../protos/perfetto/trace/gpu:zero",
    ]
  }
}  # if (!build_with_chromium && enable_perfetto_integration_tests)

perfetto_fuzzer_test("end_to_end_shared_memory_fuzzer") {
  sources = [ "end_to_end_shared_memory_fuzzer.cc" ]
  testonly = true
  deps = [
    ":test_helper",
    "../gn:default_deps",
    "../protos/perfetto/trace:zero",
    "../src/base:test_support",
    "../src/protozero",
    "../src/tracing/core",
    "../src/tracing/ipc/producer",
    "../src/tracing/ipc/service",
  ]
}

perfetto_fuzzer_test("producer_socket_fuzzer") {
  sources = [ "producer_socket_fuzzer.cc" ]
  testonly = true
  deps = [
    ":test_helper",
    "../gn:default_deps",
    "../protos/perfetto/trace:zero",
    "../src/base:test_support",
  ]
}

# perfetto_fuzzer_test() targets are no-ops if is_fuzzer = false.
if (enable_perfetto_benchmarks || is_fuzzer ||
    enable_perfetto_integration_tests) {
  source_set("test_helper") {
    testonly = true
    public_deps = [
      "../protos/perfetto/trace:cpp",
      "../src/tracing/ipc/consumer",
      "../src/tracing/ipc/producer",
      "../src/tracing/ipc/service",
    ]
    deps = [
      "../gn:default_deps",
      "../protos/perfetto/config:cpp",
      "../protos/perfetto/trace:zero",
      "../src/base:test_support",
      "../src/ipc:perfetto_ipc",
      "../src/tracing/ipc:common",
    ]
    sources = [
      "fake_producer.cc",
      "fake_producer.h",
      "test_helper.cc",
      "test_helper.h",
    ]
    if (is_android) {
      sources += [
        "android_test_utils.cc",
        "android_test_utils.h",
      ]
    }
    if (!build_with_chromium && enable_perfetto_traced_probes) {
      deps += [
        "../include/perfetto/ext/traced",
        "../src/traced/probes:probes_src",
      ]
    }
  }
}

if (enable_perfetto_benchmarks) {
  source_set("end_to_end_benchmarks") {
    testonly = true
    deps = [
      ":test_helper",
      "../gn:benchmark",
      "../gn:default_deps",
      "../gn:gtest_and_gmock",
      "../include/perfetto/ext/traced",
      "../protos/perfetto/config:cpp",
      "../protos/perfetto/trace:cpp",
      "../protos/perfetto/trace:zero",
      "../src/base:test_support",
    ]
    sources = [ "end_to_end_benchmark.cc" ]
  }

  source_set("benchmark_main") {
    testonly = true
    deps = [
      "../gn:benchmark",
      "../gn:default_deps",
    ]
    sources = [ "benchmark_main.cc" ]
  }
}  # if (enable_perfetto_benchmarks)

if (perfetto_build_with_android || (is_android && perfetto_build_standalone)) {
  # This is used only in-tree builds. It's built in standalone builds just to
  # get build coverage.
  static_library("perfetto_gtest_logcat_printer") {
    testonly = true
    complete_static_lib = true
    sources = [ "gtest_logcat_printer.cc" ]
    deps = [
      "../gn:default_deps",
      "../gn:gtest_and_gmock",
    ]
  }
}
