1# Copyright (c) 2021 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14# Defines a collect ebpf testcase template 15# 16# The collect_ebpf_testcase template is to collect the ebpf testcase to out/xxx/ebpf_testcase, 17# and record the configuration file. 18# Parameters 19# ebpf_testcase the ebp testcase of subsystem 20# subsystem_name 21# 22template("collect_ebpf_testcase") { 23 assert(defined(invoker.ebpf_testcase)) 24 assert(defined(invoker.subsystem_name)) 25 assert(defined(invoker.part_name)) 26 27 forward_variables_from(invoker, 28 [ 29 "ebpf_testcase", 30 "subsystem_name", 31 "part_name", 32 ]) 33 34 deps = [] 35 subsystem_testcase_collect_path = 36 "${root_out_dir}/ebpf_testcase/${subsystem_name}/${part_name}" 37 subsystem_testcase_config_file = "${subsystem_testcase_collect_path}/${target_name}_ebpf_testcase_config.json" 38 copy("${target_name}_copy_testcase") { 39 sources = [] 40 sources += ebpf_testcase 41 outputs = [ "${subsystem_testcase_collect_path}/{{source_file_part}}" ] 42 } 43 44 src_testcase_list = [] 45 foreach(testcase, ebpf_testcase) { 46 src_testcase_list += [ rebase_path(testcase, root_build_dir) ] 47 } 48 49 action("${target_name}") { 50 deps += [ ":${target_name}_copy_testcase" ] 51 script = "//build/gen_subsystem_ebpf_testcase_config.py" 52 sources = ebpf_testcase 53 outputs = [ subsystem_testcase_config_file ] 54 args = [ 55 "--subsystem-name", 56 subsystem_name, 57 "--subsystem-ebpf-testcase-config-file", 58 rebase_path(subsystem_testcase_config_file, root_build_dir), 59 ] 60 args += [ "--subsystem-testcase-list" ] 61 args += src_testcase_list 62 args += [ "--subsystem-testcase-collect-path" ] 63 args += [ rebase_path(subsystem_testcase_collect_path, root_build_dir) ] 64 } 65} 66