1# Copyright 2023 The Chromium Authors 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import("//testing/test.gni") 6 7template("private_code_test") { 8 isolated_script_test(target_name) { 9 forward_variables_from(invoker, 10 [ 11 "data", 12 "data_deps", 13 ]) 14 script = "//build/private_code_test/private_code_test.py" 15 _linker_inputs_dep = invoker.linker_inputs_dep 16 if (shlib_prefix != "") { 17 _so_name = shlib_prefix + get_label_info(_linker_inputs_dep, "name") 18 _so_name = string_replace(_so_name, 19 "${shlib_prefix}${shlib_prefix}", 20 shlib_prefix) 21 } 22 _dir = get_label_info(_linker_inputs_dep, "root_out_dir") 23 if (is_android) { 24 _dir += "/lib.unstripped" 25 } 26 _linker_inputs_file = "$_dir/${_so_name}$shlib_extension" 27 if (defined(invoker.private_paths_dep)) { 28 _private_paths_dep = invoker.private_paths_dep 29 _private_paths_file = invoker.private_paths_file 30 } else { 31 _private_paths_dep = 32 "//build/private_code_test:private_paths($default_toolchain)" 33 _private_paths_file = 34 get_label_info(_private_paths_dep, "target_gen_dir") + 35 "/private_paths.txt" 36 } 37 38 data_deps = [ 39 _linker_inputs_dep, 40 _private_paths_dep, 41 ] 42 args = [ 43 "--linker-inputs", 44 "@WrappedPath(" + rebase_path(_linker_inputs_file, root_build_dir) + ")", 45 "--private-paths-file", 46 "@WrappedPath(" + rebase_path(_private_paths_file, root_build_dir) + ")", 47 "--root-out-dir", 48 rebase_path(get_label_info(_linker_inputs_dep, "root_out_dir"), 49 root_build_dir), 50 ] 51 if (defined(invoker.allowed_violations)) { 52 foreach(_glob, invoker.allowed_violations) { 53 args += [ 54 "--allow-violation", 55 _glob, 56 ] 57 } 58 } 59 if (defined(invoker.expect_failure) && invoker.expect_failure) { 60 args += [ "--expect-failure" ] 61 } 62 } 63} 64