From ae663543f1fe296910a8d760e8be37c5080adea9 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Mon, 3 Apr 2023 16:01:06 -0700 Subject: Test for differing bp2build files in multiproduct_analysis bp2build should always produce the same build files for the same source tree, regardless of which product we have lunched. Add a test for that. Currently, there are bugs in bp2build that cause it to not produce the same build files all the time, so we can't make this a failure yet. Bug: 247785938 Test: ./multiproduct_analysis.sh Change-Id: I352bedf3aa4ce6fcb3e50e63b40b944cd58b9937 --- ci/multiproduct_analysis.sh | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'ci') diff --git a/ci/multiproduct_analysis.sh b/ci/multiproduct_analysis.sh index ceb59713..2105ea55 100755 --- a/ci/multiproduct_analysis.sh +++ b/ci/multiproduct_analysis.sh @@ -1,15 +1,18 @@ #!/bin/bash -eux -AOSP_ROOT="$(dirname $0)/../../.." -OUT_DIR=$(realpath ${OUT_DIR:-${AOSP_ROOT}/out}) - source "$(dirname $0)/target_lists.sh" +cd "$(dirname $0)/../../.." +OUT_DIR=$(realpath ${OUT_DIR:-out}) + -read -ra PRODUCTS <<<"$(${AOSP_ROOT}/build/soong/soong_ui.bash --dumpvar-mode all_named_products)" +read -ra PRODUCTS <<<"$(build/soong/soong_ui.bash --dumpvar-mode all_named_products)" FAILED_PRODUCTS=() +PRODUCTS_WITH_BP2BUILD_DIFFS=() function report { + # Turn off -x so that we can see the printfs more clearly + set +x # check if FAILED_PRODUCTS is not empty if (( ${#FAILED_PRODUCTS[@]} )); then printf "Failed products:\n" @@ -19,10 +22,23 @@ function report { # TODO(b/261023967): Don't fail the build until every product is OK and we want to prevent backsliding. # exit 1 fi + if (( ${#PRODUCTS_WITH_BP2BUILD_DIFFS[@]} )); then + printf "Products that produced different bp2build files from aosp_arm64:\n" + printf '%s\n' "${PRODUCTS_WITH_BP2BUILD_DIFFS[@]}" + + # TODO(b/261023967): Don't fail the build until every product is OK and we want to prevent backsliding. + # exit 1 + fi } trap report EXIT +# Create zip of the bp2build files for aosp_arm64. We'll check that all other products produce +# identical bp2build files +export TARGET_PRODUCT="aosp_arm64" +build/soong/soong_ui.bash --make-mode --skip-soong-tests bp2build +tar --mtime='1970-01-01' -czf "out/multiproduct_analysis_reference_bp2build_files.tar.gz" -C out/soong/bp2build . + total=${#PRODUCTS[@]} count=1 @@ -33,11 +49,16 @@ for product in "${PRODUCTS[@]}"; do export TARGET_PRODUCT="${product}" # Re-run product config and bp2build for every TARGET_PRODUCT. - "${AOSP_ROOT}/build/soong/soong_ui.bash" --make-mode --skip-soong-tests bp2build + build/soong/soong_ui.bash --make-mode --skip-soong-tests bp2build # Remove the ninja_build output marker file to communicate to buildbot that this is not a regular Ninja build, and its # output should not be parsed as such. rm -f out/ninja_build + rm -f out/multiproduct_analysis_current_bp2build_files.tar.gz + tar --mtime='1970-01-01' -czf "out/multiproduct_analysis_current_bp2build_files.tar.gz" -C out/soong/bp2build . + diff -q out/multiproduct_analysis_current_bp2build_files.tar.gz out/multiproduct_analysis_reference_bp2build_files.tar.gz || \ + PRODUCTS_WITH_BP2BUILD_DIFFS+=("${product}") + STARTUP_FLAGS=( # Keep the Bazel server alive, package cache hot and reduce excessive I/O # and wall time by ensuring that max_idle_secs is longer than bp2build which -- cgit v1.2.3