Ferrochrome: Re-enable tests with more safe guards

This CL includes following changes
  - Ensure whether adb root success
  - Find and launch VM launcher based on intent action
  - Ensure that both host and DUT have enough space
  - Ensure arm64 arch
  - Ensure non-virtual device
  - Remove pushed image when test is finished (kill vmlauncher for it)
  - Enable verbose log by 'set -x'

Bug: 346742552
Change-Id: I74eb02821d3979f7548e15551a3e1c51938d9f71
Test: Locally on aosp_shiba, \
  tangorpro with go/abtd/run/L12000030004706790
diff --git a/tests/ferrochrome/Android.bp b/tests/ferrochrome/Android.bp
index 889f41e..f165b8f 100644
--- a/tests/ferrochrome/Android.bp
+++ b/tests/ferrochrome/Android.bp
@@ -4,10 +4,26 @@
 
 sh_test_host {
     name: "ferrochrome-tests",
-    src: "ferrochrome.sh",
+    src: ":ferrochrome-tests.sh",
+    test_suites: ["general-tests"],
     test_options: {
         unit_test: false,
     },
     per_testcase_directory: true,
     data: ["assets/vm_config.json"],
+    data_bins: ["ferrochrome-precondition-checker.sh"],
+}
+
+// Workaround for enabling verbose logging only on CI
+genrule {
+    name: "ferrochrome-tests.sh",
+    srcs: ["ferrochrome.sh"],
+    out: ["ferrochrome-tests"],
+    // This breaks shebang, but test will execute the script with bash
+    cmd: "echo \"set -x\" > $(out); cat $(in) >> $(out)",
+}
+
+sh_binary_host {
+    name: "ferrochrome-precondition-checker.sh",
+    src: "ferrochrome-precondition-checker.sh",
 }