[component][fuzzing] Reorganize manifests

This CL reorganizes the manifests according to the following heuristic:

 * Manifests for each component's binaries are found in a meta/
   directory under the corresponding source directory, e.g.
   .../framework/engine/meta/engine.cml.
 * Manifest shards for libraries are located alongside their source
   code, e.g. .../framework/adapters/llvm.shard.cml.
 * Unit test packages are at the top-level, so their manifests are under
   .../framework/meta.
 * Integration tests are under .../tests, and otherwise follow the rules
   above.

Change-Id: I88ea53488fad9cd1f02e05a46b1d6893f7f7903c
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/680317
Commit-Queue: Aaron Green <aarongreen@google.com>
Reviewed-by: Dmitry Yatsushkevich <dmitryya@google.com>
diff --git a/src/sys/fuzzing/common/meta/test.shard.cml b/src/sys/fuzzing/common/meta/test.shard.cml
deleted file mode 100644
index 0ffb3db..0000000
--- a/src/sys/fuzzing/common/meta/test.shard.cml
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2022 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [
-        "//sdk/lib/inspect/client.shard.cml",
-        "//src/sys/test_runners/gtest/default.shard.cml",
-        "syslog/client.shard.cml",
-    ],
-    use: [
-        {
-            protocol: [ "fuchsia.process.Launcher" ],
-        },
-    ],
-}
diff --git a/src/sys/fuzzing/common/meta/unittests.cml b/src/sys/fuzzing/common/meta/unittests.cml
index 3de4dbf..b2a87c3 100644
--- a/src/sys/fuzzing/common/meta/unittests.cml
+++ b/src/sys/fuzzing/common/meta/unittests.cml
@@ -2,7 +2,11 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 {
-    include: [ "//src/sys/fuzzing/common/meta/test.shard.cml" ],
+    include: [
+        "//sdk/lib/inspect/client.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
+        "syslog/client.shard.cml",
+    ],
     program: {
         binary: "test/component_fuzzing_common_unittests",
     },
diff --git a/src/sys/fuzzing/framework/BUILD.gn b/src/sys/fuzzing/framework/BUILD.gn
index 2478b92..99e644c 100644
--- a/src/sys/fuzzing/framework/BUILD.gn
+++ b/src/sys/fuzzing/framework/BUILD.gn
@@ -8,12 +8,15 @@
 group("tests") {
   testonly = true
   deps = [
-    ":default-tests",
-    ":fatal-tests",
+    ":fatal-unittests-pkg",
+    ":unittests-pkg",
+    "tests",
   ]
 }
 
-test("unittests_bin") {
+# This package contains "normal" unit tests.
+
+test("unittests-bin") {
   output_name = "component_fuzzing_framework_unittests"
   visibility = [ ":*" ]
   testonly = true
@@ -26,7 +29,22 @@
   ]
 }
 
-test("fatal_unittests_bin") {
+fuchsia_test_component("unittests") {
+  manifest = "meta/unittests.cml"
+  deps = [
+    ":unittests-bin",
+    "testing/data:corpus",
+  ]
+}
+
+fuchsia_test_package("unittests-pkg") {
+  package_name = "component-fuzzing-framework-tests"
+  test_components = [ ":unittests" ]
+}
+
+# This package contains unit tests that produce fatal error messages.
+
+test("fatal-unittests-bin") {
   output_name = "component_fuzzing_framework_fatal_unittests"
   visibility = [ "../*" ]
   testonly = true
@@ -36,81 +54,12 @@
   ]
 }
 
-fuchsia_test_component("unittests") {
-  manifest = "meta/unittests.cml"
-  deps = [
-    ":unittests_bin",
-    "testing/data:corpus",
-  ]
-}
-
 fuchsia_test_component("fatal-unittests") {
   manifest = "meta/fatal-unittests.cml"
-  deps = [ ":fatal_unittests_bin" ]
+  deps = [ ":fatal-unittests-bin" ]
 }
 
-fuchsia_test_component("test-engine") {
-  manifest = "meta/test-engine.cml"
-  deps = [ "testing:engine" ]
-}
-
-fuchsia_test_component("integration-tests") {
-  visibility = [ ":*" ]
-  manifest = "meta/integration-tests.cml"
-  deps = [
-    "tests:framework-integration-tests",
-    "//src/sys/fuzzing/framework/engine:engine-bin",
-  ]
-}
-
-fuchsia_test_component("test-fuzzer") {
-  manifest = "meta/test-fuzzer.cml"
-  deps = [
-    "testing/data:corpus",
-    "tests:fuzzer",
-  ]
-}
-
-fuchsia_test_component("test-fuzzer-uninstrumented") {
-  manifest = "meta/test-fuzzer-uninstrumented.cml"
-  deps = [
-    "testing/data:corpus",
-    "tests:fuzzer-uninstrumented",
-  ]
-}
-
-# This component contains an integration test that uses the "real" fuzzing engine that generates
-# inputs to drive a simple test fuzzer, thereby imitating a real fuzzer.
-fuchsia_test_component("fuzzer-realm") {
-  manifest = "meta/fuzzer-realm.cml"
-  deps = [
-    ":integration-tests",
-    ":test-fuzzer",
-    "//src/sys/fuzzing/framework/coverage",
-  ]
-}
-
-# This component contains an integration test that uses a test "engine" that uses fixed inputs to
-# drive a simple test fuzzer, thereby imitating the auto-generated fuzzer tests that run in CQ.
-fuchsia_test_component("fuzzer-test-realm") {
-  manifest = "meta/fuzzer-test-realm.cml"
-  deps = [
-    ":test-engine",
-    ":test-fuzzer-uninstrumented",
-    "//src/sys/fuzzing/framework/coverage",
-  ]
-}
-
-fuchsia_test_package("default-tests") {
-  package_name = "component-fuzzing-framework-tests"
-  test_components = [
-    ":unittests",
-    ":fuzzer-realm",
-    ":fuzzer-test-realm",
-  ]
-}
-
-fuchsia_test_package("fatal-tests") {
+fuchsia_test_package("fatal-unittests-pkg") {
   package_name = "component-fuzzing-framework-fatal-tests"
 
   # Some tests involve handling intentional crashes.
diff --git a/src/sys/fuzzing/framework/meta/test-fuzzer.shard.cml b/src/sys/fuzzing/framework/adapters/llvm.shard.cml
similarity index 77%
rename from src/sys/fuzzing/framework/meta/test-fuzzer.shard.cml
rename to src/sys/fuzzing/framework/adapters/llvm.shard.cml
index d3f873c..c823701 100644
--- a/src/sys/fuzzing/framework/meta/test-fuzzer.shard.cml
+++ b/src/sys/fuzzing/framework/adapters/llvm.shard.cml
@@ -1,6 +1,9 @@
 // Copyright 2022 The Fuchsia Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
+// This manifest shard corresponds to the fuzz target adapter component, which
+// maps test inputs from the engine to the target component(s) being fuzzed.
 {
     include: [
         "//sdk/lib/inspect/client.shard.cml",
@@ -8,16 +11,12 @@
     ],
     program: {
         runner: "elf",
-        args: [ "data/corpus" ],
     },
     capabilities: [
         {
             protocol: [ "fuchsia.fuzzer.TargetAdapter" ],
         },
     ],
-    use: [
-        { protocol: "fuchsia.process.Launcher" },
-    ],
     expose: [
         {
             protocol: [ "fuchsia.fuzzer.TargetAdapter" ],
diff --git a/src/sys/fuzzing/framework/coverage/BUILD.gn b/src/sys/fuzzing/framework/coverage/BUILD.gn
index 147de10..0f9d075 100644
--- a/src/sys/fuzzing/framework/coverage/BUILD.gn
+++ b/src/sys/fuzzing/framework/coverage/BUILD.gn
@@ -40,7 +40,7 @@
 
 fuchsia_component("coverage") {
   testonly = true
-  manifest = "../meta/coverage.cml"
+  manifest = "meta/coverage.cml"
   deps = [ ":coverage-bin" ]
 }
 
@@ -56,8 +56,8 @@
   ]
   deps = [
     ":coverage-lib",
-    "../testing",
     "//src/sys/fuzzing/fidl:fuchsia.fuzzer",
+    "//src/sys/fuzzing/framework/testing",
     "//third_party/googletest:gtest",
   ]
 }
diff --git a/src/sys/fuzzing/framework/coverage/meta/coverage.cml b/src/sys/fuzzing/framework/coverage/meta/coverage.cml
new file mode 100644
index 0000000..8920f438
--- /dev/null
+++ b/src/sys/fuzzing/framework/coverage/meta/coverage.cml
@@ -0,0 +1,26 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This manifest corresponds to the coverage component that forwards coverage
+// data from targets to the engine.
+{
+    include: [ "syslog/client.shard.cml" ],
+    program: {
+        runner: "elf",
+        binary: "bin/component_fuzzing_coverage",
+    },
+    capabilities: [
+        { protocol: "fuchsia.fuzzer.Instrumentation" },
+        { protocol: "fuchsia.fuzzer.CoverageProvider" },
+    ],
+    expose: [
+        {
+            protocol: [
+                "fuchsia.fuzzer.CoverageProvider",
+                "fuchsia.fuzzer.Instrumentation",
+            ],
+            from: "self",
+        },
+    ],
+}
diff --git a/src/sys/fuzzing/framework/engine/BUILD.gn b/src/sys/fuzzing/framework/engine/BUILD.gn
index 2fca1b6..d0c9c3e 100644
--- a/src/sys/fuzzing/framework/engine/BUILD.gn
+++ b/src/sys/fuzzing/framework/engine/BUILD.gn
@@ -4,6 +4,9 @@
 
 import("//build/components/fuchsia_component.gni")
 
+# Both the "real" and "test" engines used in fuzzers and fuzzer tests,
+# respectively, use the adapter-client code to connect to the fuzz target
+# adapter component.
 source_set("adapter-client") {
   visibility = [ "../*" ]
   testonly = true
@@ -26,6 +29,8 @@
   ]
 }
 
+# This source set is the core of the "real" engine and includes the coverage
+# processing and input mutation.
 source_set("engine-lib") {
   visibility = [ "../*" ]
   testonly = true
@@ -71,7 +76,7 @@
 
 fuchsia_component("engine") {
   testonly = true
-  manifest = "../meta/engine.cml"
+  manifest = "meta/engine.cml"
   deps = [ ":engine-bin" ]
 }
 
@@ -88,11 +93,12 @@
   ]
   public_deps = [
     ":engine-lib",
-    "../target:no_hooks",
-    "../testing",
     "//src/sys/fuzzing/common:runner-unittests",
     "//src/sys/fuzzing/common/testing",
     "//src/sys/fuzzing/fidl:fuchsia.fuzzer",
+    "//src/sys/fuzzing/framework/coverage:coverage-lib",
+    "//src/sys/fuzzing/framework/target:no_hooks",
+    "//src/sys/fuzzing/framework/testing",
     "//third_party/googletest:gtest",
   ]
 }
@@ -113,9 +119,9 @@
   ]
   deps = [
     ":testing",
-    "../testing:test-target",
     "//src/lib/files",
     "//src/sys/fuzzing/common:runner-unittests",
+    "//src/sys/fuzzing/framework/testing:test-target",
   ]
 }
 
@@ -129,7 +135,7 @@
   ]
   deps = [
     ":testing",
-    "../testing:test-target",
     "//src/sys/fuzzing/common:runner-fatal-unittests",
+    "//src/sys/fuzzing/framework/testing:test-target",
   ]
 }
diff --git a/src/sys/fuzzing/framework/engine/default.shard.cml b/src/sys/fuzzing/framework/engine/default.shard.cml
new file mode 100644
index 0000000..d51fd00
--- /dev/null
+++ b/src/sys/fuzzing/framework/engine/default.shard.cml
@@ -0,0 +1,34 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This manifest shard corresponds to both the "real" and "test" engines used in
+// fuzzers and fuzzer tests, respectively.
+{
+    include: [
+        "//sdk/lib/inspect/client.shard.cml",
+        "syslog/client.shard.cml",
+    ],
+    children: [
+        {
+            name: "fuzzer",
+            url: "#meta/fuzzer.cm",
+        },
+    ],
+    use: [
+        {
+            protocol: "fuchsia.fuzzer.TargetAdapter",
+            from: "#fuzzer",
+        },
+    ],
+    offer: [
+        {
+            protocol: [
+                "fuchsia.logger.LogSink",
+                "fuchsia.process.Launcher",
+            ],
+            from: "parent",
+            to: "#fuzzer",
+        },
+    ],
+}
diff --git a/src/sys/fuzzing/framework/engine/meta/engine.cml b/src/sys/fuzzing/framework/engine/meta/engine.cml
new file mode 100644
index 0000000..5c4728a
--- /dev/null
+++ b/src/sys/fuzzing/framework/engine/meta/engine.cml
@@ -0,0 +1,25 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This manifest corresponds to the "real" engine used by fuzzers.
+{
+    include: [
+        "//src/sys/fuzzing/framework/engine/default.shard.cml",
+        "//src/sys/test_runners/fuzz/default.shard.cml",
+    ],
+    program: {
+        binary: "bin/component_fuzzing_engine",
+    },
+    use: [
+        { protocol: "fuchsia.fuzzer.CoverageProvider" },
+        { protocol: "fuchsia.process.Launcher" },
+    ],
+    offer: [
+        {
+            protocol: "fuchsia.fuzzer.Instrumentation",
+            from: "parent",
+            to: "#fuzzer",
+        },
+    ],
+}
diff --git a/src/sys/fuzzing/framework/meta/coverage.cml b/src/sys/fuzzing/framework/meta/coverage.cml
deleted file mode 100644
index 43bc7b2..0000000
--- a/src/sys/fuzzing/framework/meta/coverage.cml
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2021 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [ "syslog/client.shard.cml" ],
-    program: {
-        runner: "elf",
-        binary: "bin/component_fuzzing_coverage",
-    },
-    capabilities: [
-        { protocol: "fuchsia.fuzzer.Instrumentation" },
-        { protocol: "fuchsia.fuzzer.CoverageProvider" },
-    ],
-    expose: [
-        {
-            protocol: [ "fuchsia.fuzzer.Instrumentation" ],
-            from: "self",
-        },
-        {
-            protocol: [ "fuchsia.fuzzer.CoverageProvider" ],
-            from: "self",
-        },
-    ],
-}
diff --git a/src/sys/fuzzing/framework/meta/engine.cml b/src/sys/fuzzing/framework/meta/engine.cml
deleted file mode 100644
index 8fd1b70..0000000
--- a/src/sys/fuzzing/framework/meta/engine.cml
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2021 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [
-        "//src/sys/test_runners/fuzz/default.shard.cml",
-        "syslog/client.shard.cml",
-    ],
-    program: {
-        binary: "bin/component_fuzzing_engine",
-    },
-    use: [
-        { protocol: "fuchsia.fuzzer.TargetAdapter" },
-        { protocol: "fuchsia.fuzzer.CoverageProvider" },
-    ],
-}
diff --git a/src/sys/fuzzing/framework/meta/fatal-unittests.cml b/src/sys/fuzzing/framework/meta/fatal-unittests.cml
index 94b87cc..74feddb 100644
--- a/src/sys/fuzzing/framework/meta/fatal-unittests.cml
+++ b/src/sys/fuzzing/framework/meta/fatal-unittests.cml
@@ -2,8 +2,15 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 {
-    include: [ "//src/sys/fuzzing/common/meta/test.shard.cml" ],
+    include: [
+        "//sdk/lib/inspect/client.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
+        "syslog/client.shard.cml",
+    ],
     program: {
         binary: "test/component_fuzzing_framework_fatal_unittests",
     },
+    use: [
+        { protocol: "fuchsia.process.Launcher" },
+    ],
 }
diff --git a/src/sys/fuzzing/framework/meta/fuzzer-realm.cml b/src/sys/fuzzing/framework/meta/fuzzer-realm.cml
deleted file mode 100644
index a1cdd85..0000000
--- a/src/sys/fuzzing/framework/meta/fuzzer-realm.cml
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2022 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [ "//src/sys/fuzzing/framework/meta/realm.shard.cml" ],
-    children: [
-        {
-            name: "engine",
-            url: "#meta/integration-tests.cm",
-        },
-        {
-            name: "fuzzer",
-            url: "#meta/test-fuzzer.cm",
-        },
-        {
-            name: "coverage",
-            url: "#meta/coverage.cm",
-        },
-    ],
-    offer: [
-        {
-            protocol: [ "fuchsia.fuzzer.CoverageProvider" ],
-            from: "#coverage",
-            to: "#engine",
-        },
-        {
-            protocol: [ "fuchsia.fuzzer.Instrumentation" ],
-            from: "#coverage",
-            to: "#fuzzer",
-        },
-        {
-            protocol: [ "fuchsia.logger.LogSink" ],
-            from: "parent",
-            to: "#coverage",
-        },
-    ],
-}
diff --git a/src/sys/fuzzing/framework/meta/fuzzer-test-realm.cml b/src/sys/fuzzing/framework/meta/fuzzer-test-realm.cml
deleted file mode 100644
index eafd824..0000000
--- a/src/sys/fuzzing/framework/meta/fuzzer-test-realm.cml
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2022 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [ "//src/sys/fuzzing/framework/meta/realm.shard.cml" ],
-    children: [
-        {
-            name: "engine",
-            url: "#meta/test-engine.cm",
-        },
-        {
-            name: "fuzzer",
-            url: "#meta/test-fuzzer-uninstrumented.cm",
-        },
-    ],
-}
diff --git a/src/sys/fuzzing/framework/meta/integration-tests.cml b/src/sys/fuzzing/framework/meta/integration-tests.cml
deleted file mode 100644
index 3e8beb9..0000000
--- a/src/sys/fuzzing/framework/meta/integration-tests.cml
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2022 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [ "//src/sys/fuzzing/common/meta/test.shard.cml" ],
-    program: {
-        binary: "test/component_fuzzing_framework_tests",
-    },
-    use: [
-        { protocol: "fuchsia.fuzzer.TargetAdapter" },
-        { protocol: "fuchsia.fuzzer.CoverageProvider" },
-    ],
-}
diff --git a/src/sys/fuzzing/framework/meta/realm.shard.cml b/src/sys/fuzzing/framework/meta/realm.shard.cml
deleted file mode 100644
index 1b51abe..0000000
--- a/src/sys/fuzzing/framework/meta/realm.shard.cml
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2022 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    offer: [
-        {
-            runner: "gtest_runner",
-            from: "parent",
-            to: [ "#engine" ],
-        },
-        {
-            protocol: "fuchsia.process.Launcher",
-            from: "parent",
-            to: [
-                "#engine",
-                "#fuzzer",
-            ],
-        },
-        {
-            protocol: [ "fuchsia.fuzzer.TargetAdapter" ],
-            from: "#fuzzer",
-            to: "#engine",
-        },
-        {
-            protocol: [ "fuchsia.logger.LogSink" ],
-            from: "parent",
-            to: [
-                "#engine",
-                "#fuzzer",
-            ],
-        },
-    ],
-    expose: [
-        {
-            protocol: "fuchsia.test.Suite",
-            from: "#engine",
-        },
-    ],
-}
diff --git a/src/sys/fuzzing/framework/meta/test-engine.cml b/src/sys/fuzzing/framework/meta/test-engine.cml
deleted file mode 100644
index e69c299..0000000
--- a/src/sys/fuzzing/framework/meta/test-engine.cml
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright 2021 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [ "//src/sys/fuzzing/common/meta/test.shard.cml" ],
-    program: {
-        binary: "bin/component_fuzzing_test_engine",
-    },
-    use: [
-        { protocol: "fuchsia.fuzzer.TargetAdapter" },
-    ],
-}
diff --git a/src/sys/fuzzing/framework/meta/test-fuzzer-uninstrumented.cml b/src/sys/fuzzing/framework/meta/test-fuzzer-uninstrumented.cml
deleted file mode 100644
index 00aa46f..0000000
--- a/src/sys/fuzzing/framework/meta/test-fuzzer-uninstrumented.cml
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright 2022 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-{
-    include: [ "//src/sys/fuzzing/framework/meta/test-fuzzer.shard.cml" ],
-    program: {
-        binary: "bin/component_fuzzing_framework_test_fuzzer_uninstrumented",
-    },
-}
diff --git a/src/sys/fuzzing/framework/meta/unittests.cml b/src/sys/fuzzing/framework/meta/unittests.cml
index 87a8a42..ded3bd1 100644
--- a/src/sys/fuzzing/framework/meta/unittests.cml
+++ b/src/sys/fuzzing/framework/meta/unittests.cml
@@ -3,11 +3,16 @@
 // found in the LICENSE file.
 {
     include: [
-        "//src/sys/fuzzing/common/meta/test.shard.cml",
+        "//sdk/lib/inspect/client.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
         "//src/sys/test_runners/tmp_storage.shard.cml",
+        "syslog/client.shard.cml",
     ],
     program: {
         binary: "test/component_fuzzing_framework_unittests",
         args: [ "data/corpus" ],
     },
+    use: [
+        { protocol: "fuchsia.process.Launcher" },
+    ],
 }
diff --git a/src/sys/fuzzing/framework/testing/BUILD.gn b/src/sys/fuzzing/framework/testing/BUILD.gn
index 6dafa1e..81cf271 100644
--- a/src/sys/fuzzing/framework/testing/BUILD.gn
+++ b/src/sys/fuzzing/framework/testing/BUILD.gn
@@ -4,6 +4,7 @@
 
 import("//build/components/fuchsia_test_component.gni")
 
+# This source set contains various fakes used in framework unit tests.
 source_set("testing") {
   visibility = [ "../*" ]
   testonly = true
@@ -20,7 +21,6 @@
     "target.h",
   ]
   public_deps = [
-    "../coverage:coverage-lib",
     "../engine:engine-lib",
     "../target:no_hooks",
     "//src/sys/fuzzing/common",
@@ -31,6 +31,7 @@
   deps = [ "//sdk/lib/fdio" ]
 }
 
+# This executable is used for unit tests that manipulate processes.
 executable("test-target") {
   output_name = "component_fuzzing_framework_test_target"
   visibility = [ "//src/sys/fuzzing/*" ]
@@ -43,17 +44,24 @@
   ]
 }
 
-executable("engine") {
+# The test engine is used to drive the target adapter with fixed inputs from the seed corpus. This
+# is used to create fuzzer tests that can be run as part of CQ.
+executable("engine-bin") {
   output_name = "component_fuzzing_test_engine"
   testonly = true
   sources = [ "engine.cc" ]
   deps = [
-    "../engine:adapter-client",
     "//sdk/lib/fidl/cpp",
     "//sdk/lib/sys/cpp",
     "//src/lib/fxl/test:gtest_main",
     "//src/sys/fuzzing/common",
     "//src/sys/fuzzing/common/testing",
+    "//src/sys/fuzzing/framework/engine:adapter-client",
     "//third_party/googletest:gtest",
   ]
 }
+
+fuchsia_test_component("engine") {
+  manifest = "meta/engine.cml"
+  deps = [ ":engine-bin" ]
+}
diff --git a/src/sys/fuzzing/framework/testing/meta/engine.cml b/src/sys/fuzzing/framework/testing/meta/engine.cml
new file mode 100644
index 0000000..ff426d1
--- /dev/null
+++ b/src/sys/fuzzing/framework/testing/meta/engine.cml
@@ -0,0 +1,14 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This manifest corresponds to the "test" engine used in fuzzer tests.
+{
+    include: [
+        "//src/sys/fuzzing/framework/engine/default.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
+    ],
+    program: {
+        binary: "bin/component_fuzzing_test_engine",
+    },
+}
diff --git a/src/sys/fuzzing/framework/tests/BUILD.gn b/src/sys/fuzzing/framework/tests/BUILD.gn
index 4fbb4214..322e6a8 100644
--- a/src/sys/fuzzing/framework/tests/BUILD.gn
+++ b/src/sys/fuzzing/framework/tests/BUILD.gn
@@ -2,24 +2,22 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/components.gni")
+import("//build/dist/renamed_binary.gni")
 import("//build/test.gni")
 
-test("framework-integration-tests") {
-  output_name = "component_fuzzing_framework_tests"
-  sources = [ "framework-integration-test.cc" ]
+group("tests") {
+  testonly = true
   deps = [
-    "//sdk/lib/fdio",
-    "//sdk/lib/sys/cpp",
-    "//src/lib/fxl",
-    "//src/lib/fxl/test:gtest_main",
-    "//src/sys/fuzzing/common",
-    "//src/sys/fuzzing/common/testing",
-    "//src/sys/fuzzing/fidl:fuchsia.fuzzer",
-    "//third_party/googletest:gtest",
+    ":fuzzer-integration-tests-pkg",
+    ":fuzzer-test-integration-tests-pkg",
   ]
 }
 
-executable("fuzzer") {
+# This package contains integration tests that use the "real" fuzzing engine, which generates inputs
+# to drive a simple test fuzzer, to imitates a real fuzzer.
+
+executable("fuzzer-bin") {
   testonly = true
   output_name = "component_fuzzing_framework_test_fuzzer"
   sources = [ "fuzzer.cc" ]
@@ -31,10 +29,89 @@
   exclude_toolchain_tags = [ "instrumented" ]
 }
 
-executable("fuzzer-uninstrumented") {
+fuchsia_test_component("fuzzer") {
+  manifest = "meta/fuzzer.cml"
+  deps = [
+    ":fuzzer-bin",
+    "//src/sys/fuzzing/framework/testing/data:corpus",
+  ]
+}
+
+test("integration-test-bin") {
+  output_name = "component_fuzzing_framework_tests"
+  sources = [ "framework-integration-test.cc" ]
+  deps = [
+    "//sdk/lib/fdio",
+    "//sdk/lib/sys/cpp",
+    "//src/lib/fxl",
+    "//src/lib/fxl/test:gtest_main",
+    "//src/sys/fuzzing/common",
+    "//src/sys/fuzzing/common/testing",
+    "//src/sys/fuzzing/fidl:fuchsia.fuzzer",
+    "//src/sys/fuzzing/framework/engine:engine-lib",
+    "//third_party/googletest:gtest",
+  ]
+}
+
+fuchsia_test_component("engine") {
+  manifest = "meta/engine.cml"
+  deps = [
+    ":integration-test-bin",
+    "//src/sys/fuzzing/framework/engine:engine-bin",
+  ]
+}
+
+fuchsia_test_component("fuzzer-integration-tests") {
+  manifest = "meta/integration-tests.cml"
+  deps = [
+    ":engine",
+    ":fuzzer",
+    "//src/sys/fuzzing/framework/coverage",
+  ]
+}
+
+fuchsia_test_package("fuzzer-integration-tests-pkg") {
+  package_name = "component-fuzzer-integration-tests"
+  test_components = [ ":fuzzer-integration-tests" ]
+}
+
+# This package contains integration tests that use a test "engine", which uses fixed inputs to drive
+# a simple test fuzzer without instrumentation, to imitate the fuzzer tests that run in CQ.
+
+executable("fuzzer-uninstrumented-bin") {
   testonly = true
   output_name = "component_fuzzing_framework_test_fuzzer_uninstrumented"
   sources = [ "fuzzer.cc" ]
-  deps = [ "//src/sys/fuzzing/framework/adapters:llvm" ]
+  deps = [ "../adapters:llvm" ]
   exclude_toolchain_tags = [ "instrumented" ]
 }
+
+renamed_binary("fuzzer-uninstrumented-renamed") {
+  testonly = true
+  dest = "bin/component_fuzzing_framework_test_fuzzer"
+  source =
+      "$root_out_dir/component_fuzzing_framework_test_fuzzer_uninstrumented"
+  source_deps = [ ":fuzzer-uninstrumented-bin" ]
+}
+
+fuchsia_test_component("fuzzer-uninstrumented") {
+  component_name = "fuzzer"
+  manifest = "meta/fuzzer.cml"
+  deps = [
+    ":fuzzer-uninstrumented-renamed",
+    "//src/sys/fuzzing/framework/testing/data:corpus",
+  ]
+}
+
+fuchsia_test_component("fuzzer-test-integration-test") {
+  manifest = "../testing/meta/engine.cml"
+  deps = [
+    ":fuzzer-uninstrumented",
+    "//src/sys/fuzzing/framework/testing:engine",
+  ]
+}
+
+fuchsia_test_package("fuzzer-test-integration-tests-pkg") {
+  package_name = "component-fuzzer-test-integration-test"
+  test_components = [ ":fuzzer-test-integration-test" ]
+}
diff --git a/src/sys/fuzzing/framework/tests/meta/engine.cml b/src/sys/fuzzing/framework/tests/meta/engine.cml
new file mode 100644
index 0000000..355e529
--- /dev/null
+++ b/src/sys/fuzzing/framework/tests/meta/engine.cml
@@ -0,0 +1,25 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This manifest corresponds to the "real" engine used by the integration tests.
+{
+    include: [
+        "//src/sys/fuzzing/framework/engine/default.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
+    ],
+    program: {
+        binary: "test/component_fuzzing_framework_tests",
+    },
+    use: [
+        { protocol: "fuchsia.fuzzer.CoverageProvider" },
+        { protocol: "fuchsia.process.Launcher" },
+    ],
+    offer: [
+        {
+            protocol: "fuchsia.fuzzer.Instrumentation",
+            from: "parent",
+            to: "#fuzzer",
+        },
+    ],
+}
diff --git a/src/sys/fuzzing/framework/meta/test-fuzzer.cml b/src/sys/fuzzing/framework/tests/meta/fuzzer.cml
similarity index 61%
rename from src/sys/fuzzing/framework/meta/test-fuzzer.cml
rename to src/sys/fuzzing/framework/tests/meta/fuzzer.cml
index 6cf0fce..d84ebcb 100644
--- a/src/sys/fuzzing/framework/meta/test-fuzzer.cml
+++ b/src/sys/fuzzing/framework/tests/meta/fuzzer.cml
@@ -1,10 +1,14 @@
 // Copyright 2022 The Fuchsia Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
+// This manifest corresponds to the fuzzer used by the integration tests.
 {
-    include: [ "//src/sys/fuzzing/framework/meta/test-fuzzer.shard.cml" ],
+    include: [ "//src/sys/fuzzing/framework/adapters/llvm.shard.cml" ],
     program: {
+        runner: "elf",
         binary: "bin/component_fuzzing_framework_test_fuzzer",
+        args: [ "data/corpus" ],
     },
     use: [
         { protocol: "fuchsia.fuzzer.Instrumentation" },
diff --git a/src/sys/fuzzing/framework/tests/meta/integration-tests.cml b/src/sys/fuzzing/framework/tests/meta/integration-tests.cml
new file mode 100644
index 0000000..66b2191
--- /dev/null
+++ b/src/sys/fuzzing/framework/tests/meta/integration-tests.cml
@@ -0,0 +1,47 @@
+// Copyright 2022 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This manifest corresponds to the root of the realm used for the integration
+// tests.
+{
+    children: [
+        {
+            name: "coverage",
+            url: "#meta/coverage.cm",
+        },
+        {
+            name: "engine",
+            url: "#meta/engine.cm",
+        },
+    ],
+    offer: [
+        {
+            protocol: [
+                "fuchsia.fuzzer.CoverageProvider",
+                "fuchsia.fuzzer.Instrumentation",
+            ],
+            from: "#coverage",
+            to: "#engine",
+        },
+        {
+            protocol: "fuchsia.process.Launcher",
+            from: "parent",
+            to: "#engine",
+        },
+        {
+            protocol: "fuchsia.logger.LogSink",
+            from: "parent",
+            to: [
+                "#coverage",
+                "#engine",
+            ],
+        },
+    ],
+    expose: [
+        {
+            protocol: "fuchsia.test.Suite",
+            from: "#engine",
+        },
+    ],
+}
diff --git a/src/sys/fuzzing/libfuzzer/meta/error-unittests.cml b/src/sys/fuzzing/libfuzzer/meta/error-unittests.cml
index d51ca97..4b1db2e 100644
--- a/src/sys/fuzzing/libfuzzer/meta/error-unittests.cml
+++ b/src/sys/fuzzing/libfuzzer/meta/error-unittests.cml
@@ -3,10 +3,16 @@
 // found in the LICENSE file.
 {
     include: [
-        "//src/sys/fuzzing/common/meta/test.shard.cml",
+        "//sdk/lib/inspect/client.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
         "//src/sys/test_runners/tmp_storage.shard.cml",
+        "syslog/client.shard.cml",
     ],
     program: {
         binary: "test/component_fuzzing_libfuzzer_error_unittests",
     },
+    use: [
+        { protocol: "test.fuzzer.Relay" },
+        { protocol: "fuchsia.process.Launcher" },
+    ],
 }
diff --git a/src/sys/fuzzing/libfuzzer/meta/unittests.cml b/src/sys/fuzzing/libfuzzer/meta/unittests.cml
index 6f79128..17b14ba 100644
--- a/src/sys/fuzzing/libfuzzer/meta/unittests.cml
+++ b/src/sys/fuzzing/libfuzzer/meta/unittests.cml
@@ -3,13 +3,16 @@
 // found in the LICENSE file.
 {
     include: [
-        "//src/sys/fuzzing/common/meta/test.shard.cml",
+        "//sdk/lib/inspect/client.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
         "//src/sys/test_runners/tmp_storage.shard.cml",
+        "syslog/client.shard.cml",
     ],
     program: {
         binary: "test/component_fuzzing_libfuzzer_unittests",
     },
     use: [
         { protocol: "test.fuzzer.Relay" },
+        { protocol: "fuchsia.process.Launcher" },
     ],
 }
diff --git a/src/sys/fuzzing/registry/tests/meta/integration-tests.cml b/src/sys/fuzzing/registry/tests/meta/integration-tests.cml
index 653fe55..0f1c282 100644
--- a/src/sys/fuzzing/registry/tests/meta/integration-tests.cml
+++ b/src/sys/fuzzing/registry/tests/meta/integration-tests.cml
@@ -2,16 +2,17 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 {
-    include: [ "//src/sys/fuzzing/common/meta/test.shard.cml" ],
+    include: [
+        "//sdk/lib/inspect/client.shard.cml",
+        "//src/sys/test_runners/gtest/default.shard.cml",
+        "syslog/client.shard.cml",
+    ],
     program: {
         binary: "test/registry_integration_tests",
     },
     use: [
-        {
-            protocol: [
-                "fuchsia.fuzzer.Registrar",
-                "fuchsia.fuzzer.Registry",
-            ],
-        },
+        { protocol: "fuchsia.fuzzer.Registrar" },
+        { protocol: "fuchsia.fuzzer.Registry" },
+        { protocol: "fuchsia.process.Launcher" },
     ],
 }