Use linkme rather than collecting tests manually.

Bug: 260692911
Test: atest apkdmverity.test libdm_rust.test
Change-Id: I9355dc13e31c4487109be31e2d7a7a50b16fb889
diff --git a/libs/ignorabletest/src/lib.rs b/libs/ignorabletest/src/lib.rs
index 746c0dd..c7243e6 100644
--- a/libs/ignorabletest/src/lib.rs
+++ b/libs/ignorabletest/src/lib.rs
@@ -5,42 +5,17 @@
 #[doc(hidden)]
 pub use libtest_mimic as _libtest_mimic;
 #[doc(hidden)]
+pub use linkme as _linkme;
+#[doc(hidden)]
 pub use paste as _paste;
 
 /// Macro to generate the main function for the test harness.
 #[macro_export]
 macro_rules! test_main {
-    ($tests:expr) => {
+    () => {
         #[cfg(test)]
         fn main() {
-            ignorabletest::runner::main($tests)
-        }
-    };
-}
-
-/// Macro to generate a function which returns a list of tests to be run.
-///
-/// # Usage
-/// ```
-/// list_tests!{all_tests: [test_this, test_that]};
-///
-/// test!(test_this);
-/// fn test_this() {
-///   // ...
-/// }
-///
-/// test!(test_that);
-/// fn test_that() {
-///   // ...
-/// }
-/// ```
-#[macro_export]
-macro_rules! list_tests {
-    {$function_name:ident: [$( $test_name:ident ),* $(,)? ]} => {
-        pub fn $function_name() -> ::std::vec::Vec<$crate::_libtest_mimic::Trial> {
-            vec![
-                $( $crate::_paste::paste!([<__test_ $test_name>]()) ),*
-            ]
+            ignorabletest::runner::main()
         }
     };
 }
@@ -59,6 +34,7 @@
 macro_rules! test {
     ($test_name:ident) => {
         $crate::_paste::paste!(
+            #[$crate::_linkme::distributed_slice($crate::runner::IGNORABLETEST_TESTS)]
             fn [< __test_ $test_name >]() -> $crate::_libtest_mimic::Trial {
                 $crate::_libtest_mimic::Trial::test(
                     ::std::stringify!($test_name),
@@ -69,6 +45,7 @@
     };
     ($test_name:ident, ignore_if: $ignore_expr:expr) => {
         $crate::_paste::paste!(
+            #[$crate::_linkme::distributed_slice($crate::runner::IGNORABLETEST_TESTS)]
             fn [< __test_ $test_name >]() -> $crate::_libtest_mimic::Trial {
                 $crate::_libtest_mimic::Trial::test(
                     ::std::stringify!($test_name),
diff --git a/libs/ignorabletest/src/runner.rs b/libs/ignorabletest/src/runner.rs
index e1b14e0..4ec3d79 100644
--- a/libs/ignorabletest/src/runner.rs
+++ b/libs/ignorabletest/src/runner.rs
@@ -2,14 +2,21 @@
 
 use core::ops::{Deref, FnOnce};
 use libtest_mimic::{Arguments, Failed, Trial};
+use linkme::distributed_slice;
 use std::env;
 
 /// Command-line arguments to ignore, because they are not supported by libtest-mimic.
 const IGNORED_ARGS: [&str; 2] = ["-Zunstable-options", "--report-time"];
 
+/// The collection of all tests to run.
+#[doc(hidden)]
+#[distributed_slice]
+pub static IGNORABLETEST_TESTS: [fn() -> Trial] = [..];
+
 /// Runs all tests.
-pub fn main(tests: Vec<Trial>) {
+pub fn main() {
     let args = Arguments::from_iter(env::args().filter(|arg| !IGNORED_ARGS.contains(&arg.deref())));
+    let tests = IGNORABLETEST_TESTS.iter().map(|test| test()).collect();
     libtest_mimic::run(&args, tests).exit();
 }