From 4e17a2e50333e9c6fc3c7a7f9ea905cf37150785 Mon Sep 17 00:00:00 2001 From: Usta Shrestha Date: Thu, 8 Dec 2022 01:18:44 -0500 Subject: [PATCH] cosmetic: getting rid of SC2155 warnings https://github.com/koalaman/shellcheck/wiki/SC2155 Bug: N/A Test: bootstrap_test.sh Change-Id: I3ce7ab2c7b2cf827e32c3cde0dfbcc932fc48039 --- tests/bootstrap_test.sh | 94 ++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/tests/bootstrap_test.sh b/tests/bootstrap_test.sh index d89e6b702..7925ab00e 100755 --- a/tests/bootstrap_test.sh +++ b/tests/bootstrap_test.sh @@ -17,11 +17,11 @@ function test_smoke { function test_null_build() { setup run_soong - local bootstrap_mtime1=$(stat -c "%y" out/soong/bootstrap.ninja) - local output_mtime1=$(stat -c "%y" out/soong/build.ninja) + local -r bootstrap_mtime1=$(stat -c "%y" out/soong/bootstrap.ninja) + local -r output_mtime1=$(stat -c "%y" out/soong/build.ninja) run_soong - local bootstrap_mtime2=$(stat -c "%y" out/soong/bootstrap.ninja) - local output_mtime2=$(stat -c "%y" out/soong/build.ninja) + local -r bootstrap_mtime2=$(stat -c "%y" out/soong/bootstrap.ninja) + local -r output_mtime2=$(stat -c "%y" out/soong/build.ninja) if [[ "$bootstrap_mtime1" == "$bootstrap_mtime2" ]]; then # 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() { setup 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 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 fail "Bootstrap Ninja file did not change" @@ -79,7 +79,7 @@ EOF function test_add_android_bp() { setup run_soong - local mtime1=$(stat -c "%y" out/soong/build.ninja) + local -r mtime1=$(stat -c "%y" out/soong/build.ninja) mkdir -p a cat > a/Android.bp <<'EOF' @@ -91,7 +91,7 @@ EOF touch a/my_little_binary_host.py 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 fail "Output Ninja file did not change" fi @@ -142,7 +142,7 @@ python_binary_host { EOF touch a/my_little_binary_host.py 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 @@ -151,7 +151,7 @@ EOF fi 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 # 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" 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 fail "Ninja file rewritten on null incremental build" fi run_soong - local ninja_mtime3=$(stat -c "%y" out/soong/build.ninja) - local glob_deps_mtime3=$(stat -c "%y" "$glob_deps_file") + local -r ninja_mtime3=$(stat -c "%y" out/soong/build.ninja) + local -r glob_deps_mtime3=$(stat -c "%y" "$glob_deps_file") if [[ "$ninja_mtime2" != "$ninja_mtime3" ]]; then fail "Ninja file rewritten on null incremental build" @@ -192,12 +192,12 @@ python_binary_host { EOF touch a/my_little_binary_host.py 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 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 fail "Output Ninja file did not change" fi @@ -275,10 +275,10 @@ EOF run_soong grep -q "CHERRY IS RED" out/soong/build.ninja \ || 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 - local mtime2=$(stat -c "%y" out/soong/build.ninja) + local -r mtime2=$(stat -c "%y" out/soong/build.ninja) if [[ "$mtime1" != "$mtime2" ]]; then fail "Output Ninja file changed when environment variable did not" fi @@ -288,7 +288,7 @@ EOF function test_create_global_include_directory() { setup 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 # 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 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 fail "Output Ninja file changed when top level directory changed" fi @@ -306,7 +306,7 @@ function test_create_global_include_directory() { mkdir -p system/core/include 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 fail "Output Ninja file did not change when global include directory created" fi @@ -317,7 +317,7 @@ function test_create_global_include_directory() { function test_add_file_to_soong_build() { setup run_soong - local mtime1=$(stat -c "%y" out/soong/build.ninja) + local -r mtime1=$(stat -c "%y" out/soong/build.ninja) mkdir -p a cat > a/Android.bp <<'EOF' @@ -379,7 +379,7 @@ func (p *picardSingleton) GenerateBuildActions(ctx android.SingletonContext) { EOF 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 fail "Output Ninja file did not change" fi @@ -457,7 +457,7 @@ func (p *picardSingleton) GenerateBuildActions(ctx android.SingletonContext) { EOF 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" @@ -489,7 +489,7 @@ func init() { EOF 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 fail "Output Ninja file did not change" fi @@ -514,20 +514,20 @@ function test_null_build_after_soong_docs() { setup 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 - 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 - 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 fail "Output Ninja file changed on null build" fi 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 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 && \ 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 else 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 || \ 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" fi } @@ -606,11 +606,11 @@ EOF fail "BUILD file in symlink forest was not created"; 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 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 fail "BUILD.bazel file was regenerated" @@ -657,10 +657,10 @@ function test_bp2build_null_build { setup 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 - 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 fail "Output Ninja file changed on null build" @@ -717,19 +717,19 @@ function test_json_module_graph_back_and_forth_null_build() { setup 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 - 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 - 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 fail "Output Ninja file changed after writing JSON module graph" fi 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 fail "JSON module graph file changed after writing Ninja file" fi @@ -837,19 +837,19 @@ function test_bp2build_back_and_forth_null_build { setup 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 - 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 fail "Output Ninja file changed when switching to bp2build" 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 - local output_mtime3=$(stat -c "%y" out/soong/build.ninja) - local marker_mtime2=$(stat -c "%y" out/soong/bp2build_workspace_marker) + 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 @@ -858,8 +858,8 @@ function test_bp2build_back_and_forth_null_build { fi run_soong bp2build - local output_mtime4=$(stat -c "%y" out/soong/build.ninja) - local marker_mtime3=$(stat -c "%y" out/soong/bp2build_workspace_marker) + 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 @@ -880,10 +880,10 @@ function test_queryview_null_build() { setup 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 - 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 fail "Queryview marker file changed on null build"