blob: 5800f4a411b03884ea779e8781cfc327cd3cd38c [file] [edit]
//
// Copyright (C) 2025 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
phony_rule {
name: "berberis_host_tests_result",
phony_deps: select(soong_config_variable("berberis", "translation_arch"), {
"riscv64_to_x86_64": [
"berberis_host_tests_64_run_test",
"berberis_host_tests_avx_64_run_test",
"berberis_host_tests_no_avx_64_run_test",
"berberis_ndk_program_tests_interpret_only_run_test_x86_64_riscv64",
"berberis_ndk_program_tests_lite_translate_or_interpret_run_test_x86_64_riscv64",
"berberis_ndk_program_tests_heavy_optimize_or_interpret_run_test_x86_64_riscv64",
"berberis_ndk_program_tests_two_gear_run_test_x86_64_riscv64",
"inline_asm_tests_riscv64_interpret_only_run_test_x86_64_riscv64",
"inline_asm_tests_riscv64_lite_translate_or_interpret_run_test_x86_64_riscv64",
"inline_asm_tests_riscv64_heavy_optimize_or_interpret_run_test_x86_64_riscv64",
"inline_asm_tests_riscv64_two_gear_run_test_x86_64_riscv64",
],
default: [
],
}),
}
phony_rule {
name: "berberis_run_host_tests",
phony_deps: select(soong_config_variable("berberis", "translation_arch"), {
"riscv64_to_x86_64": [
"berberis_run_host_tests_check_errors",
"berberis_run_risc64_tests_check_errors",
],
default: [
],
}),
}
// berberis_ndk_program_tests
genrule_defaults {
name: "berberis_ndk_program_tests_riscv64_defaults",
native_bridge_supported: true,
compile_multilib: "64",
enabled: false,
arch: {
riscv64: {
enabled: true,
},
},
host_first_srcs: [
":berberis_gen_gtest_failure_template",
":berberis_program_runner_riscv64",
":libbase",
":liblog",
":libc++",
":libberberis_riscv64",
],
// Force running with the prebuilt host libc due to b/254755879.
srcs: [
":gcc.sysroot",
":gcc.lib64",
":gcc.lib",
":gcc.lib32",
],
dist: {
targets: ["berberis_host_tests_result"],
dir: "gtest",
},
}
ld_library_path = " LD_LIBRARY_PATH=prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/x86_64-linux/lib64:prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/lib"
prebuilt_ld = "prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.17-4.8/sysroot/usr/lib/ld-linux-x86-64.so.2"
cc_genrule {
name: "berberis_ndk_program_tests_interpret_only_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["berberis_ndk_program_tests_interpret_only_result.xml"],
host_first_srcs: [
":berberis_ndk_program_tests_static_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 berberis_ndk_program_tests_interpret_only > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=interpret-only" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :berberis_ndk_program_tests_static_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
cc_genrule {
name: "berberis_ndk_program_tests_lite_translate_or_interpret_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["berberis_ndk_program_tests_lite_translate_or_interpret_result.xml"],
host_first_srcs: [
":berberis_ndk_program_tests_static_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 berberis_ndk_program_tests_lite_translate_or_interpret > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=lite-translate-or-interpret" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :berberis_ndk_program_tests_static_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
cc_genrule {
name: "berberis_ndk_program_tests_heavy_optimize_or_interpret_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["berberis_ndk_program_tests_heavy_optimize_or_interpret_result.xml"],
host_first_srcs: [
":berberis_ndk_program_tests_static_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 berberis_ndk_program_tests_heavy_optimize_or_interpret > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=heavy-optimize-or-interpret" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :berberis_ndk_program_tests_static_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
cc_genrule {
name: "berberis_ndk_program_tests_two_gear_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["berberis_ndk_program_tests_two_gear_result.xml"],
host_first_srcs: [
":berberis_ndk_program_tests_static_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 berberis_ndk_program_tests_two_gear > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=two-gear" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :berberis_ndk_program_tests_static_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
// inline_asm_tests_riscv64
cc_genrule {
name: "inline_asm_tests_riscv64_interpret_only_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["inline_asm_tests_riscv64_interpret_only_result.xml"],
host_first_srcs: [
":inline_asm_tests_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 inline_asm_tests_riscv64_interpret_only > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=interpret-only" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :inline_asm_tests_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
cc_genrule {
name: "inline_asm_tests_riscv64_lite_translate_or_interpret_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["inline_asm_tests_riscv64_lite_translate_or_interpret_result.xml"],
host_first_srcs: [
":inline_asm_tests_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 inline_asm_tests_riscv64_lite_translate_or_interpret > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=lite-translate-or-interpret" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :inline_asm_tests_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
cc_genrule {
name: "inline_asm_tests_riscv64_heavy_optimize_or_interpret_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["inline_asm_tests_riscv64_heavy_optimize_or_interpret_result.xml"],
host_first_srcs: [
":inline_asm_tests_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 inline_asm_tests_riscv64_heavy_optimize_or_interpret > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=heavy-optimize-or-interpret" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :inline_asm_tests_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
cc_genrule {
name: "inline_asm_tests_riscv64_two_gear_run_test_x86_64_riscv64",
defaults: ["berberis_ndk_program_tests_riscv64_defaults"],
out: ["inline_asm_tests_riscv64_two_gear_result.xml"],
host_first_srcs: [
":inline_asm_tests_riscv64_prebuilt",
],
cmd: "$(location :berberis_gen_gtest_failure_template) berberis_host_tests_riscv64 inline_asm_tests_riscv64_two_gear > $(out)" +
" && cp -t $(genDir) $(location :berberis_program_runner_riscv64) $(location :liblog) $(location :libc++) $(location :libbase) $(location :libberberis_riscv64)" +
" && BERBERIS_MODE=two-gear" +
ld_library_path + " " + prebuilt_ld + " $(genDir)/berberis_program_runner_riscv64 $(location :inline_asm_tests_riscv64_prebuilt) --gtest_output=xml:$(out) ; true",
}
// berberis_host_tests
genrule_defaults {
name: "berberis_host_tests_defaults",
compile_multilib: "64",
host_supported: true,
device_supported: false,
srcs: [
":libbase",
":libc++",
":liblog",
":berberis_host_tests_data_32",
":berberis_host_tests_data_64",
],
host_first_srcs: [
":berberis_gen_gtest_failure_template",
],
cmd: "TEST_BINARY=$$(echo $(in) | tr ' ' '\n' | grep berberis_host_tests | grep -v data | tr '\n' ' ')" + // Pick the actual test binary from input.
// Wrap in a shell command to delay variable substitution until it's executed. Otherwise
// TEST_BINARY would be undefined.
" sh -c '" +
" cp -t $(genDir) $${TEST_BINARY} $(location :liblog) $(location :libc++) $(location :libbase)" +
" && mkdir -p $(genDir)/tiny_loader/tests/files/32 $(genDir)/tiny_loader/tests/files/64" +
" && cp -t $(genDir)/tiny_loader/tests/files/32 $(locations :berberis_host_tests_data_32)" +
" && cp -t $(genDir)/tiny_loader/tests/files/64 $(locations :berberis_host_tests_data_64)" +
" && $(genDir)/$$(basename $${TEST_BINARY}) --gtest_output=xml:$(out) ; true" +
// END OF "sh -c"
"'",
dist: {
targets: ["berberis_host_tests_result"],
dir: "gtest",
},
enabled: select(soong_config_variable("berberis", "translation_arch"), {
"riscv64_to_x86_64": true,
default: false,
}),
target: {
windows: {
enabled: false,
},
},
}
cc_genrule {
name: "berberis_host_tests_64_run_test",
defaults: ["berberis_host_tests_defaults"],
out: ["berberis_host_tests_64_result.xml"],
srcs: [
":berberis_host_tests",
],
}
cc_genrule {
name: "berberis_host_tests_avx_64_run_test",
defaults: ["berberis_host_tests_defaults"],
out: ["berberis_host_tests_avx_64_result.xml"],
srcs: [
":berberis_host_tests_avx",
],
}
cc_genrule {
name: "berberis_host_tests_no_avx_64_run_test",
defaults: ["berberis_host_tests_defaults"],
out: ["berberis_host_tests_no_avx_64_result.xml"],
srcs: [
":berberis_host_tests_no_avx",
],
}
cc_genrule {
name: "berberis_run_host_tests_check_errors",
out: [
"timestamp",
],
cmd: "( [[ \"$$(grep -L 'testsuites.*failures=\"0\"' $(in))\" == \"\" ]] && touch $(out)) || (echo \"Errors found in:\" ; grep -L 'testsuites.*failures=\"0\"' $(in) ; exit 1)",
host_first_srcs: [
":berberis_host_tests_64_run_test",
":berberis_host_tests_avx_64_run_test",
":berberis_host_tests_no_avx_64_run_test",
],
enabled: select(soong_config_variable("berberis", "translation_arch"), {
"riscv64_to_x86_64": true,
default: false,
}),
}
cc_genrule {
name: "berberis_run_risc64_tests_check_errors",
out: [
"timestamp",
],
cmd: "( [[ \"$$(grep -L 'testsuites.*failures=\"0\"' $(in))\" == \"\" ]] && touch $(out)) || (echo \"Errors found in:\" ; grep -L 'testsuites.*failures=\"0\"' $(in) ; exit 1)",
srcs: [
":berberis_ndk_program_tests_interpret_only_run_test_x86_64_riscv64",
":berberis_ndk_program_tests_lite_translate_or_interpret_run_test_x86_64_riscv64",
":berberis_ndk_program_tests_heavy_optimize_or_interpret_run_test_x86_64_riscv64",
":berberis_ndk_program_tests_two_gear_run_test_x86_64_riscv64",
":inline_asm_tests_riscv64_interpret_only_run_test_x86_64_riscv64",
":inline_asm_tests_riscv64_lite_translate_or_interpret_run_test_x86_64_riscv64",
":inline_asm_tests_riscv64_heavy_optimize_or_interpret_run_test_x86_64_riscv64",
":inline_asm_tests_riscv64_two_gear_run_test_x86_64_riscv64",
],
native_bridge_supported: true,
compile_multilib: "64",
enabled: false,
arch: {
riscv64: {
enabled: true,
},
},
}