Fixes for run_integration_tests.sh
This script runs some useful integration tests, but is currently broken
at ToT. This CL enables us to rerun this script successfully.
Details
1. Remove the scripts related to bp2build/b/mixed_builds. These modes
have been/are on the verge of deletion from soong
2. Remove the comparisision scripts for soong and bazel built artifcats,
for the same reason
3. Add a TARGET_RELEASE to androidmk_test.sh
4. Add a TARGET_PRODUCT to o/s/build.ninja, since the generated .ninja files
now have a product-specific suffix.
5. Remove a test that checks that globs are not generated in the first
clean run. We always generate the glob file now (aosp/2893286)
Test: build/soong/tests/run_integration_tests.sh
Change-Id: I39f6706ab2a81a7b1b2e90d43195bc3e2c7a5c08
diff --git a/tests/androidmk_test.sh b/tests/androidmk_test.sh
index b81828b..aecc4e8 100755
--- a/tests/androidmk_test.sh
+++ b/tests/androidmk_test.sh
@@ -5,7 +5,7 @@
# How to run: bash path-to-script/androidmk_test.sh
# Tests of converting license functionality of the androidmk tool
REAL_TOP="$(readlink -f "$(dirname "$0")"/../../..)"
-"$REAL_TOP/build/soong/soong_ui.bash" --make-mode androidmk
+"$REAL_TOP/build/soong/soong_ui.bash" --make-mode TARGET_RELEASE=trunk_staging androidmk
source "$(dirname "$0")/lib.sh"
diff --git a/tests/apex_cc_module_arch_variant_tests.sh b/tests/apex_cc_module_arch_variant_tests.sh
deleted file mode 100755
index 1f5e003..0000000
--- a/tests/apex_cc_module_arch_variant_tests.sh
+++ /dev/null
@@ -1,94 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2022 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.
-
-set -uo pipefail
-
-# Integration test for verifying arch variant cflags set on cc modules included
-# in Bazel-built apexes in the real source tree.
-
-if [ ! -e "build/make/core/Makefile" ]; then
- echo "$0 must be run from the top of the Android source tree."
- exit 1
-fi
-
-############
-# Test Setup
-############
-
-OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
-BAZEL_OUTPUT_DIR="$OUTPUT_DIR/bazel"
-
-export TARGET_PRODUCT="aosp_arm64"
-[ "$#" -ge 1 ] && export TARGET_PRODUCT="$1"
-ARCH_VARIANT_CFLAG="armv8-a"
-[ "$#" -ge 2 ] && ARCH_VARIANT_CFLAG="$2"
-CPU_VARIANT_CFLAG=""
-[ "$#" -ge 3 ] && CPU_VARIANT_CFLAG="$3"
-
-function call_bazel() {
- build/bazel/bin/bazel --output_base="$BAZEL_OUTPUT_DIR" $@
-}
-
-function cleanup {
- # call bazel clean because some bazel outputs don't have w bits.
- call_bazel clean
- rm -rf "${OUTPUT_DIR}"
-}
-trap cleanup EXIT
-
-######################
-# Run bp2build / Bazel
-######################
-build/soong/soong_ui.bash --make-mode BP2BUILD_VERBOSE=1 --skip-soong-tests bp2build
-
-# 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))' | 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))' \
- | egrep -o '.*opt-ST.*: ([0-9]+)$' \
- | cut -d: -f2 -)
-
-while read -r num;
-do
- all_cppcompile_actions_num=$(($all_cppcompile_actions_num + $num))
-done <<< "$aquery_summary"
-
-if [ $actions_with_arch_variant_num -eq $all_cppcompile_actions_num ]
-then
- echo "Pass: arch variant is set."
-else
- echo "Error: number of CppCompile actions with arch variant set: actual=$actions_with_arch_variant_num, expected=$all_cppcompile_actions_num"
- exit 1
-fi
-
-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))' | grep -c "\-mcpu=$CPU_VARIANT_CFLAG")
-
- if [ $actions_with_cpu_variant_num -eq $all_cppcompile_actions_num ]
- then
- echo "Pass: cpu variant is set."
- else
- 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
diff --git a/tests/apex_comparison_tests.sh b/tests/apex_comparison_tests.sh
deleted file mode 100755
index 8893060..0000000
--- a/tests/apex_comparison_tests.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2022 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.
-
-set -euo pipefail
-
-# Soong/Bazel integration test for building unbundled apexes in the real source tree.
-#
-# These tests build artifacts from head and compares their contents.
-
-if [ ! -e "build/make/core/Makefile" ]; then
- echo "$0 must be run from the top of the Android source tree."
- exit 1
-fi
-
-############
-# Test Setup
-############
-
-OUTPUT_DIR="$(mktemp -d $(pwd)/tmp.XXXXXX)"
-SOONG_OUTPUT_DIR="$OUTPUT_DIR/soong"
-BAZEL_OUTPUT_DIR="$OUTPUT_DIR/bazel"
-
-export TARGET_PRODUCT="module_arm"
-[ "$#" -eq 1 ] && export TARGET_PRODUCT="$1"
-
-function call_bazel() {
- build/bazel/bin/bazel --output_base="$BAZEL_OUTPUT_DIR" $@
-}
-
-function cleanup {
- # call bazel clean because some bazel outputs don't have w bits.
- call_bazel clean
- rm -rf "${OUTPUT_DIR}"
-}
-
-function deapexer() {
- DEBUGFS_PATH="$(realpath $(call_bazel cquery --config=bp2build --config=linux_x86_64 --config=ci --output=files //external/e2fsprogs/debugfs))"
- call_bazel run --config=bp2build //system/apex/tools:deapexer -- --debugfs_path=$DEBUGFS_PATH $@
-}
-
-trap cleanup EXIT
-
-###########
-# Run Soong
-###########
-export UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true # don't rely on prebuilts
-export TARGET_BUILD_APPS="com.android.adbd com.android.tzdata build.bazel.examples.apex.minimal"
-packages/modules/common/build/build_unbundled_mainline_module.sh \
- --product "$TARGET_PRODUCT" \
- --dist_dir "$SOONG_OUTPUT_DIR"
-
-######################
-# Run bp2build / Bazel
-######################
-build/soong/soong_ui.bash --make-mode BP2BUILD_VERBOSE=1 --skip-soong-tests bp2build
-
-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
-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))"
-
-# # 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
-
-#######
-# Tests
-#######
-
-function compare_deapexer_list() {
- local BAZEL_APEX=$1; shift
- local APEX=$1; shift
-
- # Compare the outputs of `deapexer list`, which lists the contents of the apex filesystem image.
- local SOONG_APEX="$SOONG_OUTPUT_DIR/$APEX"
-
- local SOONG_LIST="$OUTPUT_DIR/soong.list"
- local BAZEL_LIST="$OUTPUT_DIR/bazel.list"
-
- deapexer list "$SOONG_APEX" > "$SOONG_LIST"
- deapexer list "$BAZEL_APEX" > "$BAZEL_LIST"
-
- if cmp -s "$SOONG_LIST" "$BAZEL_LIST"
- then
- echo "ok: $APEX"
- else
- echo "contents of $APEX are different between Soong and Bazel:"
- echo
- echo expected
- echo
- cat "$SOONG_LIST"
- echo
- echo got
- echo
- cat "$BAZEL_LIST"
- exit 1
- fi
-}
-
-compare_deapexer_list "${BAZEL_ADBD}" com.android.adbd.apex
-compare_deapexer_list "${BAZEL_TZDATA}" com.android.tzdata.apex
-compare_deapexer_list "${BAZEL_MINIMAL}" build.bazel.examples.apex.minimal.apex
diff --git a/tests/bootstrap_test.sh b/tests/bootstrap_test.sh
index 5fc05f8..2e40950 100755
--- a/tests/bootstrap_test.sh
+++ b/tests/bootstrap_test.sh
@@ -9,6 +9,8 @@
readonly GENERATED_BUILD_FILE_NAME="BUILD.bazel"
+readonly target_product="${TARGET_PRODUCT:-aosp_arm}"
+
function test_smoke {
setup
run_soong
@@ -18,10 +20,10 @@
setup
run_soong
local -r bootstrap_mtime1=$(stat -c "%y" out/soong/bootstrap.ninja)
- local -r output_mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r output_mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
run_soong
local -r bootstrap_mtime2=$(stat -c "%y" out/soong/bootstrap.ninja)
- local -r output_mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r output_mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$bootstrap_mtime1" == "$bootstrap_mtime2" ]]; then
# Bootstrapping is always done. It doesn't take a measurable amount of time.
@@ -60,7 +62,7 @@
touch a/my_little_binary_host.py
run_soong
- grep -q "^# Module:.*my_little_binary_host" out/soong/build.ninja || fail "module not found"
+ grep -q "^# Module:.*my_little_binary_host" out/soong/build."${target_product}".ninja || fail "module not found"
cat > a/Android.bp <<'EOF'
python_binary_host {
@@ -71,14 +73,14 @@
touch a/my_great_binary_host.py
run_soong
- grep -q "^# Module:.*my_little_binary_host" out/soong/build.ninja && fail "old module found"
- grep -q "^# Module:.*my_great_binary_host" out/soong/build.ninja || fail "new module not found"
+ grep -q "^# Module:.*my_little_binary_host" out/soong/build."${target_product}".ninja && fail "old module found"
+ grep -q "^# Module:.*my_great_binary_host" out/soong/build."${target_product}".ninja || fail "new module not found"
}
function test_add_android_bp() {
setup
run_soong
- local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
mkdir -p a
cat > a/Android.bp <<'EOF'
@@ -90,12 +92,12 @@
touch a/my_little_binary_host.py
run_soong
- local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change"
fi
- grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja || fail "New module not in output"
+ grep -q "^# Module:.*my_little_binary_host$" out/soong/build."${target_product}".ninja || fail "New module not in output"
run_soong
}
@@ -112,12 +114,12 @@
touch a/my_little_binary_host.py
run_soong
- grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja || fail "Module not in output"
+ grep -q "^# Module:.*my_little_binary_host$" out/soong/build."${target_product}".ninja || fail "Module not in output"
rm a/Android.bp
run_soong
- if grep -q "^# Module:.*my_little_binary_host$" out/soong/build.ninja; then
+ if grep -q "^# Module:.*my_little_binary_host$" out/soong/build."${target_product}".ninja; then
fail "Old module in output"
fi
}
@@ -141,16 +143,12 @@
EOF
touch a/my_little_binary_host.py
run_soong
- local -r ninja_mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r ninja_mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
- local glob_deps_file=out/soong/globs/build/0.d
-
- if [ -e "$glob_deps_file" ]; then
- fail "Glob deps file unexpectedly written on first build"
- fi
+ local glob_deps_file=out/soong/globs/"${target_product}"/0.d
run_soong
- local -r ninja_mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r ninja_mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
# There is an ineffiencency in glob that requires bpglob to rerun once for each glob to update
# the entry in the .ninja_log. It doesn't update the output file, but we can detect the rerun
@@ -166,7 +164,7 @@
fi
run_soong
- local -r ninja_mtime3=$(stat -c "%y" out/soong/build.ninja)
+ local -r ninja_mtime3=$(stat -c "%y" out/soong/build."${target_product}".ninja)
local -r glob_deps_mtime3=$(stat -c "%y" "$glob_deps_file")
if [[ "$ninja_mtime2" != "$ninja_mtime3" ]]; then
@@ -191,17 +189,17 @@
EOF
touch a/my_little_binary_host.py
run_soong
- local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
touch a/my_little_library.py
run_soong
- local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change"
fi
- grep -q my_little_library.py out/soong/build.ninja || fail "new file is not in output"
+ grep -q my_little_library.py out/soong/build."${target_product}".ninja || fail "new file is not in output"
}
function test_soong_build_rerun_iff_environment_changes() {
@@ -267,17 +265,17 @@
export CHERRY=TASTY
run_soong
- grep -q "CHERRY IS TASTY" out/soong/build.ninja \
+ grep -q "CHERRY IS TASTY" out/soong/build."${target_product}".ninja \
|| fail "first value of environment variable is not used"
export CHERRY=RED
run_soong
- grep -q "CHERRY IS RED" out/soong/build.ninja \
+ grep -q "CHERRY IS RED" out/soong/build."${target_product}".ninja \
|| fail "second value of environment variable not used"
- local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
run_soong
- local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime1" != "$mtime2" ]]; then
fail "Output Ninja file changed when environment variable did not"
fi
@@ -287,7 +285,7 @@
function test_create_global_include_directory() {
setup
run_soong
- local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
# Soong needs to know if top level directories like hardware/ exist for use
# as global include directories. Make sure that doesn't cause regens for
@@ -295,7 +293,7 @@
mkdir -p system/core
run_soong
- local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime1" != "$mtime2" ]]; then
fail "Output Ninja file changed when top level directory changed"
fi
@@ -305,7 +303,7 @@
mkdir -p system/core/include
run_soong
- local -r mtime3=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime3=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime2" = "$mtime3" ]]; then
fail "Output Ninja file did not change when global include directory created"
fi
@@ -315,7 +313,7 @@
function test_add_file_to_soong_build() {
setup
run_soong
- local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
mkdir -p vendor/foo/picard
cat > vendor/foo/picard/Android.bp <<'EOF'
@@ -377,12 +375,12 @@
EOF
run_soong
- local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change"
fi
- grep -q "Make it so" out/soong/build.ninja || fail "New action not present"
+ grep -q "Make it so" out/soong/build."${target_product}".ninja || fail "New action not present"
}
# Tests a glob in a build= statement in an Android.bp file, which is interpreted
@@ -455,9 +453,9 @@
EOF
run_soong
- local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
- grep -q "Make it so" out/soong/build.ninja || fail "Original action not present"
+ grep -q "Make it so" out/soong/build."${target_product}".ninja || fail "Original action not present"
cat > build/soong/picard/foob.bp <<'EOF'
bootstrap_go_package {
@@ -487,14 +485,14 @@
EOF
run_soong
- local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change"
fi
- grep -q "Engage" out/soong/build.ninja || fail "New action not present"
+ grep -q "Engage" out/soong/build."${target_product}".ninja || fail "New action not present"
- if grep -q "Make it so" out/soong/build.ninja; then
+ if grep -q "Make it so" out/soong/build."${target_product}".ninja; then
fail "Original action still present"
fi
}
@@ -512,7 +510,7 @@
setup
run_soong
- local -r ninja_mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r ninja_mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
run_soong soong_docs
local -r docs_mtime1=$(stat -c "%y" out/soong/docs/soong_build.html)
@@ -525,7 +523,7 @@
fi
run_soong
- local -r ninja_mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r ninja_mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then
fail "Output Ninja file changed on null build"
@@ -565,144 +563,6 @@
fi
}
-function test_bp2build_smoke {
- setup
- run_soong bp2build
- [[ -e out/soong/bp2build_workspace_marker ]] || fail "bp2build marker file not created"
- [[ -e out/soong/workspace ]] || fail "Bazel workspace not created"
-}
-
-function test_bp2build_generates_marker_file {
- setup
-
- run_soong bp2build
-
- if [[ ! -f "./out/soong/bp2build_files_marker" ]]; then
- fail "bp2build marker file was not generated"
- fi
-
- if [[ ! -f "./out/soong/bp2build_workspace_marker" ]]; then
- fail "symlink forest marker file was not generated"
- fi
-}
-
-function test_bp2build_add_irrelevant_file {
- setup
-
- mkdir -p a/b
- touch a/b/c.txt
- cat > a/b/Android.bp <<'EOF'
-filegroup {
- name: "c",
- srcs: ["c.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong bp2build
- if [[ ! -e out/soong/bp2build/a/b/BUILD.bazel ]]; then
- fail "BUILD file in symlink forest was not created";
- fi
-
- local -r mtime1=$(stat -c "%y" out/soong/bp2build/a/b/BUILD.bazel)
-
- touch a/irrelevant.txt
- run_soong bp2build
- local -r mtime2=$(stat -c "%y" out/soong/bp2build/a/b/BUILD.bazel)
-
- if [[ "$mtime1" != "$mtime2" ]]; then
- fail "BUILD.bazel file was regenerated"
- fi
-
- if [[ ! -e "out/soong/workspace/a/irrelevant.txt" ]]; then
- fail "New file was not symlinked into symlink forest"
- fi
-}
-
-function test_bp2build_add_android_bp {
- setup
-
- mkdir -p a
- touch a/a.txt
- cat > a/Android.bp <<'EOF'
-filegroup {
- name: "a",
- srcs: ["a.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong bp2build
- [[ -e out/soong/bp2build/a/${GENERATED_BUILD_FILE_NAME} ]] || fail "a/${GENERATED_BUILD_FILE_NAME} not created"
- [[ -L out/soong/workspace/a/${GENERATED_BUILD_FILE_NAME} ]] || fail "a/${GENERATED_BUILD_FILE_NAME} not symlinked"
-
- mkdir -p b
- touch b/b.txt
- cat > b/Android.bp <<'EOF'
-filegroup {
- name: "b",
- srcs: ["b.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong bp2build
- [[ -e out/soong/bp2build/b/${GENERATED_BUILD_FILE_NAME} ]] || fail "a/${GENERATED_BUILD_FILE_NAME} not created"
- [[ -L out/soong/workspace/b/${GENERATED_BUILD_FILE_NAME} ]] || fail "a/${GENERATED_BUILD_FILE_NAME} not symlinked"
-}
-
-function test_bp2build_null_build {
- setup
-
- run_soong bp2build
- local -r mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- run_soong bp2build
- local -r mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- if [[ "$mtime1" != "$mtime2" ]]; then
- fail "Output Ninja file changed on null build"
- fi
-}
-
-function test_bp2build_add_to_glob {
- setup
-
- mkdir -p a
- touch a/a1.txt
- cat > a/Android.bp <<'EOF'
-filegroup {
- name: "a",
- srcs: ["*.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong bp2build
- grep -q a1.txt "out/soong/bp2build/a/${GENERATED_BUILD_FILE_NAME}" || fail "a1.txt not in ${GENERATED_BUILD_FILE_NAME} file"
-
- touch a/a2.txt
- run_soong bp2build
- grep -q a2.txt "out/soong/bp2build/a/${GENERATED_BUILD_FILE_NAME}" || fail "a2.txt not in ${GENERATED_BUILD_FILE_NAME} file"
-}
-
-function test_multiple_soong_build_modes() {
- setup
- run_soong json-module-graph bp2build nothing
- if [[ ! -f "out/soong/bp2build_workspace_marker" ]]; then
- fail "bp2build marker file was not generated"
- fi
-
-
- if [[ ! -f "out/soong/module-graph.json" ]]; then
- fail "JSON file was not created"
- fi
-
- if [[ ! -f "out/soong/build.ninja" ]]; then
- fail "Main build.ninja file was not created"
- fi
-}
-
function test_dump_json_module_graph() {
setup
run_soong json-module-graph
@@ -715,13 +575,13 @@
setup
run_soong
- local -r ninja_mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r ninja_mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
run_soong json-module-graph
local -r json_mtime1=$(stat -c "%y" out/soong/module-graph.json)
run_soong
- local -r ninja_mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r ninja_mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then
fail "Output Ninja file changed after writing JSON module graph"
fi
@@ -734,143 +594,6 @@
}
-function test_bp2build_bazel_workspace_structure {
- setup
-
- mkdir -p a/b
- touch a/a.txt
- touch a/b/b.txt
- cat > a/b/Android.bp <<'EOF'
-filegroup {
- name: "b",
- srcs: ["b.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong bp2build
- [[ -e out/soong/workspace ]] || fail "Bazel workspace not created"
- [[ -d out/soong/workspace/a/b ]] || fail "module directory not a directory"
- [[ -L "out/soong/workspace/a/b/${GENERATED_BUILD_FILE_NAME}" ]] || fail "${GENERATED_BUILD_FILE_NAME} file not symlinked"
- [[ "$(readlink -f out/soong/workspace/a/b/${GENERATED_BUILD_FILE_NAME})" =~ "bp2build/a/b/${GENERATED_BUILD_FILE_NAME}"$ ]] \
- || fail "BUILD files symlinked at the wrong place"
- [[ -L out/soong/workspace/a/b/b.txt ]] || fail "a/b/b.txt not symlinked"
- [[ -L out/soong/workspace/a/a.txt ]] || fail "a/b/a.txt not symlinked"
- [[ ! -e out/soong/workspace/out ]] || fail "out directory symlinked"
-}
-
-function test_bp2build_bazel_workspace_add_file {
- setup
-
- mkdir -p a
- touch a/a.txt
- cat > a/Android.bp <<EOF
-filegroup {
- name: "a",
- srcs: ["a.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong bp2build
-
- touch a/a2.txt # No reference in the .bp file needed
- run_soong bp2build
- [[ -L out/soong/workspace/a/a2.txt ]] || fail "a/a2.txt not symlinked"
-}
-
-function test_bp2build_build_file_precedence {
- setup
-
- mkdir -p a
- touch a/a.txt
- touch a/${GENERATED_BUILD_FILE_NAME}
- cat > a/Android.bp <<EOF
-filegroup {
- name: "a",
- srcs: ["a.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong bp2build
- [[ -L "out/soong/workspace/a/${GENERATED_BUILD_FILE_NAME}" ]] || fail "${GENERATED_BUILD_FILE_NAME} file not symlinked"
- [[ "$(readlink -f out/soong/workspace/a/${GENERATED_BUILD_FILE_NAME})" =~ "bp2build/a/${GENERATED_BUILD_FILE_NAME}"$ ]] \
- || fail "${GENERATED_BUILD_FILE_NAME} files symlinked to the wrong place"
-}
-
-function test_bp2build_fails_fast {
- setup
-
- mkdir -p "a/${GENERATED_BUILD_FILE_NAME}"
- cat > a/Android.bp <<EOF
-filegroup {
- name: "a",
- srcs: ["a.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- mkdir -p "b/${GENERATED_BUILD_FILE_NAME}"
- cat > b/Android.bp <<EOF
-filegroup {
- name: "b",
- srcs: ["b.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- if run_soong bp2build >& "$MOCK_TOP/errors"; then
- fail "Build should have failed"
- fi
-
- # we should expect at least one error
- grep -q -E "(a|b)/${GENERATED_BUILD_FILE_NAME}' exist" "$MOCK_TOP/errors" || fail "Error for ${GENERATED_BUILD_FILE_NAME} not found"
-}
-
-function test_bp2build_back_and_forth_null_build {
- setup
-
- run_soong
- local -r output_mtime1=$(stat -c "%y" out/soong/build.ninja)
-
- run_soong bp2build
- local -r output_mtime2=$(stat -c "%y" out/soong/build.ninja)
- if [[ "$output_mtime1" != "$output_mtime2" ]]; then
- fail "Output Ninja file changed when switching to bp2build"
- fi
-
- local -r marker_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- run_soong
- local -r output_mtime3=$(stat -c "%y" out/soong/build.ninja)
- local -r marker_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
- if [[ "$output_mtime1" != "$output_mtime3" ]]; then
- fail "Output Ninja file changed when switching to regular build from bp2build"
- fi
- if [[ "$marker_mtime1" != "$marker_mtime2" ]]; then
- fail "bp2build marker file changed when switching to regular build from bp2build"
- fi
-
- run_soong bp2build
- local -r output_mtime4=$(stat -c "%y" out/soong/build.ninja)
- local -r marker_mtime3=$(stat -c "%y" out/soong/bp2build_workspace_marker)
- if [[ "$output_mtime1" != "$output_mtime4" ]]; then
- fail "Output Ninja file changed when switching back to bp2build"
- fi
- if [[ "$marker_mtime1" != "$marker_mtime3" ]]; then
- fail "bp2build marker file changed when switching back to bp2build"
- fi
-}
-
-function test_queryview_smoke() {
- setup
-
- run_soong queryview
- [[ -e out/soong/queryview/WORKSPACE ]] || fail "queryview WORKSPACE file not created"
-
-}
-
function test_queryview_null_build() {
setup
@@ -886,14 +609,14 @@
}
# This test verifies that adding a new glob to a blueprint file only
-# causes build.ninja to be regenerated on the *next* build, and *not*
+# causes build."${target_product}".ninja to be regenerated on the *next* build, and *not*
# the build after. (This is a regression test for a bug where globs
# resulted in two successive regenerations.)
function test_new_glob_incrementality {
setup
run_soong nothing
- local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
mkdir -p globdefpkg/
cat > globdefpkg/Android.bp <<'EOF'
@@ -904,14 +627,14 @@
EOF
run_soong nothing
- local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime1" == "$mtime2" ]]; then
fail "Ninja file was not regenerated, despite a new bp file"
fi
run_soong nothing
- local -r mtime3=$(stat -c "%y" out/soong/build.ninja)
+ local -r mtime3=$(stat -c "%y" out/soong/build."${target_product}".ninja)
if [[ "$mtime2" != "$mtime3" ]]; then
fail "Ninja file was regenerated despite no previous bp changes"
diff --git a/tests/bp2build_bazel_test.sh b/tests/bp2build_bazel_test.sh
deleted file mode 100755
index 8a64a56..0000000
--- a/tests/bp2build_bazel_test.sh
+++ /dev/null
@@ -1,445 +0,0 @@
-#!/bin/bash -eu
-
-set -o pipefail
-
-# Test that bp2build and Bazel can play nicely together
-
-source "$(dirname "$0")/lib.sh"
-
-readonly GENERATED_BUILD_FILE_NAME="BUILD.bazel"
-
-function test_bp2build_null_build {
- setup
- run_soong bp2build
- local -r output_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- run_soong bp2build
- local -r output_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- if [[ "$output_mtime1" != "$output_mtime2" ]]; then
- fail "Output bp2build marker file changed on null build"
- fi
-}
-
-# Tests that, if bp2build reruns due to a blueprint file changing, that
-# BUILD files whose contents are unchanged are not regenerated.
-function test_bp2build_unchanged {
- setup
-
- mkdir -p pkg
- touch pkg/x.txt
- cat > pkg/Android.bp <<'EOF'
-filegroup {
- name: "x",
- srcs: ["x.txt"],
- bazel_module: {bp2build_available: true},
- }
-EOF
-
- run_soong bp2build
- local -r buildfile_mtime1=$(stat -c "%y" out/soong/bp2build/pkg/BUILD.bazel)
- local -r marker_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- # Force bp2build to rerun by updating the timestamp of a blueprint file.
- touch pkg/Android.bp
-
- run_soong bp2build
- local -r buildfile_mtime2=$(stat -c "%y" out/soong/bp2build/pkg/BUILD.bazel)
- local -r marker_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- if [[ "$marker_mtime1" == "$marker_mtime2" ]]; then
- fail "Expected bp2build marker file to change"
- fi
- if [[ "$buildfile_mtime1" != "$buildfile_mtime2" ]]; then
- fail "BUILD.bazel was updated even though contents are same"
- fi
-
- # Force bp2build to rerun by updating the timestamp of the constants_exported_to_soong.bzl file.
- touch build/bazel/constants_exported_to_soong.bzl
-
- run_soong bp2build
- local -r buildfile_mtime3=$(stat -c "%y" out/soong/bp2build/pkg/BUILD.bazel)
- local -r marker_mtime3=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- if [[ "$marker_mtime2" == "$marker_mtime3" ]]; then
- fail "Expected bp2build marker file to change"
- fi
- if [[ "$buildfile_mtime2" != "$buildfile_mtime3" ]]; then
- fail "BUILD.bazel was updated even though contents are same"
- fi
-}
-
-# Tests that blueprint files that are deleted are not present when the
-# bp2build tree is regenerated.
-function test_bp2build_deleted_blueprint {
- setup
-
- mkdir -p pkg
- touch pkg/x.txt
- cat > pkg/Android.bp <<'EOF'
-filegroup {
- name: "x",
- srcs: ["x.txt"],
- bazel_module: {bp2build_available: true},
- }
-EOF
-
- run_soong bp2build
- if [[ ! -e "./out/soong/bp2build/pkg/BUILD.bazel" ]]; then
- fail "Expected pkg/BUILD.bazel to be generated"
- fi
-
- rm pkg/Android.bp
-
- run_soong bp2build
- if [[ -e "./out/soong/bp2build/pkg/BUILD.bazel" ]]; then
- fail "Expected pkg/BUILD.bazel to be deleted"
- fi
-}
-
-function test_bp2build_null_build_with_globs {
- setup
-
- mkdir -p foo/bar
- cat > foo/bar/Android.bp <<'EOF'
-filegroup {
- name: "globs",
- srcs: ["*.txt"],
- }
-EOF
- touch foo/bar/a.txt foo/bar/b.txt
-
- run_soong bp2build
- local -r output_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- run_soong bp2build
- local -r output_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
-
- if [[ "$output_mtime1" != "$output_mtime2" ]]; then
- fail "Output bp2build marker file changed on null build"
- fi
-}
-
-function test_different_relative_outdir {
- setup
-
- mkdir -p a
- touch a/g.txt
- cat > a/Android.bp <<'EOF'
-filegroup {
- name: "g",
- srcs: ["g.txt"],
- bazel_module: {bp2build_available: true},
- }
-EOF
-
- # A directory under $MOCK_TOP
- outdir=out2
- trap "rm -rf $outdir" EXIT
- # Modify OUT_DIR in a subshell so it doesn't affect the top level one.
- (export OUT_DIR=$outdir; run_soong bp2build && run_bazel build --config=bp2build --config=ci //a:g)
-}
-
-function test_different_absolute_outdir {
- setup
-
- mkdir -p a
- touch a/g.txt
- cat > a/Android.bp <<'EOF'
-filegroup {
- name: "g",
- srcs: ["g.txt"],
- bazel_module: {bp2build_available: true},
- }
-EOF
-
- # A directory under /tmp/...
- outdir=$(mktemp -t -d st.XXXXX)
- trap 'rm -rf $outdir' EXIT
- # Modify OUT_DIR in a subshell so it doesn't affect the top level one.
- (export OUT_DIR=$outdir; run_soong bp2build && run_bazel build --config=bp2build --config=ci //a:g)
-}
-
-function _bp2build_generates_all_buildfiles {
- setup
-
- mkdir -p foo/convertible_soong_module
- cat > foo/convertible_soong_module/Android.bp <<'EOF'
-genrule {
- name: "the_answer",
- cmd: "echo '42' > $(out)",
- out: [
- "the_answer.txt",
- ],
- bazel_module: {
- bp2build_available: true,
- },
- }
-EOF
-
- mkdir -p foo/unconvertible_soong_module
- cat > foo/unconvertible_soong_module/Android.bp <<'EOF'
-genrule {
- name: "not_the_answer",
- cmd: "echo '43' > $(out)",
- out: [
- "not_the_answer.txt",
- ],
- bazel_module: {
- bp2build_available: false,
- },
- }
-EOF
-
- run_soong bp2build
-
- if [[ ! -f "./out/soong/workspace/foo/convertible_soong_module/${GENERATED_BUILD_FILE_NAME}" ]]; then
- fail "./out/soong/workspace/foo/convertible_soong_module/${GENERATED_BUILD_FILE_NAME} was not generated"
- fi
-
- if [[ ! -f "./out/soong/workspace/foo/unconvertible_soong_module/${GENERATED_BUILD_FILE_NAME}" ]]; then
- fail "./out/soong/workspace/foo/unconvertible_soong_module/${GENERATED_BUILD_FILE_NAME} was not generated"
- fi
-
- if ! grep "the_answer" "./out/soong/workspace/foo/convertible_soong_module/${GENERATED_BUILD_FILE_NAME}"; then
- fail "missing BUILD target the_answer in convertible_soong_module/${GENERATED_BUILD_FILE_NAME}"
- fi
-
- if grep "not_the_answer" "./out/soong/workspace/foo/unconvertible_soong_module/${GENERATED_BUILD_FILE_NAME}"; then
- fail "found unexpected BUILD target not_the_answer in unconvertible_soong_module/${GENERATED_BUILD_FILE_NAME}"
- fi
-
- if ! grep "filegroup" "./out/soong/workspace/foo/unconvertible_soong_module/${GENERATED_BUILD_FILE_NAME}"; then
- fail "missing filegroup in unconvertible_soong_module/${GENERATED_BUILD_FILE_NAME}"
- fi
-
- # NOTE: We don't actually use the extra BUILD file for anything here
- run_bazel build --config=android --config=bp2build --config=ci //foo/...
-
- local -r the_answer_file="$(find -L bazel-out -name the_answer.txt)"
- if [[ ! -f "${the_answer_file}" ]]; then
- fail "Expected the_answer.txt to be generated, but was missing"
- fi
- if ! grep 42 "${the_answer_file}"; then
- fail "Expected to find 42 in '${the_answer_file}'"
- fi
-}
-
-function test_bp2build_generates_all_buildfiles {
- _save_trap=$(trap -p EXIT)
- trap '[[ $? -ne 0 ]] && echo Are you running this locally? Try changing --sandbox_tmpfs_path to something other than /tmp/ in build/bazel/linux.bazelrc.' EXIT
- _bp2build_generates_all_buildfiles
- eval "${_save_trap}"
-}
-
-function test_build_files_take_precedence {
- _save_trap=$(trap -p EXIT)
- trap '[[ $? -ne 0 ]] && echo Are you running this locally? Try changing --sandbox_tmpfs_path to something other than /tmp/ in build/bazel/linux.bazelrc.' EXIT
- _build_files_take_precedence
- eval "${_save_trap}"
-}
-
-function _build_files_take_precedence {
- setup
-
- # This specific directory is hardcoded in bp2build as being one
- # where the BUILD file should be intentionally kept.
- mkdir -p testpkg/keep_build_file
- cat > testpkg/keep_build_file/Android.bp <<'EOF'
-genrule {
- name: "print_origin",
- cmd: "echo 'from_soong' > $(out)",
- out: [
- "origin.txt",
- ],
- bazel_module: {
- bp2build_available: true,
- },
- }
-EOF
-
- run_soong bp2build
- run_bazel build --config=android --config=bp2build --config=ci //testpkg/keep_build_file:print_origin
-
- local -r output_file="$(find -L bazel-out -name origin.txt)"
- if [[ ! -f "${output_file}" ]]; then
- fail "Expected origin.txt to be generated, but was missing"
- fi
- if ! grep from_soong "${output_file}"; then
- fail "Expected to find 'from_soong' in '${output_file}'"
- fi
-
- cat > testpkg/keep_build_file/BUILD.bazel <<'EOF'
-genrule(
- name = "print_origin",
- outs = ["origin.txt"],
- cmd = "echo 'from_bazel' > $@",
-)
-EOF
-
- # Clean the workspace. There is a test infrastructure bug where run_bazel
- # will symlink Android.bp files in the source directory again and thus
- # pollute the workspace.
- # TODO: b/286059878 - Remove this clean after the underlying bug is fixed.
- run_soong clean
- run_soong bp2build
- run_bazel build --config=android --config=bp2build --config=ci //testpkg/keep_build_file:print_origin
- if ! grep from_bazel "${output_file}"; then
- fail "Expected to find 'from_bazel' in '${output_file}'"
- fi
-}
-
-function test_bp2build_symlinks_files {
- setup
- mkdir -p foo
- touch foo/BLANK1
- touch foo/BLANK2
- touch foo/F2D
- touch foo/BUILD
-
- run_soong bp2build
-
- if [[ -e "./out/soong/workspace/foo/BUILD" ]]; then
- fail "./out/soong/workspace/foo/BUILD should be omitted"
- fi
- for file in BLANK1 BLANK2 F2D
- do
- if [[ ! -L "./out/soong/workspace/foo/$file" ]]; then
- fail "./out/soong/workspace/foo/$file should exist"
- fi
- done
- local -r BLANK1_BEFORE=$(stat -c %y "./out/soong/workspace/foo/BLANK1")
-
- rm foo/BLANK2
- rm foo/F2D
- mkdir foo/F2D
- touch foo/F2D/BUILD
-
- run_soong bp2build
-
- if [[ -e "./out/soong/workspace/foo/BUILD" ]]; then
- fail "./out/soong/workspace/foo/BUILD should be omitted"
- fi
- local -r BLANK1_AFTER=$(stat -c %y "./out/soong/workspace/foo/BLANK1")
- if [[ "$BLANK1_AFTER" != "$BLANK1_BEFORE" ]]; then
- fail "./out/soong/workspace/foo/BLANK1 should be untouched"
- fi
- if [[ -e "./out/soong/workspace/foo/BLANK2" ]]; then
- fail "./out/soong/workspace/foo/BLANK2 should be removed"
- fi
- if [[ -L "./out/soong/workspace/foo/F2D" ]] || [[ ! -d "./out/soong/workspace/foo/F2D" ]]; then
- fail "./out/soong/workspace/foo/F2D should be a dir"
- fi
-}
-
-function test_cc_correctness {
- setup
-
- mkdir -p a
- cat > a/Android.bp <<EOF
-cc_object {
- name: "qq",
- srcs: ["qq.cc"],
- bazel_module: {
- bp2build_available: true,
- },
- stl: "none",
- system_shared_libs: [],
-}
-EOF
-
- cat > a/qq.cc <<EOF
-#include "qq.h"
-int qq() {
- return QQ;
-}
-EOF
-
- cat > a/qq.h <<EOF
-#define QQ 1
-EOF
-
- run_soong bp2build
-
- run_bazel build --config=android --config=bp2build --config=ci //a:qq
- local -r output_mtime1=$(stat -c "%y" bazel-bin/a/_objs/qq/qq.o)
-
- run_bazel build --config=android --config=bp2build --config=ci //a:qq
- local -r output_mtime2=$(stat -c "%y" bazel-bin/a/_objs/qq/qq.o)
-
- if [[ "$output_mtime1" != "$output_mtime2" ]]; then
- fail "output changed on null build"
- fi
-
- cat > a/qq.h <<EOF
-#define QQ 2
-EOF
-
- run_bazel build --config=android --config=bp2build --config=ci //a:qq
- local -r output_mtime3=$(stat -c "%y" bazel-bin/a/_objs/qq/qq.o)
-
- if [[ "$output_mtime1" == "$output_mtime3" ]]; then
- fail "output not changed when included header changed"
- fi
-}
-
-# Regression test for the following failure during symlink forest creation:
-#
-# Cannot stat '/tmp/st.rr054/foo/bar/unresolved_symlink': stat /tmp/st.rr054/foo/bar/unresolved_symlink: no such file or directory
-#
-function test_bp2build_null_build_with_unresolved_symlink_in_source() {
- setup
-
- mkdir -p foo/bar
- ln -s /tmp/non-existent foo/bar/unresolved_symlink
- cat > foo/bar/Android.bp <<'EOF'
-filegroup {
- name: "fg",
- srcs: ["unresolved_symlink/non-existent-file.txt"],
- }
-EOF
-
- run_soong bp2build
-
- dest=$(readlink -f out/soong/workspace/foo/bar/unresolved_symlink)
- if [[ "$dest" != "/tmp/non-existent" ]]; then
- fail "expected to plant an unresolved symlink out/soong/workspace/foo/bar/unresolved_symlink that resolves to /tmp/non-existent"
- fi
-}
-
-function test_bazel_standalone_output_paths_contain_product_name {
- setup
- mkdir -p a
- cat > a/Android.bp <<EOF
-cc_object {
- name: "qq",
- srcs: ["qq.cc"],
- bazel_module: {
- bp2build_available: true,
- },
- stl: "none",
- system_shared_libs: [],
-}
-EOF
-
- cat > a/qq.cc <<EOF
-#include "qq.h"
-int qq() {
- return QQ;
-}
-EOF
-
- cat > a/qq.h <<EOF
-#define QQ 1
-EOF
-
- export TARGET_PRODUCT=aosp_arm; run_soong bp2build
- local -r output=$(run_bazel cquery //a:qq --output=files --config=android --config=bp2build --config=ci)
- if [[ ! $(echo ${output} | grep "bazel-out/aosp_arm") ]]; then
- fail "Did not find the product name '${TARGET_PRODUCT}' in the output path. This can cause " \
- "unnecessary rebuilds when toggling between products as bazel outputs for different products will " \
- "clobber each other. Output paths are: \n${output}"
- fi
-}
-
-scan_and_run_tests
diff --git a/tests/dcla_apex_comparison_test.sh b/tests/dcla_apex_comparison_test.sh
deleted file mode 100755
index e3c189f..0000000
--- a/tests/dcla_apex_comparison_test.sh
+++ /dev/null
@@ -1,166 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2023 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.
-
-set -euo pipefail
-
-# Soong/Bazel integration test to build the mainline modules in mixed build and
-# compare the DCLA libs extracted from those modules to ensure they are identical.
-
-if [ ! -e "build/make/core/Makefile" ]; then
- echo "$0 must be run from the top of the Android source tree."
- exit 1
-fi
-
-TARGET_PRODUCTS=(
- module_arm64
- module_x86_64
-)
-
-MODULES=(
- # These modules depend on the DCLA libs
- com.android.adbd
- com.android.art
- com.android.art.debug
- com.android.art.testing
- com.android.btservices
- com.android.conscrypt
- com.android.i18n
- com.android.media
- com.android.media.swcodec
- com.android.resolv
- com.android.runtime
- com.android.tethering
-)
-
-BAZEL_TARGETS=(
- //packages/modules/adb/apex:com.android.adbd
- //frameworks/av/apex:com.android.media.swcodec
-)
-
-DCLA_LIBS=(
- libbase.so
- libc++.so
- libcrypto.so
- libcutils.so
- libstagefright_flacdec.so
- libutils.so
-)
-
-if [[ -z ${OUT_DIR+x} ]]; then
- OUT_DIR="out"
-fi
-
-if [[ -z ${ANDROID_HOST_OUT+x} ]]; then
- export ANDROID_HOST_OUT="out/host/linux-x86"
-fi
-
-######################
-# Build deapexer and debugfs
-######################
-DEAPEXER="${ANDROID_HOST_OUT}/bin/deapexer"
-DEBUGFS="${ANDROID_HOST_OUT}/bin/debugfs"
-if [[ ! -f "${DEAPEXER}" ]] || [[ ! -f "${DEBUGFS}" ]]; then
- build/soong/soong_ui.bash --make-mode --skip-soong-tests deapexer debugfs
-fi
-
-DEAPEXER="${DEAPEXER} --debugfs_path=${DEBUGFS}"
-
-############
-# Test Setup
-############
-OUTPUT_DIR="$(mktemp -d tmp.XXXXXX)"
-
-function call_bazel() {
- build/bazel/bin/bazel $@
-}
-
-function cleanup {
- rm -rf "${OUTPUT_DIR}"
-}
-trap cleanup EXIT
-
-#######
-# Tests
-#######
-
-function extract_dcla_libs() {
- local product=$1; shift
- local modules=("$@"); shift
-
- for module in "${modules[@]}"; do
- local apex="${OUTPUT_DIR}/${product}/${module}.apex"
- local extract_dir="${OUTPUT_DIR}/${product}/${module}/extract"
-
- $DEAPEXER extract "${apex}" "${extract_dir}"
- done
-}
-
-function compare_dcla_libs() {
- local product=$1; shift
- local modules=("$@"); shift
-
- for lib in "${DCLA_LIBS[@]}"; do
- for arch in lib lib64; do
- local prev_sha=""
- for module in "${modules[@]}"; do
- local file="${OUTPUT_DIR}/${product}/${module}/extract/${arch}/${lib}"
- if [[ ! -f "${file}" ]]; then
- # not all libs are present in a module
- echo "file doesn't exist: ${file}"
- continue
- fi
- sha=$(sha1sum ${file})
- sha="${sha% *}"
- if [ "${prev_sha}" == "" ]; then
- prev_sha="${sha}"
- elif [ "${sha}" != "${prev_sha}" ] && { [ "${lib}" != "libcrypto.so" ] || [[ "${module}" != *"com.android.tethering" ]]; }; then
- echo "Test failed, ${lib} has different hash value"
- exit 1
- fi
- done
- done
- done
-}
-
-export UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true # don't rely on prebuilts
-export TARGET_BUILD_APPS="${MODULES[@]}"
-for product in "${TARGET_PRODUCTS[@]}"; do
- ###########
- # Build the mainline modules
- ###########
- packages/modules/common/build/build_unbundled_mainline_module.sh \
- --product "${product}" \
- --dist_dir "${OUTPUT_DIR}/${product}"
-
- bazel_apexes=()
- if [[ -n ${TEST_BAZEL+x} ]] && [ "${TEST_BAZEL}" = true ]; then
- export TARGET_PRODUCT="${product/module/aosp}"
- call_bazel build --config=bp2build --config=ci --config=android "${BAZEL_TARGETS[@]}"
- for target in "${BAZEL_TARGETS[@]}"; do
- apex_path="$(realpath $(call_bazel cquery --config=bp2build --config=android --config=ci --output=files $target))"
- mkdir -p ${OUTPUT_DIR}/${product}
- bazel_apex="bazel_$(basename $apex_path)"
- mv $apex_path ${OUTPUT_DIR}/${product}/${bazel_apex}
- bazel_apexes+=(${bazel_apex%".apex"})
- done
- fi
-
- all_modeuls=(${MODULES[@]} ${bazel_apexes[@]})
- extract_dcla_libs "${product}" "${all_modeuls[@]}"
- compare_dcla_libs "${product}" "${all_modeuls[@]}"
-done
-
-echo "Test passed"
diff --git a/tests/mixed_mode_test.sh b/tests/mixed_mode_test.sh
deleted file mode 100755
index ca63fdf..0000000
--- a/tests/mixed_mode_test.sh
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/bin/bash
-
-set -o pipefail
-
-# This test exercises mixed builds where Soong and Bazel cooperate in building
-# Android.
-#
-# When the execroot is deleted, the Bazel server process will automatically
-# terminate itself.
-
-source "$(dirname "$0")/lib.sh"
-
-function test_bazel_smoke {
- setup
-
- run_soong bp2build
-
- run_bazel info --config=bp2build
-}
-
-function test_add_irrelevant_file {
- setup
-
- mkdir -p soong_tests/a/b
- touch soong_tests/a/b/c.txt
- cat > soong_tests/a/b/Android.bp <<'EOF'
-filegroup {
- name: "c",
- srcs: ["c.txt"],
- bazel_module: { bp2build_available: true },
-}
-EOF
-
- run_soong --bazel-mode-staging nothing
-
- if [[ ! -e out/soong/bp2build/soong_tests/a/b/BUILD.bazel ]]; then
- fail "BUILD.bazel not created"
- fi
-
- if [[ ! -e out/soong/build.ninja ]]; then
- fail "build.ninja not created"
- fi
-
- local mtime_build1=$(stat -c "%y" out/soong/bp2build/soong_tests/a/b/BUILD.bazel)
- local mtime_ninja1=$(stat -c "%y" out/soong/build.ninja)
-
- touch soong_tests/a/irrelevant.txt
-
- run_soong --bazel-mode-staging nothing
- local mtime_build2=$(stat -c "%y" out/soong/bp2build/soong_tests/a/b/BUILD.bazel)
- local mtime_ninja2=$(stat -c "%y" out/soong/build.ninja)
-
- if [[ "$mtime_build1" != "$mtime_build2" ]]; then
- fail "BUILD.bazel was generated"
- fi
-
- if [[ "$mtime_ninja1" != "$mtime_ninja2" ]]; then
- fail "build.ninja was regenerated"
- fi
-
- if [[ ! -e out/soong/workspace/soong_tests/a/irrelevant.txt ]]; then
- fail "new file was not symlinked"
- fi
-}
-
-function test_force_enabled_modules {
- setup
- # b/273910287 - test force enable modules
- mkdir -p soong_tests/a/b
- cat > soong_tests/a/b/Android.bp <<'EOF'
-genrule {
- name: "touch-file",
- out: ["fake-out.txt"],
- cmd: "touch $(out)",
- bazel_module: { bp2build_available: true },
-}
-
-genrule {
- name: "unenabled-touch-file",
- out: ["fake-out2.txt"],
- cmd: "touch $(out)",
- bazel_module: { bp2build_available: false },
-}
-EOF
- run_soong --bazel-mode-staging --bazel-force-enabled-modules=touch-file nothing
- local bazel_contained=`grep out/soong/.intermediates/soong_tests/a/b/touch-file/gen/fake-out.txt out/soong/build.ninja`
- if [[ $bazel_contained == '' ]]; then
- fail "Bazel actions not found for force-enabled module"
- fi
-
- unused=`run_soong --bazel-force-enabled-modules=unenabled-touch-file --ensure-allowlist-integrity nothing >/dev/null`
-
- if [[ $? -ne 1 ]]; then
- fail "Expected failure due to force-enabling an unenabled module "
- fi
-}
-
-
-scan_and_run_tests
diff --git a/tests/persistent_bazel_test.sh b/tests/persistent_bazel_test.sh
deleted file mode 100755
index 9b7b58f..0000000
--- a/tests/persistent_bazel_test.sh
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/bash -eu
-
-# Copyright (C) 2023 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.
-
-set -o pipefail
-
-source "$(dirname "$0")/lib.sh"
-
-# This test verifies that adding USE_PERSISTENT_BAZEL creates a Bazel process
-# that outlasts the build process.
-# This test should only be run in sandboxed environments (because this test
-# verifies a Bazel process using global process list, and may spawn lingering
-# Bazel processes).
-function test_persistent_bazel {
- setup
-
- # Ensure no existing Bazel process.
- if [[ -e out/bazel/output/server/server.pid.txt ]]; then
- kill $(cat out/bazel/output/server/server.pid.txt) 2>/dev/null || true
- if kill -0 $(cat out/bazel/output/server/server.pid.txt) 2>/dev/null ; then
- fail "Error killing pre-setup bazel"
- fi
- fi
-
- USE_PERSISTENT_BAZEL=1 run_soong nothing
-
- if ! kill -0 $(cat out/bazel/output/server/server.pid.txt) 2>/dev/null ; then
- fail "Persistent bazel process expected, but not found after first build"
- fi
- BAZEL_PID=$(cat out/bazel/output/server/server.pid.txt)
-
- USE_PERSISTENT_BAZEL=1 run_soong nothing
-
- if ! kill -0 $BAZEL_PID 2>/dev/null ; then
- fail "Bazel pid $BAZEL_PID was killed after second build"
- fi
-
- kill $BAZEL_PID 2>/dev/null
- if ! kill -0 $BAZEL_PID 2>/dev/null ; then
- fail "Error killing bazel on shutdown"
- fi
-}
-
-# Verifies that USE_PERSISTENT_BAZEL mode operates as expected in the event
-# that there are Bazel failures.
-function test_bazel_failure {
- setup
-
- # Ensure no existing Bazel process.
- if [[ -e out/bazel/output/server/server.pid.txt ]]; then
- kill $(cat out/bazel/output/server/server.pid.txt) 2>/dev/null || true
- if kill -0 $(cat out/bazel/output/server/server.pid.txt) 2>/dev/null ; then
- fail "Error killing pre-setup bazel"
- fi
- fi
-
- # Introduce a syntax error in a BUILD file which is used in every build
- # (Note this is a BUILD file which is copied as part of test setup, so this
- # has no effect on sources outside of this test.
- rm -rf build/bazel/rules
-
- USE_PERSISTENT_BAZEL=1 run_soong nothing 1>out/failurelog.txt 2>&1 && fail "Expected build failure" || true
-
- if ! grep -sq "cannot load //build/bazel/rules/common/api_constants.bzl" out/failurelog.txt ; then
- fail "Expected error to contain 'cannot load //build/bazel/rules/common/api_constants.bzl', instead got:\n$(cat out/failurelog.txt)"
- fi
-
- kill $(cat out/bazel/output/server/server.pid.txt) 2>/dev/null || true
-}
-
-scan_and_run_tests
diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh
index 231e18b..0235f2b 100755
--- a/tests/run_integration_tests.sh
+++ b/tests/run_integration_tests.sh
@@ -4,25 +4,6 @@
TOP="$(readlink -f "$(dirname "$0")"/../../..)"
"$TOP/build/soong/tests/androidmk_test.sh"
-"$TOP/build/soong/tests/b_args_test.sh"
"$TOP/build/soong/tests/bootstrap_test.sh"
-"$TOP/build/soong/tests/mixed_mode_test.sh"
-"$TOP/build/soong/tests/bp2build_bazel_test.sh"
-"$TOP/build/soong/tests/persistent_bazel_test.sh"
"$TOP/build/soong/tests/soong_test.sh"
-"$TOP/build/soong/tests/stale_metrics_files_test.sh"
-"$TOP/build/soong/tests/symlink_forest_rerun_test.sh"
"$TOP/prebuilts/build-tools/linux-x86/bin/py3-cmd" "$TOP/build/bazel/ci/rbc_dashboard.py" aosp_arm64-userdebug
-
-# The following tests build against the full source tree and don't rely on the
-# mock client.
-"$TOP/build/soong/tests/apex_comparison_tests.sh"
-"$TOP/build/soong/tests/apex_comparison_tests.sh" "module_arm64only"
-TEST_BAZEL=true extra_build_params=--bazel-mode-staging "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
-#BUILD_BROKEN_DISABLE_BAZEL=true "$TOP/build/soong/tests/dcla_apex_comparison_test.sh"
-"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh"
-"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_arm" "armv7-a"
-"$TOP/build/soong/tests/apex_cc_module_arch_variant_tests.sh" "aosp_cf_arm64_phone" "armv8-a" "cortex-a53"
-
-"$TOP/build/bazel/ci/b_test.sh"
-"$TOP/build/soong/tests/symlinks_path_test.sh"
diff --git a/tests/stale_metrics_files_test.sh b/tests/stale_metrics_files_test.sh
deleted file mode 100755
index 0da89c3..0000000
--- a/tests/stale_metrics_files_test.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash -e
-
-# This test ensures that stale metrics files are deleted after each run
-
-# Run bazel
-# Note - bp2build metrics are present after clean runs, only
-build/soong/soong_ui.bash --make-mode clean
-build/bazel/bin/b build libcore:all
-soong_build_metrics_files=("out/soong_build_metrics.pb" "out/build_progress.pb" "out/soong_metrics" "out/bp2build_metrics.pb")
-bazel_build_metrics_files=("out/bazel_metrics.pb" "out/build_progress.pb" "out/soong_metrics" "out/bp2build_metrics.pb")
-
-# Ensure bazel metrics files are present
-for i in ${!bazel_build_metrics_files[@]};
-do
- file=${bazel_build_metrics_files[$i]}
- if [[ ! -f $file ]]; then
- echo "Missing metrics file for Bazel build " $file
- exit 1
- fi
-done
-
-
-# Run a soong build
-build/soong/soong_ui.bash --make-mode nothing
-
-for i in ${!soong_build_metrics_files[@]};
-do
- file=${soong_build_metrics_files[$i]}
- if [[ ! -f $file ]]; then
- echo "Missing metrics file for Soong build " $file
- exit 1
- fi
-done
-
-# Ensure that bazel_metrics.pb is deleted
-if [[ -f out/bazel_metrics.pb ]]; then
- echo "Stale out/bazel_metrics.pb file detected"
- exit 1
-fi
-
-# Run bazel again - to make sure that soong_build_metrics.pb gets deleted
-build/bazel/bin/b build libcore:all
-
-if [[ -f out/soong_build_metrics.pb ]]; then
- echo "Stale out/soong_build_metrics.pb file detected"
- exit 1
-fi
diff --git a/tests/symlink_forest_rerun_test.sh b/tests/symlink_forest_rerun_test.sh
deleted file mode 100755
index 74e779e..0000000
--- a/tests/symlink_forest_rerun_test.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/bash -eu
-
-set -o pipefail
-
-# Tests that symlink forest will replant if soong_build has changed
-# Any change to the build system should trigger a rerun
-
-source "$(dirname "$0")/lib.sh"
-
-function test_symlink_forest_reruns {
- setup
-
- mkdir -p a
- touch a/g.txt
- cat > a/Android.bp <<'EOF'
-filegroup {
- name: "g",
- srcs: ["g.txt"],
- }
-EOF
-
- run_soong g
-
- mtime=`cat out/soong/workspace/soong_build_mtime`
- # rerun with no changes - ensure that it hasn't changed
- run_soong g
- newmtime=`cat out/soong/workspace/soong_build_mtime`
- if [[ ! "$mtime" == "$mtime" ]]; then
- fail "symlink forest reran when it shouldn't have"
- fi
-
- # change exit codes to force a soong_build rebuild.
- sed -i 's/os.Exit(1)/os.Exit(2)/g' build/soong/bp2build/symlink_forest.go
-
- run_soong g
- newmtime=`cat out/soong/workspace/soong_build_mtime`
- if [[ "$mtime" == "$newmtime" ]]; then
- fail "symlink forest did not rerun when it should have"
- fi
-
-}
-
-scan_and_run_tests
diff --git a/tests/symlinks_path_test.sh b/tests/symlinks_path_test.sh
deleted file mode 100755
index ed42911..0000000
--- a/tests/symlinks_path_test.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/bash -eu
-
-set -o pipefail
-
-# Test that relative symlinks work by recreating the bug in b/259191764
-# In some cases, developers prefer to move their checkouts. This causes
-# issues in that symlinked files (namely, the bazel wrapper script)
-# cannot be found. As such, we implemented relative symlinks so that a
-# moved checkout doesn't need a full clean before rebuilding.
-# The bazel output base will still need to be removed, as Starlark
-# doesn't seem to support relative symlinks yet.
-
-source "$(dirname "$0")/lib.sh"
-
-function check_link_has_mock_top_prefix {
- input_link=$1
- link_target=`readlink $input_link`
- if [[ $link_target != "$MOCK_TOP"* ]]; then
- echo "Symlink for file $input_link -> $link_target doesn't start with $MOCK_TOP"
- exit 1
- fi
-}
-
-function test_symlinks_updated_when_top_dir_changed {
- setup
-
- mkdir -p a
- touch a/g.txt
- cat > a/Android.bp <<'EOF'
-filegroup {
- name: "g",
- srcs: ["g.txt"],
- bazel_module: {bp2build_available: true},
-}
-EOF
- # A directory under $MOCK_TOP
- outdir=out2
-
- # Modify OUT_DIR in a subshell so it doesn't affect the top level one.
- (export OUT_DIR=$MOCK_TOP/$outdir; run_soong bp2build && run_bazel build --config=bp2build --config=ci //a:g)
-
- g_txt="out2/soong/workspace/a/g.txt"
- check_link_has_mock_top_prefix "$g_txt"
-
- move_mock_top
-
- (export OUT_DIR=$MOCK_TOP/$outdir; run_soong bp2build && run_bazel build --config=bp2build --config=ci //a:g)
- check_link_has_mock_top_prefix "$g_txt"
-}
-
-scan_and_run_tests
\ No newline at end of file