Add the system image test to the bazel sandwich

Also make -test.sh files executable, while we wait for a bazel update
that will tell us which FileWrite actions should be executable.

Bug: 297268692
Test: m bazel_sandwich
Change-Id: I60498577ba12813bff8bbdbc1b997ea4addefd17
diff --git a/android/defs.go b/android/defs.go
index 18eed2d..682111e 100644
--- a/android/defs.go
+++ b/android/defs.go
@@ -209,12 +209,14 @@
 	buildWriteFileRule(ctx, outputFile, content)
 }
 
-func CatFileRule(ctx BuilderContext, paths Paths, outputFile WritablePath) {
+// WriteExecutableFileRuleVerbatim is the same as WriteFileRuleVerbatim, but runs chmod +x on the result
+func WriteExecutableFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
+	intermediate := PathForIntermediates(ctx, "write_executable_file_intermediates").Join(ctx, outputFile.String())
+	WriteFileRuleVerbatim(ctx, intermediate, content)
 	ctx.Build(pctx, BuildParams{
-		Rule:        Cat,
-		Inputs:      paths,
-		Output:      outputFile,
-		Description: "combine files to " + outputFile.Base(),
+		Rule:   CpExecutable,
+		Output: outputFile,
+		Input:  intermediate,
 	})
 }