Ensure directories in the Soong output dir have appropriate permissions, so that 'm clean' works.
In particular, Bazel sometimes creates directories whose files cannot be deleted.
Test: m clean used to fail after b build //system/timezone/apex:com.android.tzdata, but now it works
Test: Added integration test which fails without this change
Change-Id: I08c8feed21c31ec187fe40be513f7eb4865c8ac3
diff --git a/tests/soong_test.sh b/tests/soong_test.sh
new file mode 100755
index 0000000..905d708
--- /dev/null
+++ b/tests/soong_test.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -eu
+
+set -o pipefail
+
+# Tests of Soong functionality
+
+source "$(dirname "$0")/lib.sh"
+
+function test_m_clean_works {
+ setup
+
+ # Create a directory with files that cannot be removed
+ mkdir -p out/bad_directory_permissions
+ touch out/bad_directory_permissions/unremovable_file
+ # File permissions are fine but directory permissions are bad
+ chmod a+rwx out/bad_directory_permissions/unremovable_file
+ chmod a-rwx out/bad_directory_permissions
+
+ run_soong clean
+}
+
+test_m_clean_works