| # Copyright 2026 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/python/python_action.gni") | |
| import("//build/python/python_binary.gni") | |
| import("//build/python/python_host_test.gni") | |
| import("//build/python/python_library.gni") | |
| import("//build/testing/golden_files.gni") | |
| _protocol_tests = [ | |
| { | |
| target_name = "protocol_test" | |
| source = "tests/test_protocol.py" | |
| }, | |
| { | |
| target_name = "test_attach_detach_schemas" | |
| source = "protocol/tests/test_attach_detach_schemas.py" | |
| }, | |
| { | |
| target_name = "test_breakpoint_schemas" | |
| source = "protocol/tests/test_breakpoint_schemas.py" | |
| }, | |
| { | |
| target_name = "test_evaluate_and_console_schemas" | |
| source = "protocol/tests/test_evaluate_and_console_schemas.py" | |
| }, | |
| { | |
| target_name = "test_event_and_state_schemas" | |
| source = "protocol/tests/test_event_and_state_schemas.py" | |
| }, | |
| { | |
| target_name = "test_execution_schemas" | |
| source = "protocol/tests/test_execution_schemas.py" | |
| }, | |
| { | |
| target_name = "test_lifecycle_schemas" | |
| source = "protocol/tests/test_lifecycle_schemas.py" | |
| }, | |
| { | |
| target_name = "test_process_inspection_schemas" | |
| source = "protocol/tests/test_process_inspection_schemas.py" | |
| }, | |
| { | |
| target_name = "test_stack_schemas" | |
| source = "protocol/tests/test_stack_schemas.py" | |
| }, | |
| { | |
| target_name = "test_tracepoint_schemas" | |
| source = "protocol/tests/test_tracepoint_schemas.py" | |
| }, | |
| ] | |
| group("tests") { | |
| testonly = true | |
| deps = [ ":schema_golden_check($host_toolchain)" ] | |
| foreach(test, _protocol_tests) { | |
| deps += [ ":${test.target_name}($host_toolchain)" ] | |
| } | |
| } | |
| if (is_host) { | |
| python_library("protocol_lib") { | |
| library_name = "shared" | |
| sources = [ | |
| "__init__.py", | |
| "protocol/__init__.py", | |
| "protocol/aspace.py", | |
| "protocol/async_backtrace.py", | |
| "protocol/attach.py", | |
| "protocol/base.py", | |
| "protocol/break_request.py", | |
| "protocol/console.py", | |
| "protocol/continue_request.py", | |
| "protocol/detach.py", | |
| "protocol/diagnose_hang.py", | |
| "protocol/driver_list.py", | |
| "protocol/evaluate.py", | |
| "protocol/finish.py", | |
| "protocol/get_state.py", | |
| "protocol/handles.py", | |
| "protocol/hello.py", | |
| "protocol/mem_read.py", | |
| "protocol/modules.py", | |
| "protocol/next_request.py", | |
| "protocol/pause.py", | |
| "protocol/stack_trace.py", | |
| "protocol/start.py", | |
| "protocol/step_in.py", | |
| "protocol/stop.py", | |
| "protocol/threads.py", | |
| "protocol/tracepoint.py", | |
| "protocol/variables.py", | |
| "protocol/wait_for_event.py", | |
| "protocol/watch_request.py", | |
| ] | |
| library_deps = [ | |
| "//src/lib/debug/dap/python:lib", | |
| "//src/lib/debug/dap/python/zxdb:zxdb_dap", | |
| "//third_party/pylibs/pydantic", | |
| ] | |
| } | |
| group("pydantic_test_data") { | |
| testonly = true | |
| public_deps = [ "//prebuilt/third_party/pydantic-core:test_data" ] | |
| } | |
| python_library("test_helpers") { | |
| testonly = true | |
| library_name = "shared" | |
| sources = [ | |
| "tests/__init__.py", | |
| "tests/helpers.py", | |
| ] | |
| deps = [ ":protocol_lib" ] | |
| } | |
| foreach(test, _protocol_tests) { | |
| python_host_test(test.target_name) { | |
| main_source = test.source | |
| libraries = [ | |
| ":protocol_lib", | |
| ":test_helpers", | |
| ] | |
| # Explicitly depend on pydantic-core's test_data. This is to ensure that | |
| # the module's DSO is bundled together with our test so the top-level | |
| # pydantic module loads correctly. | |
| test_data_deps = [ ":pydantic_test_data" ] | |
| } | |
| } | |
| python_binary("generate_schema_bin") { | |
| main_source = "generate_schema.py" | |
| main_callable = "main" | |
| deps = [ ":protocol_lib" ] | |
| } | |
| python_action("generate_schema") { | |
| binary_label = ":generate_schema_bin" | |
| outputs = [ "$target_gen_dir/schema.json" ] | |
| args = [ | |
| "--output", | |
| rebase_path("$target_gen_dir/schema.json", root_build_dir), | |
| ] | |
| } | |
| golden_files("schema_golden_check") { | |
| comparisons = [ | |
| { | |
| golden = "//scripts/debug/zxdb_cli/schema.json" | |
| candidate = "$target_gen_dir/schema.json" | |
| }, | |
| ] | |
| deps = [ ":generate_schema" ] | |
| } | |
| } |