| # Copyright 2020 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/compiled_action.gni") |
| import("//build/fidl/toolchain.gni") |
| import("//build/go/go_binary.gni") |
| import("//build/go/go_library.gni") |
| import("//build/host.gni") |
| import("//build/testing/golden_files.gni") |
| import("//tools/fidl/fidlc/testdata/info.gni") |
| |
| if (is_host) { |
| go_library("codegen") { |
| source_dir = "codegen" |
| deps = [ "//tools/fidl/lib/fidlgen" ] |
| sources = [ |
| "codegen.go", |
| "description.tmpl", |
| "ir.go", |
| "protocol.tmpl", |
| "struct.tmpl", |
| "union.tmpl", |
| ] |
| } |
| |
| go_library("main") { |
| deps = [ |
| ":codegen", |
| "//tools/fidl/lib/fidlgen", |
| ] |
| sources = [ "main.go" ] |
| } |
| |
| go_binary("fidlgen_syzkaller") { |
| library = ":main" |
| sdk_category = "partner" |
| } |
| |
| fidl_testdata_info_filtered = [] |
| foreach(info, fidl_testdata_info) { |
| if (info.denylist + [ "fidlgen_syzkaller" ] - [ "fidlgen_syzkaller" ] == |
| info.denylist) { |
| fidl_testdata_info_filtered += [ info ] |
| } |
| } |
| |
| compiled_action_foreach("generate_goldens") { |
| testonly = true |
| tool = ":fidlgen_syzkaller" |
| deps = [] |
| sources = [] |
| foreach(info, fidl_testdata_info_filtered) { |
| deps += [ "${info.target}($fidl_toolchain)" ] |
| sources += [ "${info.fidl_gen_dir}/${info.target_name}.fidl.json" ] |
| } |
| args = [ |
| "-json", |
| "{{source}}", |
| "-output-syz", |
| rebase_path(target_gen_dir, root_build_dir) + |
| "/golden_{{source_name_part}}.syz.txt", |
| ] |
| outputs = [ "$target_gen_dir/golden_{{source_name_part}}.syz.txt" ] |
| } |
| |
| golden_files("fidlgen_syzkaller_golden_tests") { |
| testonly = true |
| deps = [ ":generate_goldens" ] |
| comparisons = [] |
| foreach(info, fidl_testdata_info_filtered) { |
| comparisons += [ |
| { |
| golden = "goldens/${info.name}.syz.txt.golden" |
| candidate = "$target_gen_dir/golden_${info.target_name}.fidl.syz.txt" |
| }, |
| ] |
| } |
| } |
| } |
| |
| install_host_tools("host") { |
| deps = [ ":fidlgen_syzkaller" ] |
| outputs = [ "fidlgen_syzkaller" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ ":fidlgen_syzkaller_golden_tests($host_toolchain)" ] |
| } |