From ebc01a32254eefdacf453bb47cb2f7c8b64d2891 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Mon, 27 Mar 2023 16:08:03 -0700 Subject: [PATCH] Add testing android products These must be added in the soong_injection code as opposed to just defined loosely in checked-in bzl files because the product_vars select statement must be updated to support the new platforms. Bug: 269577299 Test: b test --config=android //build/bazel/... Change-Id: I7bba9af214896dd3b5938bae70b7c0cea4f75e41 --- bp2build/bp2build_product_config.go | 42 ++++++++++++++++++++++ tests/apex_cc_module_arch_variant_tests.sh | 8 ++--- tests/apex_comparison_tests.sh | 4 +-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/bp2build/bp2build_product_config.go b/bp2build/bp2build_product_config.go index d915d6b64..fdda35b69 100644 --- a/bp2build/bp2build_product_config.go +++ b/bp2build/bp2build_product_config.go @@ -85,6 +85,11 @@ alias( # TODO: When we start generating the platforms for more than just the # currently lunched, product, this select should have an arm for each product. "@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_constraint_value": "@soong_injection//{PRODUCT_FOLDER}:{PRODUCT}-{VARIANT}_product_vars", + "@soong_injection//product_config_platforms/products/aosp_arm_for_testing:aosp_arm_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_arm_for_testing:aosp_arm_for_testing_product_vars", + "@soong_injection//product_config_platforms/products/aosp_arm64_for_testing:aosp_arm64_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_arm64_for_testing:aosp_arm64_for_testing_product_vars", + "@soong_injection//product_config_platforms/products/aosp_x86_for_testing:aosp_x86_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_x86_for_testing:aosp_x86_for_testing_product_vars", + "@soong_injection//product_config_platforms/products/aosp_x86_64_for_testing:aosp_x86_64_for_testing_constraint_value": "@soong_injection//product_config_platforms/products/aosp_x86_64_for_testing:aosp_x86_64_for_testing_product_vars", + "@soong_injection//product_config_platforms/products/aosp_arm64_for_testing_no_compression:aosp_arm64_for_testing_no_compression_constraint_value": "@soong_injection//product_config_platforms/products/aosp_arm64_for_testing_no_compression:aosp_arm64_for_testing_no_compression_product_vars", }), ) `)), @@ -122,5 +127,42 @@ flags: `)), } + // Add some products for testing + for _, arch := range []string{"arm", "arm64", "x86", "x86_64"} { + result = append(result, newFile( + fmt.Sprintf("product_config_platforms/products/aosp_%s_for_testing", arch), + "BUILD", + fmt.Sprintf(` +package(default_visibility=[ + "@soong_injection//product_config_platforms:__subpackages__", + "@//build/bazel/product_config:__subpackages__", +]) +load("@//build/bazel/tests/products:aosp_%s.variables.bzl", _soong_variables = "variables") +load("@//build/bazel/product_config:android_product.bzl", "android_product") + +android_product( + name = "aosp_%s_for_testing", + soong_variables = _soong_variables, +) +`, arch, arch))) + } + result = append(result, newFile( + "product_config_platforms/products/aosp_arm64_for_testing_no_compression", + "BUILD", + ` +package(default_visibility=[ + "@soong_injection//product_config_platforms:__subpackages__", + "@//build/bazel/product_config:__subpackages__", +]) +load("@bazel_skylib//lib:dicts.bzl", "dicts") +load("@//build/bazel/tests/products:aosp_arm64.variables.bzl", _soong_variables = "variables") +load("@//build/bazel/product_config:android_product.bzl", "android_product") + +android_product( + name = "aosp_arm64_for_testing_no_compression", + soong_variables = dicts.add(_soong_variables, {"CompressedApex": False}), +) +`)) + return result, nil } diff --git a/tests/apex_cc_module_arch_variant_tests.sh b/tests/apex_cc_module_arch_variant_tests.sh index b0cade19f..1f5e003ff 100755 --- a/tests/apex_cc_module_arch_variant_tests.sh +++ b/tests/apex_cc_module_arch_variant_tests.sh @@ -56,12 +56,12 @@ build/soong/soong_ui.bash --make-mode BP2BUILD_VERBOSE=1 --skip-soong-tests bp2b # Number of CppCompile actions with arch variant flag actions_with_arch_variant_num=$(call_bazel aquery --config=bp2build --config=ci --config=android \ - 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex))' | grep -c \'-march=$ARCH_VARIANT_CFLAG\') + 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal))' | grep -c \'-march=$ARCH_VARIANT_CFLAG\') # Number of all CppCompile actions all_cppcompile_actions_num=0 aquery_summary=$(call_bazel aquery --config=bp2build --config=ci --config=android --output=summary \ - 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex))' \ + 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal))' \ | egrep -o '.*opt-ST.*: ([0-9]+)$' \ | cut -d: -f2 -) @@ -82,7 +82,7 @@ if [ $CPU_VARIANT_CFLAG ] then # Number of CppCompiler actions with cpu variant flag actions_with_cpu_variant_num=$(call_bazel aquery --config=bp2build --config=ci --config=android \ - 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex))' | grep -c "\-mcpu=$CPU_VARIANT_CFLAG") + 'mnemonic("CppCompile", deps(//build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal))' | grep -c "\-mcpu=$CPU_VARIANT_CFLAG") if [ $actions_with_cpu_variant_num -eq $all_cppcompile_actions_num ] then @@ -91,4 +91,4 @@ then echo "Error: number of CppCompile actions with cpu variant set: actual=$actions_with_cpu_variant_num, expected=$all_cppcompile_actions_num" exit 1 fi -fi \ No newline at end of file +fi diff --git a/tests/apex_comparison_tests.sh b/tests/apex_comparison_tests.sh index 50070789a..e350323f3 100755 --- a/tests/apex_comparison_tests.sh +++ b/tests/apex_comparison_tests.sh @@ -66,10 +66,10 @@ BAZEL_OUT="$(call_bazel info --config=bp2build output_path)" call_bazel build --config=bp2build --config=ci --config=android \ //packages/modules/adb/apex:com.android.adbd \ //system/timezone/apex:com.android.tzdata \ - //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex + //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal BAZEL_ADBD="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files //packages/modules/adb/apex:com.android.adbd))" BAZEL_TZDATA="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files //system/timezone/apex:com.android.tzdata))" -BAZEL_MINIMAL="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal.apex))" +BAZEL_MINIMAL="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files //build/bazel/examples/apex/minimal:build.bazel.examples.apex.minimal))" # # Build debugfs separately, as it's not a dep of apexer, but needs to be an explicit arg. call_bazel build --config=bp2build --config=linux_x86_64 //external/e2fsprogs/debugfs //system/apex/tools:deapexer