[test_driver] Get EnvironmentController when creating environment

EnvironmentController is being made a required argument for
CreateNestedEnvironment in fxr/241175. This helps ensure that
Environments aren't abandoned unintenionally and never cleaned up,
especially in tests.

Test: Build & CQ (though the topaz_modular_integration_tests that use this
seem to be disabled at the moment)

Change-Id: I17b5c155ccc863a0ec3b34b516a5f763af2b7ce2
diff --git a/bin/test_driver/BUILD.gn b/bin/test_driver/BUILD.gn
index 6b88de8..9e048f5 100644
--- a/bin/test_driver/BUILD.gn
+++ b/bin/test_driver/BUILD.gn
@@ -11,7 +11,6 @@
     "test_driver_module.cc",
   ]
   deps = [
-    ":defs",
     "//garnet/public/fidl/fuchsia.testing.runner",
     "//garnet/public/fidl/fuchsia.ui.viewsv1",
     "//garnet/public/lib/fidl/cpp",
@@ -31,11 +30,3 @@
     },
   ]
 }
-
-source_set("defs") {
-  testonly = true
-
-  sources = [
-    "defs.h",
-  ]
-}
diff --git a/bin/test_driver/defs.h b/bin/test_driver/defs.h
deleted file mode 100644
index 01b0136..0000000
--- a/bin/test_driver/defs.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2018 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.
-
-#ifndef PERIDOT_BIN_TEST_DRIVER_DEFS_H_
-#define PERIDOT_BIN_TEST_DRIVER_DEFS_H_
-
-namespace {
-
-// The name of the test driver's child module.
-constexpr char kSubModuleName[] = "test_driver_sub_module";
-
-}  // namespace
-
-#endif  // PERIDOT_BIN_TEST_DRIVER_DEFS_H_
diff --git a/bin/test_driver/test_driver_module.cc b/bin/test_driver/test_driver_module.cc
index 2d60487..26d1644 100644
--- a/bin/test_driver/test_driver_module.cc
+++ b/bin/test_driver/test_driver_module.cc
@@ -11,7 +11,6 @@
 #include <lib/fdio/util.h>
 #include <lib/fsl/vmo/strings.h>
 
-#include "peridot/bin/test_driver/defs.h"
 #include "peridot/lib/rapidjson/rapidjson.h"
 #include "peridot/lib/testing/test_driver.h"
 #include "peridot/public/lib/integration_testing/cpp/reporting.h"
@@ -22,6 +21,11 @@
 
 namespace {
 
+// The name of the test driver's environment.
+constexpr char kEnvironmentName[] = "test_driver_env";
+// The name of the test driver's child module.
+constexpr char kSubModuleName[] = "test_driver_sub_module";
+
 // Cf. README.md for what this test does and how.
 class TestModule {
  public:
@@ -92,7 +96,8 @@
 
   bool CreateNestedEnv() {
     module_host_->startup_context()->environment()->CreateNestedEnvironment(
-        test_driver_env_.NewRequest(), /*controller=*/nullptr, kSubModuleName,
+        test_driver_env_.NewRequest(), test_driver_env_controller_.NewRequest(),
+        kEnvironmentName,
         /*additional_services=*/nullptr, {.inherit_parent_services = true});
     return true;
   }
@@ -152,6 +157,7 @@
   component::Services test_driver_services_;
   fuchsia::modular::LinkPtr link_;
   fuchsia::sys::EnvironmentPtr test_driver_env_;
+  fuchsia::sys::EnvironmentControllerPtr test_driver_env_controller_;
   fuchsia::sys::LauncherPtr test_driver_launcher_;
   fuchsia::sys::ComponentControllerPtr test_driver_component_controller_;