Android.bp: add tests

And patch to Android.bp file to include std dependency.

Test: mm
Test: cargo2android.py --run --device --dependencies --tests --patch=patches/Android.bp.patch
Test: atest spin_device_test_src_lib
Change-Id: I037b2da234fb2ced1bc24cb76fcfc7aa91594a35
diff --git a/Android.bp b/Android.bp
index 84a401c..20556ca 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,4 +1,4 @@
-// This file is generated by cargo2android.py --device --run --dependencies.
+// This file is generated by cargo2android.py --run --device --dependencies --tests --patch=patches/Android.bp.patch.
 
 rust_library {
     name: "libspin",
@@ -8,7 +8,31 @@
     edition: "2015",
     features: [
         "default",
+        "std",
         "ticket_mutex",
-	"std",
     ],
 }
+
+rust_defaults {
+    name: "spin_defaults",
+    crate_name: "spin",
+    srcs: ["src/lib.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2015",
+    features: [
+        "default",
+        "std",
+        "ticket_mutex",
+    ],
+}
+
+rust_test_host {
+    name: "spin_host_test_src_lib",
+    defaults: ["spin_defaults"],
+}
+
+rust_test {
+    name: "spin_device_test_src_lib",
+    defaults: ["spin_defaults"],
+}
diff --git a/TEST_MAPPING b/TEST_MAPPING
new file mode 100644
index 0000000..6e9bd8c
--- /dev/null
+++ b/TEST_MAPPING
@@ -0,0 +1,12 @@
+// Generated by cargo2android.py for tests in Android.bp
+{
+  "presubmit": [
+    {
+      "host": true,
+      "name": "spin_host_test_src_lib"
+    },
+    {
+      "name": "spin_device_test_src_lib"
+    }
+  ]
+}
diff --git a/patches/Android.bp.patch b/patches/Android.bp.patch
new file mode 100644
index 0000000..db27b2e
--- /dev/null
+++ b/patches/Android.bp.patch
@@ -0,0 +1,20 @@
+diff --git a/Android.bp b/Android.bp
+index 96531ab..43db8ef 100644
+--- a/Android.bp
++++ b/Android.bp
+@@ -8,6 +8,7 @@ rust_library {
+     edition: "2015",
+     features: [
+         "default",
++        "std",
+         "ticket_mutex",
+     ],
+ }
+@@ -21,6 +22,7 @@ rust_defaults {
+     edition: "2015",
+     features: [
+         "default",
++        "std",
+         "ticket_mutex",
+     ],
+ }