Enable Tests am: 22c601ebdd

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/futures-channel/+/2145020

Change-Id: Ib8f5847d88512b3d913c684534a7ef7aab4f20f0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/Android.bp b/Android.bp
index c7bc955..be3a87e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -41,6 +41,98 @@
     ],
 }
 
+rust_test {
+    name: "futures-channel_test_src_lib",
+    host_supported: true,
+    crate_name: "futures_channel",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.3.21",
+    srcs: ["src/lib.rs"],
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    test_options: {
+        unit_test: true,
+    },
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "futures-sink",
+        "sink",
+        "std",
+    ],
+    rustlibs: [
+        "libfutures",
+        "libfutures_core",
+        "libfutures_sink",
+        "libfutures_test",
+    ],
+}
+
+rust_defaults {
+    name: "futures-channel_test_defaults",
+    crate_name: "futures_channel",
+    cargo_env_compat: true,
+    cargo_pkg_version: "0.3.21",
+    test_suites: ["general-tests"],
+    auto_gen_config: true,
+    edition: "2018",
+    features: [
+        "alloc",
+        "default",
+        "futures-sink",
+        "sink",
+        "std",
+    ],
+    rustlibs: [
+        "libfutures",
+        "libfutures_channel",
+        "libfutures_core",
+        "libfutures_sink",
+        "libfutures_test",
+    ],
+}
+
+rust_test {
+    name: "futures-channel_test_tests_channel",
+    defaults: ["futures-channel_test_defaults"],
+    host_supported: true,
+    srcs: ["tests/channel.rs"],
+    test_options: {
+        unit_test: true,
+    },
+}
+
+rust_test {
+    name: "futures-channel_test_tests_mpsc-close",
+    defaults: ["futures-channel_test_defaults"],
+    host_supported: true,
+    srcs: ["tests/mpsc-close.rs"],
+    test_options: {
+        unit_test: true,
+    },
+}
+
+rust_test {
+    name: "futures-channel_test_tests_mpsc",
+    defaults: ["futures-channel_test_defaults"],
+    host_supported: true,
+    srcs: ["tests/mpsc.rs"],
+    test_options: {
+        unit_test: true,
+    },
+}
+
+rust_test {
+    name: "futures-channel_test_tests_oneshot",
+    defaults: ["futures-channel_test_defaults"],
+    host_supported: true,
+    srcs: ["tests/oneshot.rs"],
+    test_options: {
+        unit_test: true,
+    },
+}
+
 rust_library {
     name: "libfutures_channel",
     host_supported: true,
@@ -52,10 +144,13 @@
     features: [
         "alloc",
         "default",
+        "futures-sink",
+        "sink",
         "std",
     ],
     rustlibs: [
         "libfutures_core",
+        "libfutures_sink",
     ],
     apex_available: [
         "//apex_available:platform",
diff --git a/Cargo.toml b/Cargo.toml
index d0a13f6..66f5639 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -38,6 +38,8 @@
 default-features = false
 
 [dev-dependencies]
+futures = "0.3.21"
+futures-test = "0.3.21"
 
 [features]
 alloc = ["futures-core/alloc"]
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 5ef61de..b5bc1ee 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -5,6 +5,9 @@
       "path": "external/rust/crates/anyhow"
     },
     {
+      "path": "external/rust/crates/futures-test"
+    },
+    {
       "path": "external/rust/crates/futures-util"
     },
     {
@@ -25,6 +28,21 @@
       "name": "doh_unit_test"
     },
     {
+      "name": "futures-channel_test_src_lib"
+    },
+    {
+      "name": "futures-channel_test_tests_channel"
+    },
+    {
+      "name": "futures-channel_test_tests_mpsc"
+    },
+    {
+      "name": "futures-channel_test_tests_mpsc-close"
+    },
+    {
+      "name": "futures-channel_test_tests_oneshot"
+    },
+    {
       "name": "virtualizationservice_device_test"
     }
   ],
@@ -39,6 +57,21 @@
       "name": "doh_unit_test"
     },
     {
+      "name": "futures-channel_test_src_lib"
+    },
+    {
+      "name": "futures-channel_test_tests_channel"
+    },
+    {
+      "name": "futures-channel_test_tests_mpsc"
+    },
+    {
+      "name": "futures-channel_test_tests_mpsc-close"
+    },
+    {
+      "name": "futures-channel_test_tests_oneshot"
+    },
+    {
       "name": "virtualizationservice_device_test"
     }
   ]
diff --git a/cargo2android.json b/cargo2android.json
index a7e2a4b..5a6f21b 100644
--- a/cargo2android.json
+++ b/cargo2android.json
@@ -7,6 +7,8 @@
   ],
   "dependencies": true,
   "device": true,
+  "features": "alloc,default,std,sink",
   "min-sdk-version": "29",
-  "run": true
+  "run": true,
+  "tests": true
 }
diff --git a/patches/Cargo.toml.patch b/patches/Cargo.toml.patch
new file mode 100644
index 0000000..d1da570
--- /dev/null
+++ b/patches/Cargo.toml.patch
@@ -0,0 +1,13 @@
+diff --git a/Cargo.toml b/Cargo.toml
+index d0a13f6..66f5639 100644
+--- a/Cargo.toml
++++ b/Cargo.toml
+@@ -38,6 +38,8 @@ optional = true
+ default-features = false
+ 
+ [dev-dependencies]
++futures = "0.3.21"
++futures-test = "0.3.21"
+ 
+ [features]
+ alloc = ["futures-core/alloc"]