# 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/perfetto.gni")
import("//build_overrides/build.gni")

# For use_libfuzzer.
if (!build_with_chromium) {
  import("//gn/standalone/sanitizers/vars.gni")
} else {
  import("//build/config/sanitizers/sanitizers.gni")
}

source_set("end_to_end_integrationtests") {
  testonly = true
  deps = [
    ":task_runner_thread",
    ":task_runner_thread_delegates",
    ":test_helper",
    "../gn:default_deps",
    "../gn:gtest_deps",
    "../include/perfetto/traced",
    "../protos/perfetto/trace:lite",
    "../protos/perfetto/trace:zero",
    "../src/base:base",
    "../src/base:test_support",
  ]
  sources = [
    "end_to_end_integrationtest.cc",
  ]
  if (is_android && !build_with_chromium) {
    deps += [ "../src/base:android_task_runner" ]
  }
  if (start_daemons_for_testing) {
    cflags = [ "-DPERFETTO_START_DAEMONS_FOR_TESTING" ]
  }
}

if (use_libfuzzer && !build_with_chromium) {
  executable("end_to_end_shared_memory_fuzzer") {
    sources = [
      "end_to_end_shared_memory_fuzzer.cc",
    ]
    testonly = true
    deps = [
      ":task_runner_thread",
      ":task_runner_thread_delegates",
      ":test_helper",
      "../gn:default_deps",
      "../protos/perfetto/trace:lite",
      "../src/base:test_support",
      "../src/protozero",
      "../src/tracing",
      "../src/tracing:ipc",
    ]
    configs += [ "../gn:fuzzer_config" ]
  }
}

source_set("task_runner_thread") {
  testonly = true
  deps = [
    "../gn:default_deps",
    "../src/base",
    "../src/base:test_support",
  ]
  sources = [
    "task_runner_thread.cc",
    "task_runner_thread.h",
  ]
}

source_set("task_runner_thread_delegates") {
  testonly = true
  deps = [
    ":task_runner_thread",
    "../gn:default_deps",
    "../src/base:test_support",
    "../src/traced/probes:probes_src",
    "../src/tracing:ipc",
  ]
  sources = [
    "fake_producer.cc",
    "fake_producer.h",
    "task_runner_thread_delegates.h",
  ]
}

source_set("test_helper") {
  testonly = true
  public_deps = [
    "../src/tracing:ipc",
  ]
  deps = [
    ":task_runner_thread",
    ":task_runner_thread_delegates",
    "../gn:default_deps",
    "../include/perfetto/traced",
    "../protos/perfetto/trace:lite",
    "../protos/perfetto/trace:zero",
    "../src/base:test_support",
  ]
  sources = [
    "test_helper.cc",
    "test_helper.h",
  ]
  if (start_daemons_for_testing) {
    cflags = [ "-DPERFETTO_START_DAEMONS_FOR_TESTING" ]
  }
}

if (!build_with_chromium) {
  source_set("end_to_end_benchmarks") {
    testonly = true
    deps = [
      ":task_runner_thread",
      ":task_runner_thread_delegates",
      ":test_helper",
      "../../gn:default_deps",
      "../buildtools:benchmark",
      "../gn:gtest_deps",
      "../include/perfetto/traced",
      "../protos/perfetto/trace:lite",
      "../protos/perfetto/trace:zero",
      "../src/base:test_support",
    ]
    sources = [
      "end_to_end_benchmark.cc",
    ]
    if (is_android && !build_with_chromium) {
      deps += [ "../src/base:android_task_runner" ]
    }
    if (start_daemons_for_testing) {
      cflags = [ "-DPERFETTO_START_DAEMONS_FOR_TESTING" ]
    }
  }

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