Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Android/build/build/soong/tests/   (Android Betriebssystem Version 17©)  Datei vom 26.5.2026 mit Größe 7 kB image not shown  

Quelle  build_action_caching_test.sh

  Sprache: Shell
 

#!/bin/bash

set -euo pipefail

# Test that the mk and ninja files generated by Soong don't change if some
# incremental modules are restored from cache.

source "$(dirname "$0")/lib.sh"

function test_build_action_restoring() {
  setup
  do_test_build_action_restoring
}

function test_build_action_restoring_providers() {
  setup
  do_test_build_action_restoring "--incremental-provider-test"
}

function do_test_build_action_restoring() {
  local test_dir="test_build_action_restoring"
  mkdir -p ${test_dir}
  cat > ${test_dir}/Android.bp <<'EOF'
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["my_little_binary_host.py"],
}
EOF
  touch ${test_dir}/my_little_binary_host.py
  run_soong SOONG_INCREMENTAL_ANALYSIS=true "$@"
  local dir_before="${test_dir}/before"
  mkdir -p ${dir_before}
  cp -pr out/soong/build.test_arm64*.ninja* ${test_dir}/before
  # add a comment to the bp file, this should force a new analysis but no module
  # should be really impacted, so all the incremental modules should be skipped.
  cat >> ${test_dir}/Android.bp <<'EOF'
// new comments
EOF
  run_soong SOONG_INCREMENTAL_ANALYSIS=true "$@"
  local dir_after="${test_dir}/after"
  mkdir -p ${dir_after}
  cp -pr out/soong/build.test_arm64*.ninja* ${test_dir}/after

  compare_files_parity $dir_before $dir_after
  rm -rf "$test_dir"
  echo "test_build_action_restoring test passed"
}

function test_incremental_build_parity() {
  setup
  local test_dir="test_incremental_build_parity"
  run_soong SOONG_INCREMENTAL_ANALYSIS=false
  local dir_before="${test_dir}/before"
  mkdir -p ${dir_before}
  cp -pr out/soong/build.test_arm64*.ninja* ${test_dir}/before

  # Now run clean build with incremental enabled
  rm -rf out
  run_soong SOONG_INCREMENTAL_ANALYSIS=true
  local dir_after="${test_dir}/after"
  mkdir -p ${dir_after}
  cp -pr out/soong/build.test_arm64*.ninja* ${test_dir}/after

  compare_incremental_files $dir_before $dir_after
  rm -rf "$test_dir"
  echo "test_incremental_build_parity test passed"
}

function test_add_module() {
  setup

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["my_little_binary_host.py"],
}
EOF
  touch a/my_little_binary_host.py

  compare_incremental_and_full_analysis
}

function test_remove_module() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["my_little_binary_host.py"],
}
EOF
  touch a/my_little_binary_host.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  echo > a/Android.bp

  compare_incremental_and_full_analysis
}

function test_recreate_module() {
  # Regression test for b/466891621
  setup

  # Create two new modules that share a dependency.  This should cause them
  # each to have a meta_lic rule that has the same set of order-only dependencies,
  # resulting in a deduped order-only phony dependency.
  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["my_little_binary_host.py"],
  libs: ["my_little_library_host"],
}

python_binary_host {
  name: "my_little_binary_host2",
  srcs: ["my_little_binary_host2.py"],
  libs: ["my_little_library_host"],
}

python_library_host {
  name: "my_little_library_host",
  srcs: ["my_little_library_host.py"],
}
EOF
  touch a/my_little_binary_host.py
  touch a/my_little_binary_host2.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  # Remove the modules.
  mv a/Android.bp a/Android.bp.bak

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  # Recreate the modules and make sure Soong doesn't panic.
  mv a/Android.bp.bak a/Android.bp

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  compare_incremental_and_full_analysis
}

function test_add_dependency() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["my_little_binary_host.py"],
  libs: [],
}

python_library_host {
  name: "my_little_library_host",
  srcs: ["my_little_library_host.py"],
}
EOF
  touch a/my_little_binary_host.py
  touch a/my_little_library_host.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  sed -i -e 's/libs: \[\]/libs: \["my_little_library_host"\]/' a/Android.bp

  compare_incremental_and_full_analysis
}

function test_remove_dependency() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["my_little_binary_host.py"],
  libs: ["my_little_library_host"],
}

python_library_host {
  name: "my_little_library_host",
  srcs: ["my_little_library_host.py"],
}
EOF
  touch a/my_little_binary_host.py
  touch a/my_little_library_host.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  sed -i -e 's/libs: \["my_little_library_host"\]/libs: \[\]/' a/Android.bp

  compare_incremental_and_full_analysis
}

function test_modify_dependency() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["my_little_binary_host.py"],
  libs: ["my_little_library_host"],
}

python_library_host {
  name: "my_little_library_host",
  srcs: ["my_little_library_host.py"],
}

python_library_host {
  name: "my_little_library_host2",
  srcs: ["my_little_library_host2.py"],
}
EOF
  touch a/my_little_binary_host.py
  touch a/my_little_library_host.py
  touch a/my_little_library_host2.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  sed -i -e 's/libs: \["my_little_library_host"\]/libs: \["my_little_library_host2"\]/' a/Android.bp

  compare_incremental_and_full_analysis
}

function test_add_source() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["*.py"],
}
EOF
  touch a/my_little_binary_host.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  touch a/my_little_binary_host2.py

  compare_incremental_and_full_analysis
}

function test_remove_source() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["*.py"],
}
EOF
  touch a/my_little_binary_host.py
  touch a/my_little_binary_host2.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  rm a/my_little_binary_host2.py

  compare_incremental_and_full_analysis
}

function test_replace_source() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["*.py"],
}
EOF
  touch a/my_little_binary_host.py
  touch a/my_little_binary_host2.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  rm a/my_little_binary_host2.py
  touch a/my_little_binary_host3.py

  compare_incremental_and_full_analysis
}

function test_error() {
  setup

  mkdir -p a
  cat >> a/Android.bp <<EOF
python_binary_host {
  name: "my_little_binary_host",
  srcs: ["*.py"],
}
EOF
  touch a/my_little_binary_host.py

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  echo inserted_syntax_error >> a/Android.bp

  run_soong SOONG_INCREMENTAL_ANALYSIS=true || true

  sed -i -e'/inserted_syntax_error/d' a/Android.bp

  compare_incremental_and_full_analysis
}

function test_set_environment_variable() {
  setup

  run_soong SOONG_INCREMENTAL_ANALYSIS=true

  compare_incremental_and_full_analysis CC_WRAPPER=foo
}

function test_change_environment_variable() {
  setup

  run_soong SOONG_INCREMENTAL_ANALYSIS=true CC_WRAPPER=foo

  compare_incremental_and_full_analysis CC_WRAPPER=bar
}

function test_change_target_product() {
  setup

  run_soong SOONG_INCREMENTAL_ANALYSIS=true
  run_soong SOONG_INCREMENTAL_ANALYSIS=true TARGET_PRODUCT=test2_arm64
  compare_incremental_and_full_analysis
}

scan_and_run_tests "$@"

Messung V0.5 in Prozent
C=83 H=97 G=90

¤ Dauer der Verarbeitung: 0.22 Sekunden  (vorverarbeitet am  2026-06-28) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.