# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later

# SPDX-License-Identifier: GPL-2.0-or-later

add_executable(tests
    common/addon_config.cpp
    common/thread_worker.cpp
    video_core/vulkan_overlay_filter.cpp
    video_core/buffer_cache_ports.cpp
    video_core/unswizzle_workers.cpp
    video_core/block_linear_swizzle.cpp
    video_core/aftermath_dump.cpp
    video_core/frame_dump_schedule.cpp
    video_core/frame_dump_decode.cpp
    video_core/frame_gen_generations.cpp
    video_core/frame_pacer.cpp
    video_core/nx2_stutter_trace.cpp
    video_core/back_idle_trace.cpp
    video_core/list_macro_trace.cpp
    video_core/host_mip_limits.cpp
    video_core/writeback_ranges.cpp
    video_core/writeback_switches.cpp
    video_core/gpu_timestamp.cpp
    video_core/semaphore_waiters.cpp
    video_core/hdr_output.cpp
    video_core/host_vsync.cpp
    core/mii_model.cpp
    core/address_space.cpp
    core/nx2_streamplay.cpp
    core/nx2_gpu_only_regions.cpp
    core/nx2_hdr_notifications.cpp
    core/nx2_video_ready.cpp
    core/general_channel.cpp
    core/home_menu.cpp
    core/window_system.cpp
    core/native_home_bootstrap.cpp
    core/kernel_finish_termination.cpp
    core/nx2_thread_stats.cpp
    core/nx2_debug_server.cpp
    core/nx2_zip.cpp
    core/nx2_present_pacer.cpp
    core/nx2_present_queue.cpp
    core/nx2_syncpoint_allocator.cpp
    core/nx2_fence_action.cpp
    core/nx2_frame_interval.cpp
    core/ldn_lan_protocol.cpp
    core/perf_stats.cpp
    core/service_auto_stub.cpp
    core/key_derivation.cpp
    core/profile_manager_reset.cpp
    core/eticket_title_key.cpp
    core/keyblob_cmac.cpp
    core/aes_xts.cpp
    common/display_hdr.cpp
    common/restore_eden_path.cpp
    common/dkb_cpu_trace.cpp
    common/dkb_frame_trace.cpp
    audio_core/nx2_sysmix.cpp
    audio_core/nx2_input_service.cpp
    audio_core/audio_in.cpp
    audio_core/sysmix_sink.cpp
    audio_core/sysmix_test_context.h
    video_core/ampere_starfox_test10.cpp
    video_core/ampere_yoshi_title.cpp
    video_core/ampere_yoshi_compute.cpp
    video_core/scaled_image_fits.cpp
    video_core/vulkan_address_map.cpp
    video_core/texture_rect_descriptor.cpp
    video_core/join_whole_copy.cpp
    video_core/padded_square.cpp
    audio_core/batch_decoder.cpp
    audio_core/adpcm_decode.cpp
    audio_core/microphone.cpp
    audio_core/hardware_audio_codec.cpp
    core/gpu_dirty_memory.cpp
    core/nso_loader.cpp
    core/nsp_loader.cpp
    core/memory_acquire.cpp
    core/kip_sections.cpp
    core/memory_span.cpp
    core/kip_blz.cpp
    core/builtin_patches.cpp
    core/cheat_parser.cpp
    core/builtin_font_glyphs.cpp
    core/system_test_context.h
    video_core/ampere_branch_modifiers.cpp
    video_core/ampere_fast_fusion_logged.cpp
    video_core/fast_fusion_surface_store.cpp
    video_core/fast_fusion_byte_store.cpp
    video_core/vk_byte_addressed_shadow.cpp
    video_core/global_memory_coherence.cpp
    video_core/storage_buffer_pointer_tracking.cpp
    video_core/storage_write_extent.cpp
    video_core/storage_buffer_control_flow.cpp
    video_core/conditional_barrier.cpp
    video_core/far_plane_position.cpp
    video_core/storage_buffer_shared_tracking.cpp
    core/nup_validation.cpp
    core/fs_read_throttle.cpp
    core/npdm_kac.cpp
    core/nx_archive.cpp
    frontend_common/nx_archive.cpp
    core/vfs_vector.cpp
    core/vfs_real.cpp
    core/kip_ini.cpp
    core/add_on_application_id.cpp
    core/ncz_cache.cpp
    core/kip_truncated.cpp
    core/ncz_decompressor.cpp
    core/ncz_io_guards.cpp
    core/ncz_container.cpp
    core/file_sys_parsers.cpp
    core/nca_header_authentication.cpp
    core/system_data_view.cpp
    input_common/calibration_lifetime.cpp
    video_core/ampere_logged_numeric.cpp
    video_core/ampere_logged_textures.cpp
    video_core/native_texture_header_index.cpp
    video_core/texture_alias_ticks.cpp
    video_core/texture_cache_gob_layout.cpp
    video_core/image_view_slots.cpp
    video_core/sampled_views.cpp
    video_core/texture_handles.cpp
    video_core/ampere_selevet_modes.cpp
    video_core/ampere_selevet_spills.cpp
    video_core/blit_dither.cpp
    video_core/maxwell_numeric.cpp
    video_core/maxwell_r2p.cpp
    video_core/maxwell_permute_lod.cpp
    video_core/submission_policy.cpp
    video_core/native_pending_policy.cpp
    video_core/framebuffer_clear_layers.cpp
    video_core/framebuffer_limits.cpp
    video_core/descriptor_limits.cpp
    video_core/device_buffer_pool.cpp
    video_core/device_memory_asid.cpp
    video_core/unbacked_fallback.cpp
    video_core/eviction_age.cpp
    video_core/host_memory_limit.cpp
    video_core/fire_emblem_upscale.cpp
    video_core/dlss_contract.cpp
    video_core/dlss_mode.cpp
    video_core/frame_gen_choice.cpp
    video_core/ampere_fast_fusion.cpp
    video_core/ampere_async_copy.cpp
    video_core/ampere_trap_guards.cpp
    video_core/astc_bcn_batches.cpp
    video_core/async_draw_policy.cpp
    video_core/bounded_store.cpp
    video_core/pipeline_eviction_policy.cpp
    video_core/async_shader_emission.cpp
    video_core/oot_network.cpp
    video_core/page_filter.cpp
    video_core/query_stream.cpp
    video_core/pipeline_optimization.cpp
    video_core/spirv_atomic_retry.cpp
    video_core/spirv_storage_alignment.cpp
    video_core/spirv_fragment_shuffle.cpp
    video_core/phi_identity_operand.cpp
    video_core/mesh_fallback.cpp
    video_core/mesh_vertex_input.cpp
    video_core/multi_range_refresh.cpp
    video_core/command_fetch_order.cpp
    video_core/gpu_trace.cpp
    video_core/nx2_render_follower.cpp
    video_core/buffer_arena.cpp
    video_core/nx2_render_view.cpp
    video_core/gpu_written_pages.cpp
    video_core/nx2_semaphore_mirror.cpp
    video_core/command_writer.cpp
    video_core/split_fence_wait.cpp
    video_core/nx2_written_pages.cpp
    video_core/command_snapshot_suspensions.cpp
    video_core/safe_command_reads.cpp
    video_core/pending_maps.cpp
    video_core/maxwell_fast_method.cpp
    hid_core/emulated_controller_config.cpp
    hid_core/npad_assignment.cpp
    hid_core/sensor_info.cpp
    common/flat_allocator.cpp
    common/paged_scalar.cpp
    common/queue_lifetime.cpp
    common/queue_timed_wait.cpp
    common/range_set_move.cpp
    common/range_set_subtract.cpp
    video_core/uniform_cache_history.cpp
    video_core/x8d24_conversion.cpp
    video_core/ampere_ported_half_compare.cpp
    video_core/ampere_geometry_capture.cpp
    video_core/ampere_geometry_exit.cpp
    video_core/ampere_geometry_lowering.cpp
    video_core/ampere_ported_conversions.cpp
    video_core/ampere_ported_uniform_vote.cpp
    video_core/ampere_ported_textures.cpp
    video_core/ampere_tennis_i2f.cpp
    video_core/ampere_tennis_tessellation.cpp
    video_core/ampere_stage_buffer_output.cpp
    video_core/pipeline_cache_files.cpp
    video_core/shader_cache_v2.cpp
    video_core/evicted_pointer_slots.cpp
    video_core/shader_cache_v2_programs.cpp
    video_core/shader_cache_v2_driver.cpp
    video_core/vulkan_pipeline_binaries.cpp
    video_core/vulkan_buffer_oom.cpp
    video_core/pipeline_layout_cache.cpp
    video_core/shader_precache.cpp
    video_core/shader_object_pool.cpp
    video_core/storage_binding_capacity.cpp
    video_core/native_indirect_reset.cpp
    video_core/native_qmd.cpp
    video_core/fast_draw.cpp
    video_core/gpu_command_safety.cpp
    video_core/syncpoint_actions.cpp
    video_core/due_composites.cpp
    video_core/nx2_video_av1.cpp
    video_core/nx2_video_render.cpp
    video_core/ampere_matrix.cpp
    video_core/spirv_software_matrix.cpp
    video_core/spirv_program_name.cpp
    video_core/spirv_builtin_capabilities.cpp
    video_core/spirv_frag_depth_d24.cpp
    video_core/spirv_min_max_denorms.cpp
    video_core/spirv_nan_safe_min_max.cpp
    video_core/spirv_scalar_constants.cpp
    video_core/spirv_emit_twice.cpp
    video_core/ssa_fixed_variables.cpp
    video_core/virtual_range_cache.cpp
    video_core/ocarina_upscale.cpp
    video_core/ocarina_camera.cpp
    video_core/fsr4_support.cpp
    common/bit_field.cpp
    common/bit_util.cpp
    common/ca_store.cpp
    common/cityhash.cpp
    common/container_hash.cpp
    common/core_pinning.cpp
    common/data_directories.cpp
    common/event.cpp
    common/fibers.cpp
    common/fs_iterate.cpp
    frontend_common/install_keys.cpp
    frontend_common/play_time.cpp
    common/game_presets.cpp
    common/host_memory.cpp
    common/host_memory_failure.cpp
    common/host_memory_test_access.h
    core/host_memory_failure.cpp
    common/library_exceptions.cpp
    common/memory_detect.cpp
    common/multi_level_page_table.cpp
    common/nextendo.cpp
    common/npln_patch_manifest.cpp
    common/page_table.cpp
    common/param_package.cpp
    common/poll_window.cpp
    common/range_map.cpp
    common/ring_buffer.cpp
    common/scratch_buffer.cpp
    common/slot_vector.cpp
    common/sparse_large_vector.cpp
    common/unique_function.cpp
    common/zstd_compression.cpp
    core/core_timing.cpp
    core/host_wait_margin.cpp
    core/local_redirect.cpp
    core/nextendo_bcat.cpp
    core/nextendo_redirect.cpp
    core/filesystem_rename.cpp
    core/thread_startup_policy.cpp
    core/nup_writer.cpp
    core/nup_metadata.cpp
    core/nup_read_bench.cpp
    core/nup_zstd_read.cpp
    core/nx2_image_layout.cpp
    core/nx2_movie_clock.cpp
    core/nx2_video_input_queue.cpp
    core/font_merge.cpp
    core/ldn.cpp
    core/internal_network/socket_proxy.cpp
    core/priority_queue.cpp
    core/internal_network/network.cpp
    core/bsd_sockopt_ipc.cpp
    core/bsd_ipv6_ipc.cpp
    core/ipv6_sockets.cpp
    core/numeric_name_info.cpp
    core/numeric_name_info_ipc.cpp
    core/nifm_request.cpp
    core/prepo_async_context.cpp
    core/cmif_out_buffer.cpp
    core/time_zone_fallback.cpp
    video_core/memory_tracker.cpp
    video_core/invalidation_accumulator.cpp
    video_core/memory_manager_runs.cpp
    video_core/nx2_perf_draw_binds.cpp
    video_core/nx2_perf_texture_writes.cpp
    video_core/h264_packet.cpp
    video_core/vp9_range_encoder.cpp
    video_core/nx2_gpu_mapping.cpp
    video_core/vertex_repack.cpp
    video_core/vk_texel_buffer_range.cpp
    video_core/ampere_lowering.cpp
    video_core/ampere_geometry.cpp
    video_core/ampere_i2f.cpp
    video_core/ampere_gradient.cpp
    video_core/ampere_returns.cpp
    video_core/ampere_guarded_ulea.cpp
    video_core/ampere_compute_lowering.cpp
    video_core/ampere_uniform_immediate_shift.cpp
    video_core/ampere_bindless_surfaces.cpp
    video_core/native_macro_fifo.cpp
    video_core/turing_macro_effects.cpp
    video_core/turing_macro_ram.cpp
    video_core/uniform_stream_reuse.cpp
    video_core/usage_tracker.cpp
    video_core/nx2_backx.cpp
    video_core/vertex_input_cache.cpp
    video_core/shader_invalidation.cpp
    video_core/descriptor_table.cpp
    video_core/descriptor_payload_growth.cpp
    video_core/global_address_tracking.cpp
    video_core/global_atomic_routing.cpp
    video_core/global_memory_routes.cpp
    video_core/nvn_storage_descriptor.cpp
    video_core/ampere_f2i.cpp
    video_core/ampere_ldc.cpp
    video_core/ampere_vote.cpp
    video_core/shader_attributes.cpp
    video_core/indirect_reset.cpp
    video_core/stale_pages.cpp
    input_common/calibration_configuration_job.cpp
)

create_target_directory_groups(tests)

target_link_libraries(tests PRIVATE common core audio_core input_common video_core frontend_common tz ZLIB::ZLIB)
target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2WithMain Threads::Threads)
target_link_libraries(tests PRIVATE nlohmann_json::nlohmann_json OpenSSL::Crypto)

add_executable(ncz_tests
    core/ncz_cache.cpp
    core/ncz_decompressor.cpp
    core/ncz_io_guards.cpp
    ../core/crypto/ncz_cache.cpp
    ../core/crypto/ncz_decompressor.cpp
    ../core/crypto/aes_util.cpp
    ../core/file_sys/vfs/vfs.cpp
    ../core/file_sys/vfs/vfs_vector.cpp)
target_sources(ncz_tests PRIVATE
    ../core/file_sys/fssystem/fssystem_utility.cpp
    ../core/file_sys/fssystem/fssystem_aes_ctr_storage.cpp
    ../core/file_sys/fssystem/fssystem_alignment_matching_storage_impl.cpp)
target_link_libraries(ncz_tests PRIVATE common OpenSSL::Crypto zstd::zstd
    ${PLATFORM_LIBRARIES} Catch2::Catch2WithMain Threads::Threads)
add_test(NAME ncz_tests COMMAND ncz_tests)

if (TARGET dynarmic::dynarmic)
    target_sources(tests PRIVATE core/jit_codegen_options.cpp core/jit_ordered_loads.cpp
        core/jit_vector_round_int16.cpp core/window_trace.cpp)
    target_link_libraries(tests PRIVATE dynarmic::dynarmic)
endif()

target_compile_definitions(tests PRIVATE
    LICHII_NX_FIXTURE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/core/nx_fixtures"
    LICHII_TESTS_LOG_DIR="${CMAKE_CURRENT_BINARY_DIR}/test-log")

add_test(NAME tests COMMAND tests)

if ((HAS_NCE AND LINUX) OR HAS_HYPERVISOR)
    enable_language(ASM)
    add_executable(arm_cpu_guest_tests core/arm_cpu_guest.cpp core/arm_cpu_guest.S)
    target_link_libraries(arm_cpu_guest_tests PRIVATE core video_core frontend_common
        ${PLATFORM_LIBRARIES})
    target_compile_options(arm_cpu_guest_tests PRIVATE
        $<$<COMPILE_LANGUAGE:CXX>:-Wno-unused-variable>)
    if (HAS_HYPERVISOR)
        set(native_backend hvf)
        add_custom_command(TARGET arm_cpu_guest_tests POST_BUILD
            COMMAND /usr/bin/codesign --force --sign -
                --entitlements "${PROJECT_SOURCE_DIR}/dist/eglantine.entitlements"
                "$<TARGET_FILE:arm_cpu_guest_tests>"
            VERBATIM)
        add_test(NAME arm_cpu_guest_hvf_execute_fault COMMAND arm_cpu_guest_tests hvf --execute-fault)
        add_test(NAME arm_cpu_guest_hvf_revoke_fault COMMAND arm_cpu_guest_tests hvf --revoke-fault)
        add_test(NAME arm_cpu_guest_hvf_relaunch COMMAND arm_cpu_guest_tests hvf --relaunch)
        set_tests_properties(arm_cpu_guest_hvf_execute_fault arm_cpu_guest_hvf_revoke_fault
            arm_cpu_guest_hvf_relaunch
            PROPERTIES LABELS arm_cpu_guest RESOURCE_LOCK arm_cpu_guest TIMEOUT 35)
    else()
        set(native_backend nce)
    endif()
    add_test(NAME arm_cpu_guest_${native_backend} COMMAND arm_cpu_guest_tests ${native_backend})
    add_test(NAME arm_cpu_guest_${native_backend}_nx2_clock
        COMMAND arm_cpu_guest_tests ${native_backend} --nx2-clock)
    add_test(NAME arm_cpu_guest_dynarmic COMMAND arm_cpu_guest_tests dynarmic)
    add_test(NAME arm_cpu_guest_${native_backend}_fault
        COMMAND arm_cpu_guest_tests ${native_backend} --fault)
    add_test(NAME arm_cpu_guest_${native_backend}_permission_fault
        COMMAND arm_cpu_guest_tests ${native_backend} --permission-fault)
    set_tests_properties(
        arm_cpu_guest_${native_backend} arm_cpu_guest_${native_backend}_nx2_clock
        arm_cpu_guest_dynarmic arm_cpu_guest_${native_backend}_fault
        arm_cpu_guest_${native_backend}_permission_fault
        PROPERTIES LABELS arm_cpu_guest RESOURCE_LOCK arm_cpu_guest TIMEOUT 35)
endif()

add_executable(profile_migration_tests
    common/profile_migration.cpp)
target_link_libraries(profile_migration_tests PRIVATE common Catch2::Catch2WithMain)
add_test(NAME profile_migration_tests COMMAND profile_migration_tests)

add_executable(ryujinx_save_link_tests common/ryujinx_save_link.cpp)
target_link_libraries(ryujinx_save_link_tests PRIVATE common Catch2::Catch2WithMain)
add_test(NAME ryujinx_save_link_tests COMMAND ryujinx_save_link_tests)

add_executable(log_file_flush_tests
    common/log_file_flush.cpp)
target_link_libraries(log_file_flush_tests PRIVATE common Catch2::Catch2WithMain)
add_test(NAME log_file_flush_tests COMMAND log_file_flush_tests)

# One process per test case: the log backend is made once per process.
add_executable(log_file_lock_tests
    common/log_file_lock.cpp)
target_link_libraries(log_file_lock_tests PRIVATE common Catch2::Catch2WithMain)
add_test(NAME log_file_lock_parents
    COMMAND log_file_lock_tests "The log folder is created with its missing parents")
add_test(NAME log_file_lock_live
    COMMAND log_file_lock_tests "A second Lichii leaves a log another one still writes")
add_test(NAME log_file_lock_third
    COMMAND log_file_lock_tests "A third Lichii takes the next free log")
add_test(NAME log_file_lock_full
    COMMAND log_file_lock_tests "A Lichii that finds every log held keeps no log file")
# The live cases wait for child processes: fail instead of hanging the run if one never ends.
set_tests_properties(log_file_lock_parents log_file_lock_live log_file_lock_third
    log_file_lock_full PROPERTIES TIMEOUT 60)
# Catch2 exits with 4 when its only case skips (no posix_spawn on Windows): report it as skipped.
# Only from Catch2 3.7.1 on, where failed assertions exit with 42: before that the exit code was
# their count, and four failures would have read as a skip. The bundled Catch2 defines no version
# here and is newer; a system one says which it is.
if (NOT DEFINED Catch2_VERSION OR NOT Catch2_VERSION VERSION_LESS 3.7.1)
    set_tests_properties(log_file_lock_parents log_file_lock_live log_file_lock_third
        log_file_lock_full PROPERTIES SKIP_RETURN_CODE 4)
endif()

if (TARGET SDL3::SDL3)
    add_executable(sdl_window_state_tests lichii_cmd/sdl_window_state.cpp)
    target_link_libraries(sdl_window_state_tests PRIVATE SDL3::SDL3 Catch2::Catch2WithMain)
    add_test(NAME sdl_window_state_tests COMMAND sdl_window_state_tests)
endif()

if (WIN32 AND ARCHITECTURE_x86_64)
    target_sources(tests PRIVATE common/nx2_sampler.cpp)
    add_executable(event_wait_probe ../../tools/nx2/event_wait_probe.cpp)
    target_link_libraries(event_wait_probe PRIVATE common)
endif()

add_executable(update_checker_tests
    common/update_checker.cpp
    common/update_installer.cpp
    ../frontend_common/update_checker.cpp
    ../frontend_common/update_installer.cpp)
target_link_libraries(update_checker_tests PRIVATE common Catch2::Catch2WithMain)
add_test(NAME update_checker_tests COMMAND update_checker_tests)

add_executable(brontide_update_tests
    common/brontide_update_parse.cpp
    ../lichii/brontide/update_parse.cpp)
target_link_libraries(brontide_update_tests PRIVATE nlohmann_json::nlohmann_json Catch2::Catch2WithMain)
add_test(NAME brontide_update_tests COMMAND brontide_update_tests)

# A libFuzzer target for the shader cache v2 reader, where the compiler has libFuzzer. Built on
# request: ninja shader_cache_v2_fuzzer, then shader_cache_v2_fuzzer <corpus directory>
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_FLAGS -fsanitize=fuzzer)
check_cxx_source_compiles("
    #include <cstddef>
    #include <cstdint>
    extern \"C\" int LLVMFuzzerTestOneInput(const std::uint8_t*, std::size_t) { return 0; }"
    HAVE_LIBFUZZER)
unset(CMAKE_REQUIRED_FLAGS)
if (HAVE_LIBFUZZER)
    add_executable(shader_cache_v2_fuzzer EXCLUDE_FROM_ALL
        fuzz/shader_cache_v2_reader.cpp
        ../video_core/shader_cache_v2/cache_format.cpp)
    target_compile_options(shader_cache_v2_fuzzer PRIVATE -fsanitize=fuzzer,address,undefined)
    target_link_options(shader_cache_v2_fuzzer PRIVATE -fsanitize=fuzzer,address,undefined)
    target_link_libraries(shader_cache_v2_fuzzer PRIVATE common xxhash)
    if (BOOST_NO_HEADERS)
        target_link_libraries(shader_cache_v2_fuzzer PRIVATE Boost::crc)
    endif()
endif()

# The shader job scheduler on its own, so it can be built with a sanitizer: configure with
# -DSHADER_JOBS_SANITIZER=thread (or address,undefined), then build and run shader_jobs_tests.
set(SHADER_JOBS_SANITIZER "" CACHE STRING "Build shader_jobs_tests with -fsanitize=<value>")
add_executable(shader_jobs_tests
    video_core/shader_jobs.cpp
    ../video_core/shader_jobs.cpp)
target_link_libraries(shader_jobs_tests PRIVATE common Catch2::Catch2WithMain Threads::Threads)
if (SHADER_JOBS_SANITIZER)
    target_compile_options(shader_jobs_tests PRIVATE -fsanitize=${SHADER_JOBS_SANITIZER}
        -fno-omit-frame-pointer -fno-sanitize-recover=all -g)
    target_link_options(shader_jobs_tests PRIVATE -fsanitize=${SHADER_JOBS_SANITIZER})
endif()
add_test(NAME shader_jobs_tests COMMAND shader_jobs_tests)

# Stage translation on shader job workers over the tools/shader-sweep fixtures. For
# ThreadSanitizer the shader recompiler needs instrumenting too: configure a separate build with
# -DCMAKE_C_FLAGS=-fsanitize=thread -DCMAKE_CXX_FLAGS=-fsanitize=thread, then build and run
# shader_translation_tests.
add_executable(shader_translation_tests
    video_core/stage_translation.cpp
    ../video_core/shader_jobs.cpp
    ../video_core/shader_stage_translation.cpp)
target_link_libraries(shader_translation_tests PRIVATE common shader_recompiler
    Catch2::Catch2WithMain Threads::Threads)
target_compile_definitions(shader_translation_tests PRIVATE
    SHADER_SWEEP_FIXTURES="${PROJECT_SOURCE_DIR}/tools/shader-sweep/fixtures")
add_test(NAME shader_translation_tests COMMAND shader_translation_tests)

if (NOT ANDROID)
    target_sources(tests PRIVATE input_common/joycon_subcommand_response.cpp
                                 input_common/rumble_mapping.cpp
                                 input_common/switch2_protocol.cpp)
    target_link_libraries(tests PRIVATE SDL3::SDL3)

    add_executable(config_tests
        common/first_run_config.cpp
        common/recommended_settings.cpp
        ../frontend_common/profile_import.cpp
        ../frontend_common/config.cpp
        ../frontend_common/recommended_settings.cpp)
    target_link_libraries(config_tests PRIVATE common SimpleIni::SimpleIni Catch2::Catch2WithMain
        ${PLATFORM_LIBRARIES})
    add_test(NAME config_tests COMMAND config_tests)

    add_executable(profile_import_tests
        frontend_common/profile_import.cpp
        ../frontend_common/profile_import.cpp)
    target_link_libraries(profile_import_tests PRIVATE common SimpleIni::SimpleIni
        Catch2::Catch2WithMain ${PLATFORM_LIBRARIES})
    add_test(NAME profile_import_tests COMMAND profile_import_tests)
endif()

# needed for vma
if (NOT MSVC)
    target_compile_options(tests PRIVATE
        $<$<COMPILE_LANGUAGE:C,CXX>:-Wno-conversion>
        $<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-variable>
        $<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-parameter>
        $<$<COMPILE_LANGUAGE:C,CXX>:-Wno-missing-field-initializers>)
endif()
