From 5040c36649b4c799c0503b04582476bf68734f56 Mon Sep 17 00:00:00 2001 From: MarkDacek Date: Wed, 7 Jun 2023 18:03:06 +0000 Subject: [PATCH] Add integration test for ensuring that stale metrics files are deleted. Bug: 286083726 Test: run the script Change-Id: I2dd382b3a0ee1b226f4931fed3bc4b5df0a3528c --- tests/run_integration_tests.sh | 1 + tests/stale_metrics_files_test.sh | 47 +++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100755 tests/stale_metrics_files_test.sh diff --git a/tests/run_integration_tests.sh b/tests/run_integration_tests.sh index c77b9030a..43a9f0fed 100755 --- a/tests/run_integration_tests.sh +++ b/tests/run_integration_tests.sh @@ -9,6 +9,7 @@ TOP="$(readlink -f "$(dirname "$0")"/../../..)" "$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/bazel/ci/rbc_regression_test.sh" aosp_arm64-userdebug # The following tests build against the full source tree and don't rely on the diff --git a/tests/stale_metrics_files_test.sh b/tests/stale_metrics_files_test.sh new file mode 100755 index 000000000..0da89c3ca --- /dev/null +++ b/tests/stale_metrics_files_test.sh @@ -0,0 +1,47 @@ +#!/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