[crashpad] Migrate to new component templates

Bug: fuchsia:65068
Test: Ran crashpad-test on device.
Test: fx shell crashpad_database_util
Change-Id: I9c371f6d1eeaa44dd770535bddc6aa690f36d739
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2758252
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
GitOrigin-RevId: 6b55b8adbaf378438743a99365aec171af786971
diff --git a/BUILD.gn b/BUILD.gn
index 1ec9b97..08510f4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -64,11 +64,11 @@
   }
 
   if (crashpad_is_in_fuchsia) {
-    import("//build/package.gni")
-    package("crashpad-test") {
-      testonly = true
-
+    import("//src/sys/build/components.gni")
+    fuchsia_test_component("crashpad-test-component") {
+      manifest = "test/fuchsia_crashpad_tests.cmx"
       deps = [
+        ":crashpad-test-resources",
         ":crashpad_tests",
         "snapshot:crashpad_snapshot_test_both_dt_hash_styles",
         "snapshot:crashpad_snapshot_test_module",
@@ -77,86 +77,43 @@
         "test:crashpad_test_test_multiprocess_exec_test_child",
         "util:http_transport_test_server",
       ]
-
-      tests = [
-        {
-          name = "crashpad_tests"
-        },
-      ]
-
-      meta = [
-        {
-          path = "test/fuchsia_crashpad_tests.cmx"
-          dest = "crashpad_tests.cmx"
-        },
-      ]
-
-      binaries = [
-        {
-          name = "crashpad_test_test_multiprocess_exec_test_child"
-          dest = "crashpad_test_test_multiprocess_exec_test_child"
-        },
-        {
-          name = "http_transport_test_server"
-          dest = "http_transport_test_server"
-        },
-      ]
-
-      loadable_modules = [
-        {
-          name = "crashpad_snapshot_test_both_dt_hash_styles.so"
-        },
-        {
-          name = "crashpad_snapshot_test_module.so"
-        },
-        {
-          name = "crashpad_snapshot_test_module_large.so"
-        },
-        {
-          name = "crashpad_snapshot_test_module_small.so"
-        },
-      ]
-
-      resources = [
-        {
-          path = "util/net/testdata/ascii_http_body.txt"
-          dest = "util/net/testdata/ascii_http_body.txt"
-        },
-        {
-          path = "util/net/testdata/binary_http_body.dat"
-          dest = "util/net/testdata/binary_http_body.dat"
-        },
-        {
-          path = "test/test_paths_test_data_root.txt"
-          dest = "test/test_paths_test_data_root.txt"
-        },
-      ]
-
-      if (crashpad_use_boringssl_for_http_transport_socket) {
-        resources += [
-          {
-            path = "util/net/testdata/crashpad_util_test_cert.pem"
-            dest = "util/net/testdata/crashpad_util_test_cert.pem"
-          },
-          {
-            path = "util/net/testdata/crashpad_util_test_key.pem"
-            dest = "util/net/testdata/crashpad_util_test_key.pem"
-          },
-        ]
-      }
     }
 
-    package("crashpad-database-util") {
-      deps = [ "tools:crashpad_database_util" ]
+    fuchsia_test_package("crashpad-test") {
+      test_components = [ ":crashpad-test-component" ]
+    }
 
-      binaries = [
-        {
-          name = "crashpad_database_util"
-          shell = true
-        },
+    _resource_files = [
+      "test/test_paths_test_data_root.txt",
+      "util/net/testdata/ascii_http_body.txt",
+      "util/net/testdata/binary_http_body.dat",
+    ]
+    if (crashpad_use_boringssl_for_http_transport_socket) {
+      _resource_files += [
+        "util/net/testdata/crashpad_util_test_cert.pem",
+        "util/net/testdata/crashpad_util_test_key.pem",
       ]
     }
 
+    _resources = []
+    foreach(resource_file, _resource_files) {
+      _resource_file_target = string_replace(resource_file, "/", "_")
+      resource("${_resource_file_target}") {
+        sources = [ "${resource_file}" ]
+        outputs = [ "data/${resource_file}" ]
+      }
+      _resources += [ ":${_resource_file_target}" ]
+    }
+
+    group("crashpad-test-resources") {
+      deps = _resources
+    }
+
+    fuchsia_shell_package("crashpad-database-util") {
+      package_name = "crashpad_database_util"
+      deps = [ "tools:crashpad_database_util" ]
+    }
+
     group("tests") {
       testonly = true
 
diff --git a/test/fuchsia_crashpad_tests.cmx b/test/fuchsia_crashpad_tests.cmx
index 87004b2..47837e7 100644
--- a/test/fuchsia_crashpad_tests.cmx
+++ b/test/fuchsia_crashpad_tests.cmx
@@ -11,7 +11,7 @@
         "sdk/lib/diagnostics/syslog/client.shard.cmx"
     ],
     "program": {
-        "binary": "test/crashpad_tests"
+        "binary": "bin/crashpad_tests"
     },
     "sandbox": {
         "features": [