| # Copyright 2023 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/components.gni") |
| import("//build/test.gni") |
| import("//build/testing/host_test.gni") |
| import("//build/testing/host_test_data.gni") |
| import("//src/lib/testing/expectation/generated_expectations_file.gni") |
| import("//src/starnix/build/args.gni") |
| import("//src/starnix/kernel/starnix.gni") |
| import("//src/starnix/tests/build/starnix_linux_test_component.gni") |
| import("//src/starnix/tests/environments.gni") |
| import("//src/starnix/tests/starnix_test_subpackages.gni") |
| import("//src/starnix/tests/syscalls/cpp/syscall_test.gni") |
| |
| syscall_tests_deps = [ |
| # go/keep-sorted start |
| # go/keep-sorted end |
| ] |
| |
| syscall_tests_resources = [ |
| # go/keep-sorted start |
| |
| ":fuse_overlayfs", |
| ":simple_ext4_image", |
| |
| # go/keep-sorted end |
| ] |
| |
| syscall_tests_executables = [ |
| # go/keep-sorted start |
| |
| ":extended_pstate_initial_state_child", |
| ":ptrace_test_exec_child", |
| ":signal_handling_test_exec_child", |
| ":suid_test_exec_child", |
| ":syscall_test_exec_child", |
| "test_programs:clone_exec_helper", |
| "test_programs:print_helper", |
| "test_programs:signal_handling_test_exec_parent_after_exit", |
| "test_programs:signal_handling_test_exec_parent_before_exit", |
| |
| # go/keep-sorted end |
| ] |
| |
| # syscall tests that can be run on both arch32 and arch64. |
| syscall_tests = [ |
| # go/keep-sorted start |
| |
| "abort_test", |
| "ashmem_test", |
| "aspace_test", |
| "binder_test", |
| "bpf_test", |
| "cache_flush_test", |
| "capabilities_test", |
| "cgroup_freezer_test", |
| "cgroup_test", |
| "cpuinfo_test", |
| "custom_artifact_test", |
| "epoll_test", |
| "extended_pstate_test", |
| "fallocate_test", |
| "fcntl_test", |
| "fs_test", |
| "fsverity_test", |
| "fuse_test", |
| "futex_test", |
| "getrandom_test", |
| "io_uring_test", |
| "loop_test", |
| "membarrier_test", |
| "memfd_test", |
| "mmap_test", |
| "mount_test", |
| "netlink_test", |
| "overlayfs_test", |
| "perf_event_open_test", |
| "pidfd_test", |
| "pipe_test", |
| "poll_test", |
| "prctl_test", |
| "pressure_test", |
| "process_mrelease_test", |
| "procfs_mem_test", |
| "procfs_test", |
| "ptrace_test", |
| "read_write_test", |
| "reboot_test", |
| "restart_read_test", |
| "rlimit_test", |
| "sched_test", |
| "seccomp_test", |
| "sendfile_test", |
| "setpriority_test", |
| "signal_handling_test", |
| "signalfd_test", |
| "socket_test", |
| "suid_test", |
| "sw_breakpoint_test", |
| "symlink_test", |
| "sysctl_test", |
| "sysfs_kernel_test", |
| "sysfs_power_test", |
| "syslog_test", |
| "task_test", |
| "terminal_test", |
| "test_helper_test", |
| "thread_group_lifecycle_test", |
| "time_test", |
| "timerfd_test", |
| "timers_test", |
| "tmpfs_test", |
| "trivial_test", |
| "tun_test", |
| "uio_test", |
| "userfaultfd_test", |
| "vdso_test", |
| "vmsplice_test", |
| "waitpid_exit_signal_test", |
| "waitpid_flags_test", |
| "zombie_test", |
| |
| # go/keep-sorted end |
| ] |
| |
| syscall_tests_etc = [ |
| { |
| name = "exit_test" |
| |
| # Test exit without running at_exit and this mislead sanitizers. |
| disable_sanitizers_on_host = true |
| }, |
| { |
| name = "input_test" |
| container_config = { |
| extra_features = [ "framebuffer" ] |
| } |
| }, |
| { |
| name = "ioctl_test" |
| container_config = { |
| extra_features = [ "framebuffer" ] |
| } |
| }, |
| { |
| name = "fuchsia_network_monitor_fs_test" |
| container_config = { |
| extra_features = [ "network_manager" ] |
| } |
| }, |
| { |
| name = "touch_standby_test" |
| container_config = { |
| extra_features = [ "framebuffer" ] |
| } |
| }, |
| { |
| name = "udev_test" |
| container_config = { |
| extra_features = [ "framebuffer" ] |
| } |
| }, |
| ] |
| |
| # Flaky tests are run with debug logging on, for diagnostics. |
| # TODO: b/449149502 - Move the test back into syscall_tests_etc once diagnosed. |
| syscall_tests_flaky = [ |
| { |
| name = "timerfd_mutable_test" |
| container_config = { |
| extra_features = [] |
| enable_utc_time_adjustment = true |
| } |
| }, |
| ] |
| |
| if (target_cpu == "x64") { |
| # TODO(https://fxbug.dev/42059962): arm64 emulator does not have Vulkan support yet. |
| # This test requires test-ui-stack. |
| syscall_tests_etc += [ |
| { |
| name = "uinput_test" |
| container_config = { |
| extra_features = [ "framebuffer" ] |
| } |
| }, |
| ] |
| } |
| |
| mlock_onfault_behaviors = [ |
| true, |
| false, |
| ] |
| mlock_pin_flavors = [ |
| "noop", |
| "shadow_process", |
| "vmar_always_need", |
| ] |
| |
| foreach(onfault_behavior, mlock_onfault_behaviors) { |
| foreach(pin_flavor, mlock_pin_flavors) { |
| if (onfault_behavior) { |
| onfault_str = "_always_onfault" |
| } else { |
| onfault_str = "" |
| } |
| syscall_tests_etc += [ |
| { |
| name = "mlock_test${onfault_str}_${pin_flavor}_pin" |
| sources = [ "mlock_test.cc" ] |
| |
| # Sanitizer runtimes stub out mlock() because it is incompatible with their virtual memory |
| # management. |
| disable_sanitizers_on_host = true |
| container_config = { |
| mlock_always_onfault = onfault_behavior |
| mlock_pin_flavor = pin_flavor |
| } |
| }, |
| ] |
| } |
| } |
| |
| all_test_names = syscall_tests |
| foreach(test_def, syscall_tests_etc) { |
| all_test_names += [ test_def.name ] |
| } |
| |
| # TODO: b/449149502 - Remove once diagnosed. |
| all_flaky_test_names = [] |
| foreach(test_def, syscall_tests_flaky) { |
| all_flaky_test_names += [ test_def.name ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":starnix_syscalls_cpp_flaky_tests", |
| ":starnix_syscalls_cpp_tests", |
| ] |
| if (current_cpu == "arm64") { |
| deps += [ |
| ":starnix_arch32_syscalls_cpp_flaky_tests", |
| ":starnix_arch32_syscalls_cpp_tests", |
| ] |
| } |
| if (host_os == "linux" && host_cpu == "x64") { |
| foreach(test_name, all_test_names) { |
| deps += [ |
| # These are Linux tests, so we can run them as host tests on our host Linux bot. |
| ":starnix_${test_name}_baseline($host_toolchain)", |
| ] |
| } |
| } |
| } |
| |
| group("linux_vm_tests") { |
| testonly = true |
| deps = [ ":linux_syscalls_cpp_tests" ] |
| } |
| |
| source_set("test_utils") { |
| testonly = true |
| |
| sources = [ |
| "binder/client.cc", |
| "binder/client.h", |
| "binder/common.cc", |
| "binder/common.h", |
| "binder/manager.cc", |
| "binder/manager.h", |
| "binder/manager_provider_client_test.h", |
| "binder/provider.cc", |
| "binder/provider.h", |
| "binder_helper.cc", |
| "binder_helper.h", |
| "capabilities_helper.cc", |
| "capabilities_helper.h", |
| "fault_test.h", |
| "fault_test_suite.h", |
| "proc_test_base.h", |
| "syscall_matchers.h", |
| "task_test.h", |
| "test_helper.cc", |
| "test_helper.h", |
| ] |
| public_deps = [ |
| "//third_party/googletest:gmock", |
| "//third_party/googletest:gtest", |
| "//third_party/rapidjson", |
| "//zircon/system/ulib/fbl", |
| ] |
| deps = [ "//src/lib/fxl" ] |
| configs += [ "//build/config:rtti" ] |
| } |
| |
| if (current_cpu == "x64" || current_cpu == "arm64") { |
| resource("fuse_overlayfs") { |
| sources = [] |
| if (current_cpu == "x64") { |
| sources += [ "//prebuilt/starnix/fuse-overlayfs-amd64/fuse-overlayfs" ] |
| } |
| if (current_cpu == "arm64") { |
| sources += [ "//prebuilt/starnix/fuse-overlayfs-arm64/fuse-overlayfs" ] |
| } |
| outputs = [ "data/tests/deps/fuse-overlayfs" ] |
| } |
| } else { |
| group("fuse_overlayfs") { |
| } |
| } |
| |
| resource("simple_ext4_image") { |
| sources = [ |
| "data/hello_world.txt", |
| "data/simple_ext4.img", |
| ] |
| outputs = [ "data/tests/deps/{{source_file_part}}" ] |
| } |
| |
| config("march") { |
| if (current_cpu == "riscv64") { |
| # Keep `march` consistent with the value used by Android, see |
| # https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/config/riscv64_device.go;drc=726b001ae1a3388f65b571350bef4d373a3768c8;l=36 |
| cflags = [ "-march=rv64gcv_zba_zbb_zbs" ] |
| } |
| } |
| |
| foreach(test_name, syscall_tests) { |
| syscall_test(test_name) { |
| deps = syscall_tests_deps |
| resources = syscall_tests_resources |
| executables = syscall_tests_executables |
| } |
| } |
| |
| foreach(test_def, syscall_tests_etc) { |
| syscall_test(test_def.name) { |
| deps = syscall_tests_deps |
| resources = syscall_tests_resources |
| executables = syscall_tests_executables |
| forward_variables_from(test_def, "*", [ "name" ]) |
| } |
| } |
| |
| # TODO: b/449149502 - Remove once diagnosed. |
| foreach(test_def, syscall_tests_flaky) { |
| syscall_test(test_def.name) { |
| deps = syscall_tests_deps |
| resources = syscall_tests_resources |
| executables = syscall_tests_executables |
| forward_variables_from(test_def, "*", [ "name" ]) |
| } |
| } |
| |
| test("crash") { |
| # TODO(https://fxbug.dev/297293167) enable ASan instrumentation for Linux binaries in Starnix |
| exclude_toolchain_tags = [ "asan" ] |
| sources = [ "crash.cc" ] |
| deps = [ |
| ":test_utils", |
| "//src/lib/fxl/test:gtest_main", |
| "//third_party/googletest:gtest", |
| ] |
| } |
| |
| if (is_linux) { |
| executable("extended_pstate_initial_state_child") { |
| testonly = true |
| emit_tool_path = false |
| |
| # TODO(https://fxbug.dev/297293167) enable ASan instrumentation for Linux binaries in Starnix |
| exclude_toolchain_tags = [ "instrumented" ] |
| sources = [ "extended_pstate_initial_state_child.cc" ] |
| |
| # This binary does not use libc or a dynamic linker since it is testing the state |
| # presented to _start. |
| disable_syslog_backend = true |
| cflags = [ "-fno-builtin" ] |
| ldflags = [ |
| "-nostdlib", |
| "-nostartfiles", |
| "-static", |
| ] |
| |
| configs -= [ |
| "//build/config/linux:default-pie", |
| "//build/config/linux:implicit-host-libs", |
| ] |
| } |
| |
| executable("ptrace_test_exec_child") { |
| testonly = true |
| emit_tool_path = false |
| sources = [ "ptrace_test_exec_child.cc" ] |
| |
| # TODO(https://fxbug.dev/297293167) enable ASan instrumentation for Linux binaries in Starnix |
| exclude_toolchain_tags = [ |
| "asan", |
| "coverage", |
| ] |
| deps = [ ":test_utils" ] |
| } |
| |
| executable("signal_handling_test_exec_child") { |
| testonly = true |
| emit_tool_path = false |
| sources = [ "signal_handling_test_exec_child.cc" ] |
| |
| # TODO(https://fxbug.dev/297293167) enable ASan instrumentation for Linux binaries in Starnix |
| exclude_toolchain_tags = [ |
| "asan", |
| "coverage", |
| ] |
| deps = [ ":test_utils" ] |
| } |
| |
| executable("syscall_test_exec_child") { |
| testonly = true |
| emit_tool_path = false |
| sources = [ "syscall_test_exec_child.cc" ] |
| |
| # TODO(https://fxbug.dev/297293167) enable ASan instrumentation for Linux binaries in Starnix |
| exclude_toolchain_tags = [ |
| "asan", |
| "coverage", |
| ] |
| deps = [ ":test_utils" ] |
| } |
| |
| executable("suid_test_exec_child") { |
| testonly = true |
| emit_tool_path = false |
| sources = [ "suid_test_exec_child.cc" ] |
| |
| # TODO(https://fxbug.dev/297293167) enable ASan instrumentation for Linux binaries in Starnix |
| exclude_toolchain_tags = [ |
| "asan", |
| "coverage", |
| ] |
| deps = [ ":test_utils" ] |
| } |
| } |
| |
| generated_expectations_file("syscalls_cpp_test_expectations") { |
| includes = [ |
| "expectations/syscalls_cpp_test.json5", |
| "expectations/syscalls_cpp_test_${current_cpu}.json5", |
| ] |
| if (current_toolchain == target_linux_arch32_toolchain) { |
| includes += [ "expectations/syscalls_cpp_test_arch32.json5" ] |
| } |
| } |
| |
| generated_expectations_file("linux_cpp_test_expectations") { |
| includes = [ "expectations/linux_syscalls_cpp_test.json5" ] |
| } |
| |
| starnix_linux_test_component("crash_test") { |
| test_label = ":crash" |
| test_binary = "crash" |
| test_type = "starnix" |
| } |
| |
| foreach(test_name, syscall_tests) { |
| syscall_test("linux_${test_name}") { |
| test_name = test_name |
| deps = syscall_tests_deps |
| resources = syscall_tests_resources |
| executables = syscall_tests_executables |
| test_target_kernel = "linux" |
| custom_expectations = ":linux_cpp_test_expectations" |
| } |
| } |
| |
| foreach(test_def, syscall_tests_etc) { |
| syscall_test("linux_${test_def.name}") { |
| test_name = test_def.name |
| deps = syscall_tests_deps |
| resources = syscall_tests_resources |
| executables = syscall_tests_executables |
| forward_variables_from(test_def, "*", [ "name" ]) |
| test_target_kernel = "linux" |
| custom_expectations = ":linux_cpp_test_expectations" |
| } |
| } |
| |
| fuchsia_test_package("linux_syscalls_cpp_tests") { |
| test_components = [] |
| deps = [] |
| foreach(test_name, all_test_names) { |
| test_components += [ ":linux_${test_name}" ] |
| deps += [ ":linux_${test_name}_config" ] |
| } |
| |
| subpackages = starnix_test_subpackages |
| subpackages += [ "//src/starnix/containers/debian:debian_package" ] |
| |
| if (target_cpu == "x64") { |
| # TODO(https://fxbug.dev/42059962): arm64 emulator does not have Vulkan support yet. |
| # Without Vulkan, test-ui-stack will stuck on Scenic startup. |
| subpackages += [ "//src/ui/testing/test_ui_stack:test-ui-stack" ] |
| } |
| |
| deps += [ "//src/lib/testing/expectation:expectation_comparer" ] |
| |
| test_specs = { |
| # TODO(https://fxbug.dev/319150842): GCE doesn't support Vulkan, so, for now, just disable all |
| # of these tests on GCE. |
| _env = basic_envs |
| _env += [ gce_env ] |
| _env -= [ gce_env ] |
| environments = _env |
| |
| log_settings = { |
| # Tests exercise failure cases, so ERROR logs are expected. |
| max_severity = "ERROR" |
| } |
| } |
| } |
| |
| # TODO: b/449149502 - Remove once diagnosed. |
| fuchsia_test_package("starnix_syscalls_cpp_flaky_tests") { |
| test_components = [ ":crash_test" ] |
| deps = [] |
| foreach(test_name, all_flaky_test_names) { |
| test_components += [ ":${test_name}" ] |
| deps += [ ":${test_name}_config" ] |
| } |
| |
| subpackages = starnix_test_subpackages |
| subpackages += [ "//src/starnix/containers/debian:debian_package" ] |
| |
| if (target_cpu == "x64") { |
| # TODO(https://fxbug.dev/42059962): arm64 emulator does not have Vulkan support yet. |
| # Without Vulkan, test-ui-stack will stuck on Scenic startup. |
| subpackages += [ "//src/ui/testing/test_ui_stack:test-ui-stack" ] |
| } |
| |
| deps += [ "//src/lib/testing/expectation:expectation_comparer" ] |
| |
| test_specs = { |
| # TODO(https://fxbug.dev/319150842): GCE doesn't support Vulkan, so, for now, just disable all |
| # of these tests on GCE. |
| _env = basic_envs |
| _env += [ gce_env ] |
| _env -= [ gce_env ] |
| environments = _env |
| |
| log_settings = { |
| # Tests exercise failure cases, so ERROR logs are expected. |
| max_severity = "ERROR" |
| |
| # Flaky tests need additional diagnostics. |
| min_severity = "DEBUG" |
| } |
| } |
| } |
| |
| fuchsia_test_package("starnix_syscalls_cpp_tests") { |
| test_components = [ ":crash_test" ] |
| deps = [] |
| foreach(test_name, all_test_names) { |
| test_components += [ ":${test_name}" ] |
| deps += [ ":${test_name}_config" ] |
| } |
| |
| subpackages = starnix_test_subpackages |
| subpackages += [ "//src/starnix/containers/debian:debian_package" ] |
| |
| if (target_cpu == "x64") { |
| # TODO(https://fxbug.dev/42059962): arm64 emulator does not have Vulkan support yet. |
| # Without Vulkan, test-ui-stack will stuck on Scenic startup. |
| subpackages += [ "//src/ui/testing/test_ui_stack:test-ui-stack" ] |
| } |
| |
| deps += [ "//src/lib/testing/expectation:expectation_comparer" ] |
| |
| test_specs = { |
| # TODO(https://fxbug.dev/319150842): GCE doesn't support Vulkan, so, for now, just disable all |
| # of these tests on GCE. |
| _env = basic_envs |
| _env += [ gce_env ] |
| _env -= [ gce_env ] |
| environments = _env |
| |
| log_settings = { |
| # Tests exercise failure cases, so ERROR logs are expected. |
| max_severity = "ERROR" |
| } |
| } |
| } |
| |
| if (current_cpu == "arm64") { |
| fuchsia_test_package("starnix_arch32_syscalls_cpp_tests") { |
| test_components = [] |
| deps = [] |
| foreach(test_name, all_test_names) { |
| test_components += [ ":${test_name}_arch32" ] |
| deps += [ ":${test_name}_config" ] |
| } |
| |
| subpackages = starnix_test_subpackages |
| subpackages += [ "//src/starnix/containers/debian:debian_package" ] |
| |
| if (target_cpu == "x64") { |
| # TODO(https://fxbug.dev/42059962): arm64 emulator does not have Vulkan support yet. |
| # Without Vulkan, test-ui-stack will stuck on Scenic startup. |
| subpackages += [ "//src/ui/testing/test_ui_stack:test-ui-stack" ] |
| } |
| |
| deps += [ "//src/lib/testing/expectation:expectation_comparer" ] |
| |
| test_specs = { |
| # TODO(https://fxbug.dev/319150842): GCE doesn't support Vulkan, so, for now, just disable all |
| # of these tests on GCE. |
| _env = arch32_envs |
| _env += [ gce_env ] |
| _env -= [ gce_env ] |
| environments = _env |
| |
| log_settings = { |
| # Tests exercise failure cases, so ERROR logs are expected. |
| max_severity = "ERROR" |
| } |
| } |
| } |
| |
| # TODO: b/449149502 - Remove once diagnosed. |
| fuchsia_test_package("starnix_arch32_syscalls_cpp_flaky_tests") { |
| test_components = [] |
| deps = [] |
| foreach(test_name, all_flaky_test_names) { |
| test_components += [ ":${test_name}_arch32" ] |
| deps += [ ":${test_name}_config" ] |
| } |
| |
| subpackages = starnix_test_subpackages |
| subpackages += [ "//src/starnix/containers/debian:debian_package" ] |
| |
| if (target_cpu == "x64") { |
| # TODO(https://fxbug.dev/42059962): arm64 emulator does not have Vulkan support yet. |
| # Without Vulkan, test-ui-stack will stuck on Scenic startup. |
| subpackages += [ "//src/ui/testing/test_ui_stack:test-ui-stack" ] |
| } |
| |
| deps += [ "//src/lib/testing/expectation:expectation_comparer" ] |
| |
| test_specs = { |
| # TODO(https://fxbug.dev/319150842): GCE doesn't support Vulkan, so, for now, just disable all |
| # of these tests on GCE. |
| _env = arch32_envs |
| _env += [ gce_env ] |
| _env -= [ gce_env ] |
| environments = _env |
| |
| log_settings = { |
| # Tests exercise failure cases, so ERROR logs are expected. |
| max_severity = "ERROR" |
| } |
| } |
| } |
| } |