Enable tests

And disable doc comments tests since we don't have that crate, and
we want to test general code macros, not macros for comment docs.

Test: atest
Test: mm
Change-Id: I80bc9246261d5cb3cf070843c305ae98654f096f
diff --git a/Android.bp b/Android.bp
index 7c28208..ead8044 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,7 +1,76 @@
-// This file is generated by cargo2android.py --run --device --dependencies --patch=patches/Android.bp.diff.
+// This file is generated by cargo2android.py --run --device --dependencies --tests --patch=patches/Android.bp.diff.
+
+rust_defaults {
+    name: "lazy_static_defaults",
+    crate_name: "lazy_static",
+    // has rustc warnings
+    srcs: ["src/lib.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2015",
+}
+
+rust_test_host {
+    name: "lazy_static_host_test_src_lib",
+    defaults: ["lazy_static_defaults"],
+    test_options: {
+        unit_test: true,
+    },
+}
+
+rust_test {
+    name: "lazy_static_device_test_src_lib",
+    defaults: ["lazy_static_defaults"],
+}
+
+rust_defaults {
+    name: "lazy_static_defaults_lazy_static",
+    crate_name: "lazy_static",
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2015",
+    rustlibs: [
+        "liblazy_static",
+    ],
+}
+
+rust_test_host {
+    name: "lazy_static_host_test_tests_no_std",
+    defaults: ["lazy_static_defaults_lazy_static"],
+    // has rustc warnings
+    srcs: ["tests/no_std.rs"],
+    test_options: {
+        unit_test: true,
+    },
+}
+
+rust_test {
+    name: "lazy_static_device_test_tests_no_std",
+    defaults: ["lazy_static_defaults_lazy_static"],
+    // has rustc warnings
+    srcs: ["tests/no_std.rs"],
+}
+
+rust_test_host {
+    name: "lazy_static_host_test_tests_test",
+    defaults: ["lazy_static_defaults_lazy_static"],
+    // has rustc warnings
+    srcs: ["tests/test.rs"],
+    test_options: {
+        unit_test: true,
+    },
+}
+
+rust_test {
+    name: "lazy_static_device_test_tests_test",
+    defaults: ["lazy_static_defaults_lazy_static"],
+    // has rustc warnings
+    srcs: ["tests/test.rs"],
+}
 
 rust_library {
     name: "liblazy_static",
+    // has rustc warnings
     host_supported: true,
     crate_name: "lazy_static",
     srcs: ["src/lib.rs"],
@@ -12,3 +81,5 @@
     ],
     min_sdk_version: "29",
 }
+
+// dependent_library ["feature_list"]
diff --git a/TEST_MAPPING b/TEST_MAPPING
index fad2d90..1842f5d 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -1,23 +1,26 @@
-// Generated by cargo2android.py for tests in Android.bp
+// Generated by update_crate_tests.py for tests that depend on this crate.
 {
   "presubmit": [
     {
-      "host": true,
-      "name": "thread_local_host_test_src_lib"
+      "name": "quiche_device_test_src_lib"
+    },
+    {
+      "name": "lazy_static_device_test_tests_test"
+    },
+    {
+      "name": "libsqlite3-sys_device_test_src_lib"
+    },
+    {
+      "name": "lazy_static_device_test_tests_no_std"
     },
     {
       "name": "android_logger_device_test_src_lib"
     },
     {
-      "host": true,
-      "name": "tokio-macros_host_test_src_lib"
+      "name": "authfs_device_test_src_lib"
     },
     {
-      "host": true,
-      "name": "libsqlite3-sys_host_test_src_lib"
-    },
-    {
-      "name": "libsqlite3-sys_device_test_src_lib"
+      "name": "lazy_static_device_test_src_lib"
     }
   ]
 }
diff --git a/patches/Android.bp.diff b/patches/Android.bp.diff
index 3c1b4cb..3406a8e 100644
--- a/patches/Android.bp.diff
+++ b/patches/Android.bp.diff
@@ -1,11 +1,26 @@
---- Android.bp	2020-12-14 18:47:48.373508351 +0900
-+++ Android.bp.new	2020-12-14 18:47:04.753908034 +0900
-@@ -2,8 +2,17 @@
+diff --git a/Android.bp b/Android.bp
+index 937918e..ead8044 100644
+--- a/Android.bp
++++ b/Android.bp
+@@ -8,9 +8,6 @@ rust_defaults {
+     test_suites: ["general-tests"],
+     auto_gen_config: true,
+     edition: "2015",
+-    rustlibs: [
+-        "libdoc_comment",
+-    ],
+ }
  
- rust_library {
-     name: "liblazy_static",
-+    // has rustc warnings
-     host_supported: true,
+ rust_test_host {
+@@ -33,7 +30,6 @@ rust_defaults {
+     auto_gen_config: true,
+     edition: "2015",
+     rustlibs: [
+-        "libdoc_comment",
+         "liblazy_static",
+     ],
+ }
+@@ -79,7 +75,11 @@ rust_library {
      crate_name: "lazy_static",
      srcs: ["src/lib.rs"],
      edition: "2015",
@@ -15,6 +30,6 @@
 +    ],
 +    min_sdk_version: "29",
  }
-+
-+// dependent_library ["feature_list"]
-+//   doc-comment-0.3.3
+ 
+ // dependent_library ["feature_list"]
+-//   doc-comment-0.3.3
diff --git a/patches/lib.rs.diff b/patches/lib.rs.diff
new file mode 100644
index 0000000..cb9510f
--- /dev/null
+++ b/patches/lib.rs.diff
@@ -0,0 +1,24 @@
+diff --git a/src/lib.rs b/src/lib.rs
+index cada0dc..0d9d46e 100644
+--- a/src/lib.rs
++++ b/src/lib.rs
+@@ -104,12 +104,13 @@ This crate provides one cargo feature:
+ #[doc(hidden)]
+ pub mod lazy;
+ 
+-#[cfg(test)]
+-#[macro_use]
+-extern crate doc_comment;
+-
+-#[cfg(test)]
+-doctest!("../README.md");
++// ANDROID: disable tests that require doc_comment crate.
++//#[cfg(test)]
++//#[macro_use]
++//extern crate doc_comment;
++//
++//#[cfg(test)]
++//`doctest!("../README.md");
+ 
+ #[cfg(feature = "spin_no_std")]
+ #[path="core_lazy.rs"]
diff --git a/src/lib.rs b/src/lib.rs
index cada0dc..0d9d46e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -104,12 +104,13 @@
 #[doc(hidden)]
 pub mod lazy;
 
-#[cfg(test)]
-#[macro_use]
-extern crate doc_comment;
-
-#[cfg(test)]
-doctest!("../README.md");
+// ANDROID: disable tests that require doc_comment crate.
+//#[cfg(test)]
+//#[macro_use]
+//extern crate doc_comment;
+//
+//#[cfg(test)]
+//`doctest!("../README.md");
 
 #[cfg(feature = "spin_no_std")]
 #[path="core_lazy.rs"]