cosmetic: getting rid of SC2155 warnings

https://github.com/koalaman/shellcheck/wiki/SC2155

Bug: N/A
Test: bootstrap_test.sh
Change-Id: I3ce7ab2c7b2cf827e32c3cde0dfbcc932fc48039
This commit is contained in:
Usta Shrestha
2022-12-08 01:18:44 -05:00
parent da62908229
commit 4e17a2e503

View File

@@ -17,11 +17,11 @@ function test_smoke {
function test_null_build() { function test_null_build() {
setup setup
run_soong run_soong
local bootstrap_mtime1=$(stat -c "%y" out/soong/bootstrap.ninja) local -r bootstrap_mtime1=$(stat -c "%y" out/soong/bootstrap.ninja)
local output_mtime1=$(stat -c "%y" out/soong/build.ninja) local -r output_mtime1=$(stat -c "%y" out/soong/build.ninja)
run_soong run_soong
local bootstrap_mtime2=$(stat -c "%y" out/soong/bootstrap.ninja) local -r bootstrap_mtime2=$(stat -c "%y" out/soong/bootstrap.ninja)
local output_mtime2=$(stat -c "%y" out/soong/build.ninja) local -r output_mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$bootstrap_mtime1" == "$bootstrap_mtime2" ]]; then if [[ "$bootstrap_mtime1" == "$bootstrap_mtime2" ]]; then
# Bootstrapping is always done. It doesn't take a measurable amount of time. # Bootstrapping is always done. It doesn't take a measurable amount of time.
@@ -36,12 +36,12 @@ function test_null_build() {
function test_soong_build_rebuilt_if_blueprint_changes() { function test_soong_build_rebuilt_if_blueprint_changes() {
setup setup
run_soong run_soong
local mtime1=$(stat -c "%y" out/soong/bootstrap.ninja) local -r mtime1=$(stat -c "%y" out/soong/bootstrap.ninja)
sed -i 's/pluginGenSrcCmd/pluginGenSrcCmd2/g' build/blueprint/bootstrap/bootstrap.go sed -i 's/pluginGenSrcCmd/pluginGenSrcCmd2/g' build/blueprint/bootstrap/bootstrap.go
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/bootstrap.ninja) local -r mtime2=$(stat -c "%y" out/soong/bootstrap.ninja)
if [[ "$mtime1" == "$mtime2" ]]; then if [[ "$mtime1" == "$mtime2" ]]; then
fail "Bootstrap Ninja file did not change" fail "Bootstrap Ninja file did not change"
@@ -79,7 +79,7 @@ EOF
function test_add_android_bp() { function test_add_android_bp() {
setup setup
run_soong run_soong
local mtime1=$(stat -c "%y" out/soong/build.ninja) local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
mkdir -p a mkdir -p a
cat > a/Android.bp <<'EOF' cat > a/Android.bp <<'EOF'
@@ -91,7 +91,7 @@ EOF
touch a/my_little_binary_host.py touch a/my_little_binary_host.py
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/build.ninja) local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime1" == "$mtime2" ]]; then if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change" fail "Output Ninja file did not change"
fi fi
@@ -142,7 +142,7 @@ python_binary_host {
EOF EOF
touch a/my_little_binary_host.py touch a/my_little_binary_host.py
run_soong run_soong
local ninja_mtime1=$(stat -c "%y" out/soong/build.ninja) local -r ninja_mtime1=$(stat -c "%y" out/soong/build.ninja)
local glob_deps_file=out/soong/globs/build/0.d local glob_deps_file=out/soong/globs/build/0.d
@@ -151,7 +151,7 @@ EOF
fi fi
run_soong run_soong
local ninja_mtime2=$(stat -c "%y" out/soong/build.ninja) local -r ninja_mtime2=$(stat -c "%y" out/soong/build.ninja)
# There is an ineffiencency in glob that requires bpglob to rerun once for each glob to update # 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 # the entry in the .ninja_log. It doesn't update the output file, but we can detect the rerun
@@ -160,15 +160,15 @@ EOF
fail "Glob deps file missing after second build" fail "Glob deps file missing after second build"
fi fi
local glob_deps_mtime2=$(stat -c "%y" "$glob_deps_file") local -r glob_deps_mtime2=$(stat -c "%y" "$glob_deps_file")
if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then
fail "Ninja file rewritten on null incremental build" fail "Ninja file rewritten on null incremental build"
fi fi
run_soong run_soong
local ninja_mtime3=$(stat -c "%y" out/soong/build.ninja) local -r ninja_mtime3=$(stat -c "%y" out/soong/build.ninja)
local glob_deps_mtime3=$(stat -c "%y" "$glob_deps_file") local -r glob_deps_mtime3=$(stat -c "%y" "$glob_deps_file")
if [[ "$ninja_mtime2" != "$ninja_mtime3" ]]; then if [[ "$ninja_mtime2" != "$ninja_mtime3" ]]; then
fail "Ninja file rewritten on null incremental build" fail "Ninja file rewritten on null incremental build"
@@ -192,12 +192,12 @@ python_binary_host {
EOF EOF
touch a/my_little_binary_host.py touch a/my_little_binary_host.py
run_soong run_soong
local mtime1=$(stat -c "%y" out/soong/build.ninja) local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
touch a/my_little_library.py touch a/my_little_library.py
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/build.ninja) local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime1" == "$mtime2" ]]; then if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change" fail "Output Ninja file did not change"
fi fi
@@ -275,10 +275,10 @@ EOF
run_soong run_soong
grep -q "CHERRY IS RED" out/soong/build.ninja \ grep -q "CHERRY IS RED" out/soong/build.ninja \
|| fail "second value of environment variable not used" || fail "second value of environment variable not used"
local mtime1=$(stat -c "%y" out/soong/build.ninja) local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/build.ninja) local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime1" != "$mtime2" ]]; then if [[ "$mtime1" != "$mtime2" ]]; then
fail "Output Ninja file changed when environment variable did not" fail "Output Ninja file changed when environment variable did not"
fi fi
@@ -288,7 +288,7 @@ EOF
function test_create_global_include_directory() { function test_create_global_include_directory() {
setup setup
run_soong run_soong
local mtime1=$(stat -c "%y" out/soong/build.ninja) local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
# Soong needs to know if top level directories like hardware/ exist for use # 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 # as global include directories. Make sure that doesn't cause regens for
@@ -296,7 +296,7 @@ function test_create_global_include_directory() {
mkdir -p system/core mkdir -p system/core
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/build.ninja) local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime1" != "$mtime2" ]]; then if [[ "$mtime1" != "$mtime2" ]]; then
fail "Output Ninja file changed when top level directory changed" fail "Output Ninja file changed when top level directory changed"
fi fi
@@ -306,7 +306,7 @@ function test_create_global_include_directory() {
mkdir -p system/core/include mkdir -p system/core/include
run_soong run_soong
local mtime3=$(stat -c "%y" out/soong/build.ninja) local -r mtime3=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime2" = "$mtime3" ]]; then if [[ "$mtime2" = "$mtime3" ]]; then
fail "Output Ninja file did not change when global include directory created" fail "Output Ninja file did not change when global include directory created"
fi fi
@@ -317,7 +317,7 @@ function test_create_global_include_directory() {
function test_add_file_to_soong_build() { function test_add_file_to_soong_build() {
setup setup
run_soong run_soong
local mtime1=$(stat -c "%y" out/soong/build.ninja) local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
mkdir -p a mkdir -p a
cat > a/Android.bp <<'EOF' cat > a/Android.bp <<'EOF'
@@ -379,7 +379,7 @@ func (p *picardSingleton) GenerateBuildActions(ctx android.SingletonContext) {
EOF EOF
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/build.ninja) local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime1" == "$mtime2" ]]; then if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change" fail "Output Ninja file did not change"
fi fi
@@ -457,7 +457,7 @@ func (p *picardSingleton) GenerateBuildActions(ctx android.SingletonContext) {
EOF EOF
run_soong run_soong
local mtime1=$(stat -c "%y" out/soong/build.ninja) local -r mtime1=$(stat -c "%y" out/soong/build.ninja)
grep -q "Make it so" out/soong/build.ninja || fail "Original action not present" grep -q "Make it so" out/soong/build.ninja || fail "Original action not present"
@@ -489,7 +489,7 @@ func init() {
EOF EOF
run_soong run_soong
local mtime2=$(stat -c "%y" out/soong/build.ninja) local -r mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$mtime1" == "$mtime2" ]]; then if [[ "$mtime1" == "$mtime2" ]]; then
fail "Output Ninja file did not change" fail "Output Ninja file did not change"
fi fi
@@ -514,20 +514,20 @@ function test_null_build_after_soong_docs() {
setup setup
run_soong run_soong
local ninja_mtime1=$(stat -c "%y" out/soong/build.ninja) local -r ninja_mtime1=$(stat -c "%y" out/soong/build.ninja)
run_soong soong_docs run_soong soong_docs
local docs_mtime1=$(stat -c "%y" out/soong/docs/soong_build.html) local -r docs_mtime1=$(stat -c "%y" out/soong/docs/soong_build.html)
run_soong soong_docs run_soong soong_docs
local docs_mtime2=$(stat -c "%y" out/soong/docs/soong_build.html) local -r docs_mtime2=$(stat -c "%y" out/soong/docs/soong_build.html)
if [[ "$docs_mtime1" != "$docs_mtime2" ]]; then if [[ "$docs_mtime1" != "$docs_mtime2" ]]; then
fail "Output Ninja file changed on null build" fail "Output Ninja file changed on null build"
fi fi
run_soong run_soong
local ninja_mtime2=$(stat -c "%y" out/soong/build.ninja) local -r ninja_mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then
fail "Output Ninja file changed on null build" fail "Output Ninja file changed on null build"
@@ -552,7 +552,7 @@ EOF
run_ninja BUILD_BROKEN_SRC_DIR_IS_WRITABLE=false ${EXPECTED_OUT} &> /dev/null && \ run_ninja BUILD_BROKEN_SRC_DIR_IS_WRITABLE=false ${EXPECTED_OUT} &> /dev/null && \
fail "Write to source tree should not work in a ReadOnly source tree" fail "Write to source tree should not work in a ReadOnly source tree"
if grep -q "${ERROR_MSG}" ${ERROR_LOG} && grep -q "${ERROR_HINT_PATTERN}" ${ERROR_LOG} ; then if grep -q "${ERROR_MSG}" "${ERROR_LOG}" && grep -q "${ERROR_HINT_PATTERN}" "${ERROR_LOG}" ; then
echo Error message and error hint found in logs >/dev/null echo Error message and error hint found in logs >/dev/null
else else
fail "Did not find Read-only error AND error hint in error.log" fail "Did not find Read-only error AND error hint in error.log"
@@ -562,7 +562,7 @@ EOF
run_ninja BUILD_BROKEN_SRC_DIR_IS_WRITABLE=true ${EXPECTED_OUT} &> /dev/null || \ run_ninja BUILD_BROKEN_SRC_DIR_IS_WRITABLE=true ${EXPECTED_OUT} &> /dev/null || \
fail "Write to source tree did not succeed in a ReadWrite source tree" fail "Write to source tree did not succeed in a ReadWrite source tree"
if grep -q "${ERROR_MSG}\|${ERROR_HINT_PATTERN}" ${ERROR_LOG} ; then if grep -q "${ERROR_MSG}\|${ERROR_HINT_PATTERN}" "${ERROR_LOG}" ; then
fail "Found read-only error OR error hint in error.log" fail "Found read-only error OR error hint in error.log"
fi fi
} }
@@ -606,11 +606,11 @@ EOF
fail "BUILD file in symlink forest was not created"; fail "BUILD file in symlink forest was not created";
fi fi
local mtime1=$(stat -c "%y" out/soong/bp2build/a/b/BUILD.bazel) local -r mtime1=$(stat -c "%y" out/soong/bp2build/a/b/BUILD.bazel)
touch a/irrelevant.txt touch a/irrelevant.txt
run_soong bp2build run_soong bp2build
local mtime2=$(stat -c "%y" out/soong/bp2build/a/b/BUILD.bazel) local -r mtime2=$(stat -c "%y" out/soong/bp2build/a/b/BUILD.bazel)
if [[ "$mtime1" != "$mtime2" ]]; then if [[ "$mtime1" != "$mtime2" ]]; then
fail "BUILD.bazel file was regenerated" fail "BUILD.bazel file was regenerated"
@@ -657,10 +657,10 @@ function test_bp2build_null_build {
setup setup
run_soong bp2build run_soong bp2build
local mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker) local -r mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
run_soong bp2build run_soong bp2build
local mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker) local -r mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$mtime1" != "$mtime2" ]]; then if [[ "$mtime1" != "$mtime2" ]]; then
fail "Output Ninja file changed on null build" fail "Output Ninja file changed on null build"
@@ -717,19 +717,19 @@ function test_json_module_graph_back_and_forth_null_build() {
setup setup
run_soong run_soong
local ninja_mtime1=$(stat -c "%y" out/soong/build.ninja) local -r ninja_mtime1=$(stat -c "%y" out/soong/build.ninja)
run_soong json-module-graph run_soong json-module-graph
local json_mtime1=$(stat -c "%y" out/soong/module-graph.json) local -r json_mtime1=$(stat -c "%y" out/soong/module-graph.json)
run_soong run_soong
local ninja_mtime2=$(stat -c "%y" out/soong/build.ninja) local -r ninja_mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then
fail "Output Ninja file changed after writing JSON module graph" fail "Output Ninja file changed after writing JSON module graph"
fi fi
run_soong json-module-graph run_soong json-module-graph
local json_mtime2=$(stat -c "%y" out/soong/module-graph.json) local -r json_mtime2=$(stat -c "%y" out/soong/module-graph.json)
if [[ "$json_mtime1" != "$json_mtime2" ]]; then if [[ "$json_mtime1" != "$json_mtime2" ]]; then
fail "JSON module graph file changed after writing Ninja file" fail "JSON module graph file changed after writing Ninja file"
fi fi
@@ -837,19 +837,19 @@ function test_bp2build_back_and_forth_null_build {
setup setup
run_soong run_soong
local output_mtime1=$(stat -c "%y" out/soong/build.ninja) local -r output_mtime1=$(stat -c "%y" out/soong/build.ninja)
run_soong bp2build run_soong bp2build
local output_mtime2=$(stat -c "%y" out/soong/build.ninja) local -r output_mtime2=$(stat -c "%y" out/soong/build.ninja)
if [[ "$output_mtime1" != "$output_mtime2" ]]; then if [[ "$output_mtime1" != "$output_mtime2" ]]; then
fail "Output Ninja file changed when switching to bp2build" fail "Output Ninja file changed when switching to bp2build"
fi fi
local marker_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker) local -r marker_mtime1=$(stat -c "%y" out/soong/bp2build_workspace_marker)
run_soong run_soong
local output_mtime3=$(stat -c "%y" out/soong/build.ninja) local -r output_mtime3=$(stat -c "%y" out/soong/build.ninja)
local marker_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker) local -r marker_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$output_mtime1" != "$output_mtime3" ]]; then if [[ "$output_mtime1" != "$output_mtime3" ]]; then
fail "Output Ninja file changed when switching to regular build from bp2build" fail "Output Ninja file changed when switching to regular build from bp2build"
fi fi
@@ -858,8 +858,8 @@ function test_bp2build_back_and_forth_null_build {
fi fi
run_soong bp2build run_soong bp2build
local output_mtime4=$(stat -c "%y" out/soong/build.ninja) local -r output_mtime4=$(stat -c "%y" out/soong/build.ninja)
local marker_mtime3=$(stat -c "%y" out/soong/bp2build_workspace_marker) local -r marker_mtime3=$(stat -c "%y" out/soong/bp2build_workspace_marker)
if [[ "$output_mtime1" != "$output_mtime4" ]]; then if [[ "$output_mtime1" != "$output_mtime4" ]]; then
fail "Output Ninja file changed when switching back to bp2build" fail "Output Ninja file changed when switching back to bp2build"
fi fi
@@ -880,10 +880,10 @@ function test_queryview_null_build() {
setup setup
run_soong queryview run_soong queryview
local output_mtime1=$(stat -c "%y" out/soong/queryview.marker) local -r output_mtime1=$(stat -c "%y" out/soong/queryview.marker)
run_soong queryview run_soong queryview
local output_mtime2=$(stat -c "%y" out/soong/queryview.marker) local -r output_mtime2=$(stat -c "%y" out/soong/queryview.marker)
if [[ "$output_mtime1" != "$output_mtime2" ]]; then if [[ "$output_mtime1" != "$output_mtime2" ]]; then
fail "Queryview marker file changed on null build" fail "Queryview marker file changed on null build"