diff --git a/garnet/bin/appmgr/component_controller_unittest.cc b/garnet/bin/appmgr/component_controller_unittest.cc index 526acb40ed2c259a9754e10e5f44925b2c03c352..3dd7370786edde381c3fe497a317d7e464489832 100644 --- a/garnet/bin/appmgr/component_controller_unittest.cc +++ b/garnet/bin/appmgr/component_controller_unittest.cc @@ -320,7 +320,7 @@ TEST_F(ComponentControllerTest, CreateAndKill) { wait = true; }; component_ptr->Kill(); - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); // make sure all messages are processed after wait was called RunLoopUntilIdle(); @@ -345,7 +345,7 @@ TEST_F(ComponentControllerTest, CreateAndDeleteWithoutKilling) { }; realm_.ExtractComponent(component_to_remove); - EXPECT_TRUE(RunLoopUntil([&return_code] { return return_code; })); + RunLoopUntil([&return_code] { return return_code; }); // make sure all messages are processed after wait was called RunLoopUntilIdle(); @@ -362,7 +362,7 @@ TEST_F(ComponentControllerTest, ControllerScope) { ASSERT_EQ(realm_.ComponentCount(), 1u); } - EXPECT_TRUE(RunLoopUntil([this]() { return realm_.ComponentCount() == 0; })); + RunLoopUntil([this]() { return realm_.ComponentCount() == 0; }); } TEST_F(ComponentControllerTest, DetachController) { @@ -478,7 +478,7 @@ TEST_F(ComponentBridgeTest, CreateAndKill) { SendReady(); SetReturnCode(expected_retval); component_ptr->Kill(); - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); EXPECT_TRUE(ready); EXPECT_EQ(expected_retval, retval); EXPECT_EQ(TerminationReason::EXITED, termination_reason); @@ -507,7 +507,7 @@ TEST_F(ComponentBridgeTest, CreateAndDeleteWithoutKilling) { // Component controller called OnTerminated before the component is destroyed, // so we expect the value set above (INTERNAL_ERROR). runner_.ExtractComponent(component_to_remove); - EXPECT_TRUE(RunLoopUntil([&terminated] { return terminated; })); + RunLoopUntil([&terminated] { return terminated; }); EXPECT_EQ(-1, retval); EXPECT_EQ(TerminationReason::INTERNAL_ERROR, termination_reason); @@ -534,7 +534,7 @@ TEST_F(ComponentBridgeTest, RemoteComponentDied) { // Even though the termination reason was set above, unbinding and closing the // channel will cause the bridge to return UNKNOWN>. binding_.Unbind(); - EXPECT_TRUE(RunLoopUntil([&terminated] { return terminated; })); + RunLoopUntil([&terminated] { return terminated; }); EXPECT_EQ(-1, retval); EXPECT_EQ(TerminationReason::UNKNOWN, termination_reason); EXPECT_EQ(0u, runner_.ComponentCount()); @@ -556,7 +556,7 @@ TEST_F(ComponentBridgeTest, ControllerScope) { runner_.AddComponent(std::move(component)); ASSERT_EQ(runner_.ComponentCount(), 1u); } - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); // make sure all messages are processed after wait was called RunLoopUntilIdle(); @@ -592,7 +592,7 @@ TEST_F(ComponentBridgeTest, DetachController) { wait = true; }); component_bridge_ptr->Kill(); - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); // make sure all messages are processed after wait was called RunLoopUntilIdle(); @@ -655,7 +655,7 @@ TEST_F(ComponentBridgeTest, BindingErrorHandler) { auto component = CreateComponentBridge(component_ptr, std::move(export_dir_req)); } - EXPECT_TRUE(RunLoopUntil([this] { return !binding_.is_bound(); })); + RunLoopUntil([this] { return !binding_.is_bound(); }); EXPECT_TRUE(binding_error_handler_called_); } @@ -671,7 +671,7 @@ TEST_F(ComponentBridgeTest, BindingErrorHandlerWhenDetached) { component_ptr->Detach(); RunLoopUntilIdle(); } - EXPECT_TRUE(RunLoopUntil([this] { return !binding_.is_bound(); })); + RunLoopUntil([this] { return !binding_.is_bound(); }); EXPECT_TRUE(binding_error_handler_called_); } diff --git a/garnet/bin/appmgr/integration_tests/components/components_binary_test.cc b/garnet/bin/appmgr/integration_tests/components/components_binary_test.cc index 029b745c15d57080c9682660046a15fcdf4821f6..c479cf66d40c80ab756a6bf9969326c837d60c93 100644 --- a/garnet/bin/appmgr/integration_tests/components/components_binary_test.cc +++ b/garnet/bin/appmgr/integration_tests/components/components_binary_test.cc @@ -61,8 +61,7 @@ class ComponentsBinaryTest : public sys::testing::TestWithEnvironment { [&return_code](int64_t code, fuchsia::sys::TerminationReason reason) { return_code = code; }; - ASSERT_TRUE( - RunLoopUntil([&return_code] { return return_code != INT64_MIN; })); + RunLoopUntil([&return_code] { return return_code != INT64_MIN; }); EXPECT_EQ(0, return_code); } diff --git a/garnet/bin/appmgr/integration_tests/hub_integration_test.cc b/garnet/bin/appmgr/integration_tests/hub_integration_test.cc index 50b0586beb3bee53906b0858a76c48549e7dc800..1a97f7ddaced5a4b0f890d8321a750d0b5fac627 100644 --- a/garnet/bin/appmgr/integration_tests/hub_integration_test.cc +++ b/garnet/bin/appmgr/integration_tests/hub_integration_test.cc @@ -4,11 +4,11 @@ #include <fuchsia/sys/cpp/fidl.h> #include <lib/async/default.h> +#include <lib/sys/cpp/file_descriptor.h> +#include <lib/sys/cpp/testing/test_with_environment.h> #include <src/lib/fxl/strings/concatenate.h> #include <src/lib/fxl/strings/join_strings.h> #include <src/lib/fxl/strings/string_printf.h> -#include <lib/sys/cpp/file_descriptor.h> -#include <lib/sys/cpp/testing/test_with_environment.h> #include "garnet/bin/sysmgr/config.h" #include "gmock/gmock.h" @@ -48,8 +48,7 @@ class HubTest : public sys::testing::TestWithEnvironment { [&return_code](int64_t code, fuchsia::sys::TerminationReason reason) { return_code = code; }; - ASSERT_TRUE( - RunLoopUntil([&return_code] { return return_code != INT64_MIN; })); + RunLoopUntil([&return_code] { return return_code != INT64_MIN; }); std::string output; ASSERT_TRUE(files::ReadFileDescriptorToString(out_fd, &output)); EXPECT_EQ(expected_return_code, return_code) @@ -128,7 +127,7 @@ TEST_F(HubTest, ScopePolicy) { // test that we can see nested env auto nested_env = CreateNewEnclosingEnvironment("hubscopepolicytest", CreateServices()); - ASSERT_TRUE(WaitForEnclosingEnvToStart(nested_env.get())); + WaitForEnclosingEnvToStart(nested_env.get()); RunComponent(launcher_ptr(), kGlobUrl, {"/hub/r/hubscopepolicytest/"}, 0); // test that we cannot see nested env using its own launcher @@ -144,7 +143,7 @@ TEST_F(HubTest, SystemObjects) { auto nested_env = CreateNewEnclosingEnvironment("hubscopepolicytest", CreateServices()); - ASSERT_TRUE(WaitForEnclosingEnvToStart(nested_env.get())); + WaitForEnclosingEnvToStart(nested_env.get()); RunComponent(launcher_ptr(), glob_url, {"/hub/r/hubscopepolicytest/"}, 0); // test that we can see system objects diff --git a/garnet/bin/appmgr/integration_tests/inspect/test-vmo.cc b/garnet/bin/appmgr/integration_tests/inspect/test-vmo.cc index 76e1f3d6c925853396f34a121f9b8caeb81fc2fb..d6011a59e537d51c2c0b050d9946318e1525cd34 100644 --- a/garnet/bin/appmgr/integration_tests/inspect/test-vmo.cc +++ b/garnet/bin/appmgr/integration_tests/inspect/test-vmo.cc @@ -57,7 +57,7 @@ class InspectTest : public sys::testing::TestWithEnvironment { ASSERT_EQ(fuchsia::sys::TerminationReason::EXITED, reason); done = true; }; - ASSERT_TRUE(RunLoopUntil([&done] { return done; })); + RunLoopUntil([&done] { return done; }); } // Open the root object connection on the given sync pointer. diff --git a/garnet/bin/appmgr/integration_tests/inspect/test.cc b/garnet/bin/appmgr/integration_tests/inspect/test.cc index 3f317ce16615b810c8d31760038b7917c152c36c..dd92fb5f4ade6576dfa6089717ca8bd9b393a2ed 100644 --- a/garnet/bin/appmgr/integration_tests/inspect/test.cc +++ b/garnet/bin/appmgr/integration_tests/inspect/test.cc @@ -52,7 +52,7 @@ class InspectTest : public sys::testing::TestWithEnvironment { ASSERT_EQ(fuchsia::sys::TerminationReason::EXITED, reason); done = true; }; - ASSERT_TRUE(RunLoopUntil([&done] { return done; })); + RunLoopUntil([&done] { return done; }); } // Open the root object connection on the given sync pointer. diff --git a/garnet/bin/appmgr/integration_tests/realm_integration_test.cc b/garnet/bin/appmgr/integration_tests/realm_integration_test.cc index ccae7919d1ed74c58bf600128ecb338df26149b8..14ae46718bd701182bb67daae4284d70a7f51685 100644 --- a/garnet/bin/appmgr/integration_tests/realm_integration_test.cc +++ b/garnet/bin/appmgr/integration_tests/realm_integration_test.cc @@ -137,14 +137,14 @@ TEST_F(RealmTest, Resolve) { ASSERT_EQ(expect, actual); }); - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); } TEST_F(RealmTest, LaunchNonExistentComponent) { auto env_services = CreateServices(); auto enclosing_environment = CreateNewEnclosingEnvironment(kRealm, std::move(env_services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_environment.get())); + WaitForEnclosingEnvToStart(enclosing_environment.get()); // try to launch file url. auto controller1 = @@ -155,7 +155,7 @@ TEST_F(RealmTest, LaunchNonExistentComponent) { wait = true; EXPECT_EQ(reason, fuchsia::sys::TerminationReason::PACKAGE_NOT_FOUND); }; - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); // try to launch pkg url. auto controller2 = @@ -167,7 +167,7 @@ TEST_F(RealmTest, LaunchNonExistentComponent) { wait = true; EXPECT_EQ(reason, fuchsia::sys::TerminationReason::PACKAGE_NOT_FOUND); }; - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); } // This test exercises the fact that two components should be in separate jobs, @@ -183,7 +183,7 @@ TEST_F(RealmTest, CreateTwoKillOne) { fidl::examples::echo::Echo::Name_)); auto enclosing_environment = CreateNewEnclosingEnvironment(kRealm, std::move(env_services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_environment.get())); + WaitForEnclosingEnvToStart(enclosing_environment.get()); // launch component normally auto controller1 = RunComponent( enclosing_environment.get(), @@ -196,7 +196,7 @@ TEST_F(RealmTest, CreateTwoKillOne) { fidl::StringPtr ret_msg = ""; echo->EchoString(message, [&](::fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); // Kill one of the two components, make sure it's exited via Wait bool wait = false; @@ -205,13 +205,13 @@ TEST_F(RealmTest, CreateTwoKillOne) { wait = true; }; controller1->Kill(); - EXPECT_TRUE(RunLoopUntil([&wait] { return wait; })); + RunLoopUntil([&wait] { return wait; }); // Make sure the second component is still running. ret_msg = ""; echo->EchoString(message, [&](::fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); } TEST_F(RealmTest, KillRealmKillsComponent) { @@ -223,7 +223,7 @@ TEST_F(RealmTest, KillRealmKillsComponent) { fidl::examples::echo::Echo::Name_)); auto enclosing_environment = CreateNewEnclosingEnvironment(kRealm, std::move(env_services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_environment.get())); + WaitForEnclosingEnvToStart(enclosing_environment.get()); // make sure echo service is running. fidl::examples::echo::EchoPtr echo; @@ -232,17 +232,16 @@ TEST_F(RealmTest, KillRealmKillsComponent) { fidl::StringPtr ret_msg = ""; echo->EchoString(message, [&](::fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); bool killed = false; echo.set_error_handler([&](zx_status_t status) { killed = true; }); enclosing_environment->Kill(); - EXPECT_TRUE( - RunLoopUntil([&] { return enclosing_environment->is_running(); })); + RunLoopUntil([&] { return enclosing_environment->is_running(); }); // send a msg, without that error handler won't be called. echo->EchoString(message, [&](::fidl::StringPtr retval) { ret_msg = retval; }); - EXPECT_TRUE(RunLoopUntil([&] { return killed; })); + RunLoopUntil([&] { return killed; }); } TEST_F(RealmTest, EnvironmentControllerRequired) { @@ -254,7 +253,7 @@ TEST_F(RealmTest, EnvironmentControllerRequired) { zx_status_t env_status = ZX_OK; env.set_error_handler([&](zx_status_t status) { env_status = status; }); - EXPECT_TRUE(RunLoopUntil([&] { return env_status != ZX_OK; })); + RunLoopUntil([&] { return env_status != ZX_OK; }); } TEST_F(RealmTest, EnvironmentLabelMustBeUnique) { @@ -279,9 +278,8 @@ TEST_F(RealmTest, EnvironmentLabelMustBeUnique) { env.NewRequest(), env_controller.NewRequest(), kRealm, nullptr, fuchsia::sys::EnvironmentOptions{}); - EXPECT_TRUE(RunLoopUntil([&] { return env_status == ZX_ERR_BAD_STATE; })); - EXPECT_TRUE( - RunLoopUntil([&] { return env_controller_status == ZX_ERR_BAD_STATE; })); + RunLoopUntil([&] { return env_status == ZX_ERR_BAD_STATE; }); + RunLoopUntil([&] { return env_controller_status == ZX_ERR_BAD_STATE; }); } TEST_F(RealmTest, RealmJobProvider) { @@ -318,7 +316,7 @@ TEST_F(RealmTest, RealmDiesWhenItsJobDies) { fidl::examples::echo::Echo::Name_)); auto enclosing_environment = CreateNewEnclosingEnvironment(kRealm, std::move(env_services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_environment.get())); + WaitForEnclosingEnvToStart(enclosing_environment.get()); // make sure echo service is running. fidl::examples::echo::EchoPtr echo; @@ -327,7 +325,7 @@ TEST_F(RealmTest, RealmDiesWhenItsJobDies) { fidl::StringPtr ret_msg = ""; echo->EchoString(message, [&](::fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); fuchsia::sys::JobProviderSyncPtr ptr; files::Glob glob(std::string("/hub/r/") + kRealm + "/*/job"); @@ -339,8 +337,7 @@ TEST_F(RealmTest, RealmDiesWhenItsJobDies) { EXPECT_EQ(ZX_OK, ptr->GetJob(&job)); ASSERT_EQ(ZX_OK, job.kill()); - EXPECT_TRUE( - RunLoopUntil([&] { return !enclosing_environment->is_running(); })); + RunLoopUntil([&] { return !enclosing_environment->is_running(); }); } TEST_F(RealmTest, EmptyRealmDiesWhenItsJobDies) { @@ -348,7 +345,7 @@ TEST_F(RealmTest, EmptyRealmDiesWhenItsJobDies) { auto enclosing_environment = CreateNewEnclosingEnvironment(kRealm, std::move(env_services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_environment.get())); + WaitForEnclosingEnvToStart(enclosing_environment.get()); fuchsia::sys::JobProviderSyncPtr ptr; files::Glob glob(std::string("/hub/r/") + kRealm + "/*/job"); @@ -360,8 +357,7 @@ TEST_F(RealmTest, EmptyRealmDiesWhenItsJobDies) { EXPECT_EQ(ZX_OK, ptr->GetJob(&job)); ASSERT_EQ(ZX_OK, job.kill()); - EXPECT_TRUE( - RunLoopUntil([&] { return !enclosing_environment->is_running(); })); + RunLoopUntil([&] { return !enclosing_environment->is_running(); }); } TEST_F(RealmTest, KillWorks) { @@ -369,7 +365,7 @@ TEST_F(RealmTest, KillWorks) { auto enclosing_environment = CreateNewEnclosingEnvironment(kRealm, std::move(env_services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_environment.get())); + WaitForEnclosingEnvToStart(enclosing_environment.get()); std::string hub_path = std::string("/hub/r/") + kRealm; // make sure realm was created @@ -378,7 +374,7 @@ TEST_F(RealmTest, KillWorks) { bool killed = false; enclosing_environment->Kill([&] { killed = true; }); - ASSERT_TRUE(RunLoopUntil([&] { return killed; })); + RunLoopUntil([&] { return killed; }); // make sure realm was really killed files::Glob glob2(hub_path); @@ -415,7 +411,7 @@ TEST_F(EnvironmentOptionsTest, DeleteStorageOnDeath) { // storage it owns. bool killed = false; enclosing_environment->Kill([&] { killed = true; }); - ASSERT_TRUE(RunLoopUntil([&] { return killed; })); + RunLoopUntil([&] { return killed; }); // Recreate the environment and component using the same environment label. services = sys::ServiceDirectory::CreateWithRequest(&request); @@ -457,12 +453,10 @@ TEST_P(EnvironmentLabelTest, CheckLabelValidity) { /* additional_services = */ nullptr, fuchsia::sys::EnvironmentOptions{}); if (label_valid) { - EXPECT_TRUE(RunLoopUntil([&] { return env_created; })); + RunLoopUntil([&] { return env_created; }); } else { - EXPECT_TRUE( - RunLoopUntil([&] { return env_status == ZX_ERR_INVALID_ARGS; })); - EXPECT_TRUE(RunLoopUntil( - [&] { return env_controller_status == ZX_ERR_INVALID_ARGS; })); + RunLoopUntil([&] { return env_status == ZX_ERR_INVALID_ARGS; }); + RunLoopUntil([&] { return env_controller_status == ZX_ERR_INVALID_ARGS; }); EXPECT_FALSE(env_created); } } @@ -506,8 +500,8 @@ class RealmFakeLoaderTest : public RealmTest, public fuchsia::sys::Loader { component_url_ = url; } - bool WaitForComponentLoad() { - return RunLoopUntil([this] { return !component_url_.empty(); }); + void WaitForComponentLoad() { + RunLoopUntil([this] { return !component_url_.empty(); }); } const std::string& component_url() const { return component_url_; } @@ -522,28 +516,28 @@ class RealmFakeLoaderTest : public RealmTest, public fuchsia::sys::Loader { TEST_F(RealmFakeLoaderTest, CreateWebComponent_HTTP) { RunComponent(enclosing_environment_.get(), "http://example.com"); - ASSERT_TRUE(WaitForComponentLoad()); + WaitForComponentLoad(); EXPECT_THAT(component_url(), Eq("fuchsia-pkg://fuchsia.com/web_runner#meta/web_runner.cmx")); } TEST_F(RealmFakeLoaderTest, CreateWebComponent_HTTPS) { RunComponent(enclosing_environment_.get(), "https://example.com"); - ASSERT_TRUE(WaitForComponentLoad()); + WaitForComponentLoad(); EXPECT_THAT(component_url(), Eq("fuchsia-pkg://fuchsia.com/web_runner#meta/web_runner.cmx")); } TEST_F(RealmFakeLoaderTest, CreateCastComponent_CAST) { RunComponent(enclosing_environment_.get(), "cast://a12345/"); - ASSERT_TRUE(WaitForComponentLoad()); + WaitForComponentLoad(); EXPECT_EQ("fuchsia-pkg://fuchsia.com/cast_runner#meta/cast_runner.cmx", component_url()); } TEST_F(RealmFakeLoaderTest, CreateCastComponent_CASTS) { RunComponent(enclosing_environment_.get(), "casts://a12345/"); - ASSERT_TRUE(WaitForComponentLoad()); + WaitForComponentLoad(); EXPECT_EQ("fuchsia-pkg://fuchsia.com/cast_runner#meta/cast_runner.cmx", component_url()); } @@ -557,7 +551,7 @@ TEST_F(RealmFakeLoaderTest, CreateInvalidComponent) { return_code = err; reason = r; }; - ASSERT_TRUE(RunLoopUntil([&] { return return_code < INT64_MAX; })); + RunLoopUntil([&] { return return_code < INT64_MAX; }); EXPECT_EQ(TerminationReason::URL_INVALID, reason); EXPECT_EQ(-1, return_code); } diff --git a/garnet/bin/appmgr/integration_tests/realm_runner_integration_test.cc b/garnet/bin/appmgr/integration_tests/realm_runner_integration_test.cc index 3857bd25a27b7a53fa397107674bea1487af32e8..89446f99285ecd11d21df7baad71eabeac49a290 100644 --- a/garnet/bin/appmgr/integration_tests/realm_runner_integration_test.cc +++ b/garnet/bin/appmgr/integration_tests/realm_runner_integration_test.cc @@ -43,7 +43,7 @@ class RealmRunnerTest : public TestWithEnvironment { ASSERT_EQ(ZX_OK, services->AddService(runner_registry_.GetHandler())); enclosing_environment_ = CreateNewEnclosingEnvironment(kRealm, std::move(services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_environment_.get())); + WaitForEnclosingEnvToStart(enclosing_environment_.get()); } std::pair<std::unique_ptr<EnclosingEnvironment>, @@ -57,18 +57,15 @@ class RealmRunnerTest : public TestWithEnvironment { EXPECT_EQ(ZX_OK, services->AddService(registry->GetHandler())); auto nested_environment = EnclosingEnvironment::Create( "nested-environment", env, std::move(services), std::move(options)); - EXPECT_TRUE(WaitForEnclosingEnvToStart(nested_environment.get())); + WaitForEnclosingEnvToStart(nested_environment.get()); return std::make_pair(std::move(nested_environment), std::move(registry)); } - bool WaitForRunnerToRegister(MockRunnerRegistry* runner_registry = nullptr) { + void WaitForRunnerToRegister(MockRunnerRegistry* runner_registry = nullptr) { if (!runner_registry) { runner_registry = &runner_registry_; } - const bool ret = RunLoopUntil([&] { return runner_registry->runner(); }); - EXPECT_TRUE(ret) << "Waiting for connection timed out: " - << runner_registry->connect_count(); - return ret; + RunLoopUntil([&] { return runner_registry->runner(); }); } fuchsia::sys::LaunchInfo CreateLaunchInfo(const std::string& url) { @@ -77,27 +74,20 @@ class RealmRunnerTest : public TestWithEnvironment { return launch_info; } - bool WaitForRunnerToDie() { - const bool ret = RunLoopUntil([&] { return !runner_registry_.runner(); }); - EXPECT_TRUE(ret) << "Waiting for connection timed out: " - << runner_registry_.dead_runner_count(); - return ret; + void WaitForRunnerToDie() { + RunLoopUntil([&] { return !runner_registry_.runner(); }); } - bool WaitForComponentCount(size_t expected_components_count) { + void WaitForComponentCount(size_t expected_components_count) { return WaitForComponentCount(&runner_registry_, expected_components_count); } - bool WaitForComponentCount(MockRunnerRegistry* runner_registry, + void WaitForComponentCount(MockRunnerRegistry* runner_registry, size_t expected_components_count) { auto runner = runner_registry->runner(); - const bool ret = RunLoopUntil([&] { + RunLoopUntil([&] { return runner->components().size() == expected_components_count; }); - EXPECT_TRUE(ret) << "Waiting for component to start/die timed out, got:" - << runner->components().size() - << ", expected: " << expected_components_count; - return ret; } std::unique_ptr<EnclosingEnvironment> enclosing_environment_; @@ -107,8 +97,8 @@ class RealmRunnerTest : public TestWithEnvironment { TEST_F(RealmRunnerTest, RunnerLaunched) { auto component = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); - ASSERT_TRUE(WaitForComponentCount(1)); + WaitForRunnerToRegister(); + WaitForComponentCount(1); auto components = runner_registry_.runner()->components(); ASSERT_EQ(components[0].url, kComponentForRunner); } @@ -116,7 +106,7 @@ TEST_F(RealmRunnerTest, RunnerLaunched) { TEST_F(RealmRunnerTest, RunnerLaunchedOnlyOnce) { auto component1 = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); // launch again and check that runner was not executed again auto component2 = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); @@ -128,7 +118,7 @@ TEST_F(RealmRunnerTest, RunnerLaunchedOnlyOnce) { TEST_F(RealmRunnerTest, RunnerLaunchedAgainWhenKilled) { auto component = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); auto glob_str = fxl::StringPrintf("/hub/r/%s/*/c/appmgr_mock_runner.cmx/*", kRealm); @@ -140,24 +130,24 @@ TEST_F(RealmRunnerTest, RunnerLaunchedAgainWhenKilled) { component.events().OnTerminated = [&](int64_t code, TerminationReason reason) { return_code = code; }; runner_registry_.runner()->runner_ptr()->Crash(); - ASSERT_TRUE(WaitForRunnerToDie()); + WaitForRunnerToDie(); // Make sure component is dead. - ASSERT_TRUE(RunLoopUntil([&] { return return_code != INT64_MIN; })); + RunLoopUntil([&] { return return_code != INT64_MIN; }); // Make sure we no longer have runner in hub. This will make sure that appmgr // knows that runner died, before we try to launch component again. - ASSERT_TRUE(RunLoopUntil([runner_path = runner_path_in_hub.c_str()] { + RunLoopUntil([runner_path = runner_path_in_hub.c_str()] { struct stat s; return stat(runner_path, &s) != 0; - })); + }); // launch again and check that runner was executed again component = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); ASSERT_EQ(2, runner_registry_.connect_count()); // make sure component was also launched - ASSERT_TRUE(WaitForComponentCount(1)); + WaitForComponentCount(1); auto components = runner_registry_.runner()->components(); ASSERT_EQ(components[0].url, kComponentForRunner); } @@ -165,7 +155,7 @@ TEST_F(RealmRunnerTest, RunnerLaunchedAgainWhenKilled) { TEST_F(RealmRunnerTest, RunnerLaunchedForEachEnvironment) { auto component1 = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); std::unique_ptr<EnclosingEnvironment> nested_environment; std::unique_ptr<MockRunnerRegistry> nested_registry; @@ -176,8 +166,8 @@ TEST_F(RealmRunnerTest, RunnerLaunchedForEachEnvironment) { nested_environment->CreateComponentFromUrl(kComponentForRunner); WaitForRunnerToRegister(nested_registry.get()); - ASSERT_TRUE(WaitForComponentCount(&runner_registry_, 1)); - ASSERT_TRUE(WaitForComponentCount(nested_registry.get(), 1)); + WaitForComponentCount(&runner_registry_, 1); + WaitForComponentCount(nested_registry.get(), 1); EXPECT_EQ(1, runner_registry_.connect_count()); EXPECT_EQ(1, nested_registry->connect_count()); } @@ -185,7 +175,7 @@ TEST_F(RealmRunnerTest, RunnerLaunchedForEachEnvironment) { TEST_F(RealmRunnerTest, RunnerSharedFromParent) { auto component1 = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); std::unique_ptr<EnclosingEnvironment> nested_environment; std::unique_ptr<MockRunnerRegistry> nested_registry; @@ -199,7 +189,7 @@ TEST_F(RealmRunnerTest, RunnerSharedFromParent) { auto component2 = nested_environment->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForComponentCount(&runner_registry_, 2)); + WaitForComponentCount(&runner_registry_, 2); EXPECT_EQ(1, runner_registry_.connect_count()); EXPECT_EQ(0, nested_registry->connect_count()); } @@ -207,9 +197,9 @@ TEST_F(RealmRunnerTest, RunnerSharedFromParent) { TEST_F(RealmRunnerTest, ComponentBridgeReturnsRightReturnCode) { auto component = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); // make sure component was launched - ASSERT_TRUE(WaitForComponentCount(1)); + WaitForComponentCount(1); int64_t return_code; TerminationReason reason; component.events().OnTerminated = [&](int64_t code, TerminationReason r) { @@ -222,9 +212,8 @@ TEST_F(RealmRunnerTest, ComponentBridgeReturnsRightReturnCode) { runner_registry_.runner()->runner_ptr()->ConnectToComponent( components[0].unique_id, component_ptr.NewRequest()); component_ptr->Kill(ret_code); - ASSERT_TRUE(WaitForComponentCount(0)); - EXPECT_TRUE( - RunLoopUntil([&] { return reason == TerminationReason::EXITED; })); + WaitForComponentCount(0); + RunLoopUntil([&] { return reason == TerminationReason::EXITED; }); EXPECT_EQ(return_code, ret_code); } @@ -232,28 +221,27 @@ TEST_F(RealmRunnerTest, DestroyingControllerKillsComponent) { { auto component = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); // make sure component was launched - ASSERT_TRUE(WaitForComponentCount(1)); + WaitForComponentCount(1); // component will go out of scope } - ASSERT_TRUE(WaitForComponentCount(0)); + WaitForComponentCount(0); } TEST_F(RealmRunnerTest, KillComponentController) { auto component = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); // make sure component was launched - ASSERT_TRUE(WaitForComponentCount(1)); + WaitForComponentCount(1); TerminationReason reason; component.events().OnTerminated = [&](int64_t code, TerminationReason r) { reason = r; }; component->Kill(); - ASSERT_TRUE(WaitForComponentCount(0)); - EXPECT_TRUE( - RunLoopUntil([&] { return reason == TerminationReason::EXITED; })); + WaitForComponentCount(0); + RunLoopUntil([&] { return reason == TerminationReason::EXITED; }); } class RealmRunnerServiceTest : public RealmRunnerTest { @@ -275,9 +263,9 @@ class RealmRunnerServiceTest : public RealmRunnerTest { TEST_F(RealmRunnerServiceTest, ComponentCanConnectToEnvService) { auto component = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); // make sure component was launched - ASSERT_TRUE(WaitForComponentCount(1)); + WaitForComponentCount(1); fidl::examples::echo::EchoPtr echo; MockComponentPtr component_ptr; @@ -290,7 +278,7 @@ TEST_F(RealmRunnerServiceTest, ComponentCanConnectToEnvService) { fidl::StringPtr ret_msg = ""; echo->EchoString(message, [&](::fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return ret_msg.get() == message; })); + RunLoopUntil([&] { return ret_msg.get() == message; }); } TEST_F(RealmRunnerTest, ComponentCanPublishServices) { @@ -304,9 +292,9 @@ TEST_F(RealmRunnerTest, ComponentCanPublishServices) { auto component = enclosing_environment_->CreateComponent(std::move(launch_info)); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); // make sure component was launched - ASSERT_TRUE(WaitForComponentCount(1)); + WaitForComponentCount(1); // create and publish fake service vfs::PseudoDir fake_service_dir; @@ -332,7 +320,7 @@ TEST_F(RealmRunnerTest, ComponentCanPublishServices) { // try to connect to fake service fidl::examples::echo::EchoPtr echo; services->Connect(echo.NewRequest(), dummy_service_name); - ASSERT_TRUE(RunLoopUntil([&] { return connect_called; })); + RunLoopUntil([&] { return connect_called; }); } TEST_F(RealmRunnerTest, ProbeHub) { @@ -344,7 +332,7 @@ TEST_F(RealmRunnerTest, ProbeHub) { enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); auto component2 = enclosing_environment_->CreateComponentFromUrl(kComponentForRunner); - ASSERT_TRUE(WaitForRunnerToRegister()); + WaitForRunnerToRegister(); WaitForComponentCount(2); files::Glob glob(glob_str); diff --git a/garnet/bin/appmgr/integration_tests/sandbox/services/multiple_components.cc b/garnet/bin/appmgr/integration_tests/sandbox/services/multiple_components.cc index c894a668d398d4d443c0964d778aab4140bc46c7..ce353cd2d0492b66c2c5748c45b01b3d9de80559 100644 --- a/garnet/bin/appmgr/integration_tests/sandbox/services/multiple_components.cc +++ b/garnet/bin/appmgr/integration_tests/sandbox/services/multiple_components.cc @@ -40,6 +40,6 @@ TEST_F(NamespaceTest, MultipleComponents) { controllers.push_back(std::move(controller)); } - ASSERT_TRUE(RunLoopUntil([&num_running] { return num_running == 0; })); + RunLoopUntil([&num_running] { return num_running == 0; }); EXPECT_EQ(num_running, 0); } diff --git a/garnet/bin/appmgr/integration_tests/util/data_file_reader_writer_util.cc b/garnet/bin/appmgr/integration_tests/util/data_file_reader_writer_util.cc index cfe3340f30d1769a2f52234fb3fad4932bedf4f7..a6f2ec8924a70be65b8a6a7f8625109d727651df 100644 --- a/garnet/bin/appmgr/integration_tests/util/data_file_reader_writer_util.cc +++ b/garnet/bin/appmgr/integration_tests/util/data_file_reader_writer_util.cc @@ -4,8 +4,6 @@ #include "garnet/bin/appmgr/integration_tests/util/data_file_reader_writer_util.h" -#include <src/lib/fxl/logging.h> - namespace component { namespace testing { @@ -19,7 +17,7 @@ fidl::StringPtr DataFileReaderWriterUtil::ReadFileSync( done = true; result = contents; }); - FXL_CHECK(RunLoopUntil([&] { return done; })); + RunLoopUntil([&] { return done; }); return result; } @@ -32,7 +30,7 @@ zx_status_t DataFileReaderWriterUtil::WriteFileSync( done = true; result = write_result; }); - FXL_CHECK(RunLoopUntil([&] { return done; })); + RunLoopUntil([&] { return done; }); return result; } diff --git a/garnet/bin/chrealm/integration_tests/chrealm_integration_test.cc b/garnet/bin/chrealm/integration_tests/chrealm_integration_test.cc index 0af1d072b710a76de8efc06d1ec53bc70247b993..4b832f18cbf5902544762185b0a8e3978f050b19 100644 --- a/garnet/bin/chrealm/integration_tests/chrealm_integration_test.cc +++ b/garnet/bin/chrealm/integration_tests/chrealm_integration_test.cc @@ -2,11 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <unistd.h> -#include <cstdio> -#include <string> -#include <vector> - #include <fs/pseudo-dir.h> #include <fs/service.h> #include <fs/synchronous-vfs.h> @@ -14,19 +9,24 @@ #include <fuchsia/testing/chrealm/cpp/fidl.h> #include <lib/fdio/spawn.h> #include <lib/fidl/cpp/binding_set.h> +#include <lib/gtest/real_loop_fixture.h> +#include <lib/sys/cpp/testing/test_with_environment.h> #include <src/lib/fxl/arraysize.h> #include <src/lib/fxl/logging.h> #include <src/lib/fxl/strings/concatenate.h> #include <src/lib/fxl/strings/split_string.h> #include <src/lib/fxl/strings/string_printf.h> -#include <lib/gtest/real_loop_fixture.h> -#include <lib/sys/cpp/testing/test_with_environment.h> +#include <unistd.h> #include <zircon/compiler.h> #include <zircon/errors.h> #include <zircon/status.h> #include <zircon/syscalls.h> #include <zircon/types.h> +#include <cstdio> +#include <string> +#include <vector> + #include "garnet/bin/appmgr/util.h" #include "gtest/gtest.h" #include "src/lib/files/file.h" @@ -57,7 +57,7 @@ class ChrealmTest : public sys::testing::TestWithEnvironment, ASSERT_EQ(ZX_OK, services->AddService(bindings_.GetHandler(this))); // Create a nested realm to test with. enclosing_env_ = CreateNewEnclosingEnvironment(kRealm, std::move(services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(enclosing_env_.get())); + WaitForEnclosingEnvToStart(enclosing_env_.get()); // Get the path to the test realm in /hub. Test is running in the root // realm, so we find the realm under sys. diff --git a/garnet/bin/sysmgr/integration_tests/package_updating_loader_test.cc b/garnet/bin/sysmgr/integration_tests/package_updating_loader_test.cc index 8b4ac4f59993dda5c0fcc2c08159113e4580657c..68e7b5985029d7524e15054bb91d3eeac4b14a55 100644 --- a/garnet/bin/sysmgr/integration_tests/package_updating_loader_test.cc +++ b/garnet/bin/sysmgr/integration_tests/package_updating_loader_test.cc @@ -166,7 +166,7 @@ TEST_F(PackageUpdatingLoaderTest, Success) { const std::string message = "component launched"; fidl::StringPtr ret_msg = ""; echo->EchoString(message, [&](fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); // Verify that Resolve was called with the expected arguments. fuchsia::pkg::UpdatePolicy policy; @@ -198,7 +198,7 @@ TEST_F(PackageUpdatingLoaderTest, Failure) { fidl::StringPtr ret_msg = ""; echo->EchoString(message, [&](fidl::StringPtr retval) { ret_msg = retval; }); // Even though the update failed, the loader should load the component anyway. - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); } TEST_F(PackageUpdatingLoaderTest, HandleResolverDisconnectCorrectly) { @@ -225,7 +225,7 @@ TEST_F(PackageUpdatingLoaderTest, HandleResolverDisconnectCorrectly) { echo->EchoString(message, [&](fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); } // since the connection to the package resolver is initiated lazily, we need @@ -250,7 +250,7 @@ TEST_F(PackageUpdatingLoaderTest, HandleResolverDisconnectCorrectly) { FXL_LOG(INFO) << "sending echo message."; echo->EchoString(message, [&](fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); } // an initial connection and a retry @@ -276,7 +276,7 @@ TEST_F(PackageUpdatingLoaderTest, HandleResolverDisconnectCorrectly) { FXL_LOG(INFO) << "sending echo message."; echo->EchoString(message, [&](fidl::StringPtr retval) { ret_msg = retval; }); - ASSERT_TRUE(RunLoopUntil([&] { return std::string(ret_msg) == message; })); + RunLoopUntil([&] { return std::string(ret_msg) == message; }); } // one more connection diff --git a/garnet/public/lib/gtest/real_loop_fixture.cc b/garnet/public/lib/gtest/real_loop_fixture.cc index 02cb29a489b68d2a15a4b792c4af0c6b951e16f2..41ab54d77e0f48547868146d491ed08923becf7c 100644 --- a/garnet/public/lib/gtest/real_loop_fixture.cc +++ b/garnet/public/lib/gtest/real_loop_fixture.cc @@ -15,15 +15,16 @@ bool RunGivenLoopWithTimeout(async::Loop* loop, zx::duration timeout) { // after this function returns. auto canceled = std::make_shared<bool>(false); bool timed_out = false; - async::PostDelayedTask(loop->dispatcher(), - [loop, canceled, &timed_out] { - if (*canceled) { - return; - } - timed_out = true; - loop->Quit(); - }, - timeout); + async::PostDelayedTask( + loop->dispatcher(), + [loop, canceled, &timed_out] { + if (*canceled) { + return; + } + timed_out = true; + loop->Quit(); + }, + timeout); loop->Run(); loop->ResetQuit(); // Another task can call Quit() on the message loop, which exits the @@ -39,21 +40,6 @@ bool RunGivenLoopWithTimeout(async::Loop* loop, zx::duration timeout) { return timed_out; } -bool RunGivenLoopWithTimeoutOrUntil(async::Loop* loop, - fit::function<bool()> condition, - zx::duration timeout, zx::duration step) { - const zx::time deadline = (timeout == zx::sec(0)) - ? zx::time::infinite() - : zx::deadline_after(timeout); - while (zx::clock::get_monotonic() < deadline) { - if (condition()) { - return true; - } - RunGivenLoopWithTimeout(loop, step); - } - return condition(); -} - } // namespace RealLoopFixture::RealLoopFixture() : loop_(&kAsyncLoopConfigAttachToThread) {} @@ -74,14 +60,21 @@ bool RealLoopFixture::RunLoopWithTimeout(zx::duration timeout) { bool RealLoopFixture::RunLoopWithTimeoutOrUntil(fit::function<bool()> condition, zx::duration timeout, zx::duration step) { - return RunGivenLoopWithTimeoutOrUntil(&loop_, std::move(condition), timeout, - step); + const zx::time deadline = zx::deadline_after(timeout); + while (zx::clock::get_monotonic() < deadline) { + if (condition()) { + return true; + } + RunGivenLoopWithTimeout(&loop_, step); + } + return condition(); } -bool RealLoopFixture::RunLoopUntil(fit::function<bool()> condition, +void RealLoopFixture::RunLoopUntil(fit::function<bool()> condition, zx::duration step) { - return RunGivenLoopWithTimeoutOrUntil(&loop_, std::move(condition), - zx::sec(0), step); + while (!condition()) { + RunGivenLoopWithTimeout(&loop_, step); + } } void RealLoopFixture::RunLoopUntilIdle() { diff --git a/garnet/public/lib/gtest/real_loop_fixture.h b/garnet/public/lib/gtest/real_loop_fixture.h index 814b876ef893060a4f04032aac2610cf99459f9f..474c1efdc23d9db1c940871265c2bebade98281b 100644 --- a/garnet/public/lib/gtest/real_loop_fixture.h +++ b/garnet/public/lib/gtest/real_loop_fixture.h @@ -61,12 +61,8 @@ class RealLoopFixture : public ::testing::Test { // reached. bool RunLoopWithTimeout(zx::duration timeout = zx::sec(1)); - // Runs the loop until the condition returns true or the timeout is reached. - // Returns |true| if the condition was met, and |false| if the timeout was - // reached. - // TODO(qsr): When existing usage have been migrated to - // |RunLoopWithTimeoutOrUntil|, remove the timeout from this method. - bool RunLoopUntil(fit::function<bool()> condition, + // Runs the loop until the condition returns true. + void RunLoopUntil(fit::function<bool()> condition, zx::duration step = zx::msec(10)); // Runs the loop until the condition returns true or the timeout is reached. diff --git a/garnet/public/lib/inspect/tests/reader_unittest.cc b/garnet/public/lib/inspect/tests/reader_unittest.cc index f79736bb58aef52a055b45f95a22f9e6911d4294..64fde63218b7a82c050ff4492dbd1d2c4c3739c4 100644 --- a/garnet/public/lib/inspect/tests/reader_unittest.cc +++ b/garnet/public/lib/inspect/tests/reader_unittest.cc @@ -76,7 +76,7 @@ TEST_F(TestReader, Empty) { result = std::move(res); })); - ASSERT_TRUE(RunLoopUntil([&] { return !!result; })); + RunLoopUntil([&] { return !!result; }); EXPECT_THAT( inspect::ReadFromFidlObject(result.take_value()), NodeMatches(AllOf(NameMatches(kObjectsName), MetricList(IsEmpty()), @@ -98,7 +98,7 @@ TEST_F(TestReader, Values) { result = std::move(res); })); - ASSERT_TRUE(RunLoopUntil([&] { return !!result; })); + RunLoopUntil([&] { return !!result; }); EXPECT_THAT( inspect::ReadFromFidlObject(result.take_value()), @@ -124,7 +124,7 @@ TEST_F(TestReader, ListChildren) { result = std::move(res); })); - ASSERT_TRUE(RunLoopUntil([&] { return !!result; })); + RunLoopUntil([&] { return !!result; }); auto children = result.take_value(); EXPECT_THAT(*children, UnorderedElementsAre("child a", "child b")); @@ -145,7 +145,7 @@ TEST_F(TestReader, OpenChild) { result = std::move(res); })); - ASSERT_TRUE(RunLoopUntil([&] { return !!result; })); + RunLoopUntil([&] { return !!result; }); EXPECT_THAT(inspect::ReadFromFidlObject(result.take_value()), NodeMatches(AllOf( @@ -179,7 +179,7 @@ TEST_F(TestReader, OpenChildren) { } })); - ASSERT_TRUE(RunLoopUntil([&] { return result.size() == 2; })); + RunLoopUntil([&] { return result.size() == 2; }); std::vector<std::string> names; for (size_t i = 0; i < result.size(); i++) { @@ -249,7 +249,7 @@ TEST_F(TestHierarchy, ObjectHierarchy) { result = std::move(res); })); - ASSERT_TRUE(RunLoopUntil([&] { return !!result; })); + RunLoopUntil([&] { return !!result; }); auto hierarchy = result.take_value(); @@ -264,7 +264,7 @@ TEST_F(TestHierarchy, ObjectHierarchyLimitDepth) { result = std::move(res); })); - ASSERT_TRUE(RunLoopUntil([&] { return !!result; })); + RunLoopUntil([&] { return !!result; }); auto hierarchy = result.take_value(); diff --git a/peridot/bin/basemgr/auto_login_base_shell_test.cc b/peridot/bin/basemgr/auto_login_base_shell_test.cc index 7244fd834f490a6e4fd53611063a7de85c286763..202e62cde838728d94edd1541449e700b0be413c 100644 --- a/peridot/bin/basemgr/auto_login_base_shell_test.cc +++ b/peridot/bin/basemgr/auto_login_base_shell_test.cc @@ -36,5 +36,5 @@ TEST_F(AutoLoginBaseShellTest, AutoLoginBaseShellLaunchesSessionShell) { test_harness()->Run(std::move(spec)); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted; })); + RunLoopUntil([&] { return intercepted; }); } diff --git a/peridot/bin/modular_test_harness/modular_test_harness_test.cc b/peridot/bin/modular_test_harness/modular_test_harness_test.cc index b0f2ae5cec73cc734a2236f57fcf2c1d4b16b382..eaf7f689c96053bb21274d46855094775f9c3fd4 100644 --- a/peridot/bin/modular_test_harness/modular_test_harness_test.cc +++ b/peridot/bin/modular_test_harness/modular_test_harness_test.cc @@ -39,5 +39,5 @@ TEST_F(TestHarnessFixtureTest, SimpleSuccess) { test_harness()->Run(std::move(spec)); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted; })); + RunLoopUntil([&] { return intercepted; }); } diff --git a/peridot/public/lib/modular_test_harness/cpp/test_harness_fixture_test.cc b/peridot/public/lib/modular_test_harness/cpp/test_harness_fixture_test.cc index 3d59fad98f76220b791400928a84c0cae84dae5d..0f00242082368845031296e85e2dba80a9058188 100644 --- a/peridot/public/lib/modular_test_harness/cpp/test_harness_fixture_test.cc +++ b/peridot/public/lib/modular_test_harness/cpp/test_harness_fixture_test.cc @@ -79,5 +79,5 @@ TEST_F(TestHarnessFixtureTest, SimpleSuccess) { test_harness()->Run(std::move(spec)); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted; })); + RunLoopUntil([&] { return intercepted; }); } diff --git a/peridot/public/lib/modular_test_harness/cpp/test_harness_impl_unittest.cc b/peridot/public/lib/modular_test_harness/cpp/test_harness_impl_unittest.cc index 3b27f190efb827f5278fb2f6bc169fec1cbbee0d..17cc280b29af15adf171456fe403db587a09f0a0 100644 --- a/peridot/public/lib/modular_test_harness/cpp/test_harness_impl_unittest.cc +++ b/peridot/public/lib/modular_test_harness/cpp/test_harness_impl_unittest.cc @@ -71,7 +71,7 @@ namespace { // it's not usable. TEST_F(TestHarnessImplTest, ExitCallback) { test_harness().Unbind(); - ASSERT_TRUE(RunLoopUntil([&] { return did_exit(); })); + RunLoopUntil([&] { return did_exit(); }); } // Check that the config that TestHarnessImpl generates is readable by @@ -155,7 +155,7 @@ TEST_F(TestHarnessImplTest, DefaultInjectedServices) { fuchsia::auth::account::AccountManager::Name_, accountmgr.NewRequest().TakeChannel()); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted_accountmgr; })); + RunLoopUntil([&] { return intercepted_accountmgr; }); } // Test that additional injected services are made available, spin up the @@ -199,7 +199,7 @@ TEST_F(TestHarnessImplTest, CustomInjectedServices) { fuchsia::modular::ComponentContext::Name_, componentctx.NewRequest().TakeChannel()); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted_componentctx; })); + RunLoopUntil([&] { return intercepted_componentctx; }); } TEST_F(TestHarnessImplTest, InterceptBaseShell) { @@ -228,7 +228,7 @@ TEST_F(TestHarnessImplTest, InterceptBaseShell) { test_harness()->Run(std::move(spec)); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted; })); + RunLoopUntil([&] { return intercepted; }); }; TEST_F(TestHarnessImplTest, InterceptSessionShell) { @@ -260,7 +260,7 @@ TEST_F(TestHarnessImplTest, InterceptSessionShell) { test_harness()->Run(std::move(spec)); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted; })); + RunLoopUntil([&] { return intercepted; }); }; TEST_F(TestHarnessImplTest, InterceptStoryShellAndModule) { diff --git a/peridot/tests/modular_login_tests/login_override_test.cc b/peridot/tests/modular_login_tests/login_override_test.cc index 932f4bc01646829aa71368585bc65a8446b2e716..2f75370eec428d75c99268fbfc3382af8057613c 100644 --- a/peridot/tests/modular_login_tests/login_override_test.cc +++ b/peridot/tests/modular_login_tests/login_override_test.cc @@ -72,7 +72,7 @@ TEST_F(LoginOverrideTest, AuthProviderOverrideLaunchesBaseShell) { test_harness()->Run(std::move(spec)); }); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted; })); + RunLoopUntil([&] { return intercepted; }); } // Setting LoginOverride to AUTOLOGIN_GUEST should launch the session shell. @@ -98,5 +98,5 @@ TEST_F(LoginOverrideTest, AutoLoginGuestOverrideLaunchesSessionShell) { test_harness()->Run(std::move(spec)); }); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted; })); + RunLoopUntil([&] { return intercepted; }); } diff --git a/sdk/lib/sys/cpp/testing/test_with_environment.h b/sdk/lib/sys/cpp/testing/test_with_environment.h index af5d21fbd864ee6f6d8fde348f9ae5b9ac274dcd..17ae71f5fa7d547c7d637dc55db8168bd9d1ecb8 100644 --- a/sdk/lib/sys/cpp/testing/test_with_environment.h +++ b/sdk/lib/sys/cpp/testing/test_with_environment.h @@ -108,13 +108,13 @@ class TestWithEnvironment : public gtest::RealLoopFixture { fuchsia::sys::LaunchInfo launch_info, fidl::InterfaceRequest<fuchsia::sys::ComponentController> request); - // Returns true if environment was created. + // Waits for the environment to start. // // You should either use this function to wait or run your own loop if you // want CreateComponent* to succed on |enclosing_environment|. - bool WaitForEnclosingEnvToStart( + void WaitForEnclosingEnvToStart( const EnclosingEnvironment* enclosing_environment) { - return RunLoopUntil([enclosing_environment] { + RunLoopUntil([enclosing_environment] { return enclosing_environment->is_running(); }); } diff --git a/sdk/lib/sys/cpp/tests/component_interceptor_unittest.cc b/sdk/lib/sys/cpp/tests/component_interceptor_unittest.cc index 0dd964411ee0ad9644900b6a44542a714065a24a..aa97d57e89e1be37b9871efd88f57217ae1df32e 100644 --- a/sdk/lib/sys/cpp/tests/component_interceptor_unittest.cc +++ b/sdk/lib/sys/cpp/tests/component_interceptor_unittest.cc @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <string> -#include <vector> - #include <fuchsia/sys/cpp/fidl.h> #include <lib/async-loop/cpp/loop.h> #include <lib/fidl/cpp/binding_set.h> @@ -12,6 +9,9 @@ #include <lib/sys/cpp/testing/component_interceptor.h> #include <lib/sys/cpp/testing/test_with_environment.h> +#include <string> +#include <vector> + #include "gtest/gtest.h" namespace { @@ -85,7 +85,7 @@ TEST_F(ComponentInterceptorTest, TestFallbackAndInterceptingUrls) { info.url = kInterceptUrl; env->CreateComponent(std::move(info), controller.NewRequest()); - ASSERT_TRUE(RunLoopUntil([&] { return intercepted_url; })); + RunLoopUntil([&] { return intercepted_url; }); EXPECT_EQ(kInterceptUrl, actual_url); } @@ -99,8 +99,7 @@ TEST_F(ComponentInterceptorTest, TestFallbackAndInterceptingUrls) { // Should this call into our TestLoader. env->CreateComponent(std::move(info), controller.NewRequest()); - ASSERT_TRUE( - RunLoopUntil([&] { return test_loader.requested_urls.size() > 0u; })); + RunLoopUntil([&] { return test_loader.requested_urls.size() > 0u; }); EXPECT_EQ(kFallbackUrl, test_loader.requested_urls[0]); } @@ -137,11 +136,11 @@ TEST_F(ComponentInterceptorTest, TestOnKill) { info.url = kInterceptUrl; env->CreateComponent(std::move(info), controller.NewRequest()); - ASSERT_TRUE(RunLoopUntil([&] { return !!component; })); + RunLoopUntil([&] { return !!component; }); ASSERT_FALSE(killed); } // should be killed - ASSERT_TRUE(RunLoopUntil([&] { return killed; })); + RunLoopUntil([&] { return killed; }); } TEST_F(ComponentInterceptorTest, ExtraCmx) { diff --git a/sdk/lib/sys/cpp/tests/enclosing_environment_test.cc b/sdk/lib/sys/cpp/tests/enclosing_environment_test.cc index ad27a5db9c612e07ba35398387160e47815530ea..fcfaf65cb8f56b490bd888d50d9f601620cc8103 100644 --- a/sdk/lib/sys/cpp/tests/enclosing_environment_test.cc +++ b/sdk/lib/sys/cpp/tests/enclosing_environment_test.cc @@ -2,17 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <lib/sys/cpp/testing/enclosing_environment.h> - #include <fidl/examples/echo/cpp/fidl.h> #include <fuchsia/debugdata/cpp/fidl.h> #include <lib/async-loop/cpp/loop.h> #include <lib/async/cpp/wait.h> #include <lib/async/dispatcher.h> #include <lib/fidl/cpp/binding_set.h> +#include <lib/sys/cpp/testing/enclosing_environment.h> #include <lib/sys/cpp/testing/test_with_environment.h> #include <lib/zx/vmo.h> #include <zircon/processargs.h> + #include <memory> #include "src/lib/fxl/strings/string_printf.h" @@ -115,7 +115,7 @@ TEST_F(EnclosingEnvTest, RespawnService) { linfo.arguments.reset({"--echo", "--kill=die"}); svc->AddServiceWithLaunchInfo(std::move(linfo), echo::Echo::Name_); auto env = CreateNewEnclosingEnvironment("test-env", std::move(svc)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(env.get())); + WaitForEnclosingEnvToStart(env.get()); // attempt to connect to service: bool req_done = false; bool got_error = false; @@ -129,7 +129,7 @@ TEST_F(EnclosingEnvTest, RespawnService) { ASSERT_EQ(rsp, "hello"); req_done = true; }); - ASSERT_TRUE(RunLoopUntil([&req_done]() { return req_done; })); + RunLoopUntil([&req_done]() { return req_done; }); // reset flag, and send the kill string req_done = false; @@ -140,8 +140,7 @@ TEST_F(EnclosingEnvTest, RespawnService) { }); // wait until we see the response AND the channel closing - ASSERT_TRUE(RunLoopUntil( - [&req_done, &got_error]() { return req_done && got_error; })); + RunLoopUntil([&req_done, &got_error]() { return req_done && got_error; }); // Try to communicate with server again, we expect // it to be spun up once more @@ -161,7 +160,7 @@ TEST_F(EnclosingEnvTest, EnclosingEnvOnASeperateThread) { linfo.arguments.reset({"--echo", "--kill=die"}); svc->AddServiceWithLaunchInfo(std::move(linfo), echo::Echo::Name_); env = CreateNewEnclosingEnvironment("test-env", std::move(svc)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(env.get())); + WaitForEnclosingEnvToStart(env.get()); echo::EchoSyncPtr echo_ptr; env->ConnectToService(echo_ptr.NewRequest()); @@ -186,7 +185,7 @@ TEST_F(EnclosingEnvTest, RespawnServiceWithHandler) { }, echo::Echo::Name_); auto env = CreateNewEnclosingEnvironment("test-env", std::move(svc)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(env.get())); + WaitForEnclosingEnvToStart(env.get()); // attempt to connect to service: bool req_done = false; bool got_error = false; @@ -200,7 +199,7 @@ TEST_F(EnclosingEnvTest, RespawnServiceWithHandler) { ASSERT_EQ(rsp, "hello"); req_done = true; }); - ASSERT_TRUE(RunLoopUntil([&req_done]() { return req_done; })); + RunLoopUntil([&req_done]() { return req_done; }); // check that the launch info factory function was called only once EXPECT_EQ(call_counter, 1); @@ -213,8 +212,7 @@ TEST_F(EnclosingEnvTest, RespawnServiceWithHandler) { }); // wait until we see the response AND the channel closing - ASSERT_TRUE(RunLoopUntil( - [&req_done, &got_error]() { return req_done && got_error; })); + RunLoopUntil([&req_done, &got_error]() { return req_done && got_error; }); // Try to communicate with server again, we expect // it to be spun up once more @@ -247,7 +245,7 @@ TEST_F(EnclosingEnvTest, OutErrPassing) { }, echo::Echo::Name_); auto env = CreateNewEnclosingEnvironment("test-env", std::move(svc)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(env.get())); + WaitForEnclosingEnvToStart(env.get()); // attempt to connect to service: echo::EchoPtr echo; @@ -257,10 +255,10 @@ TEST_F(EnclosingEnvTest, OutErrPassing) { // now it's just a matter of waiting for the socket readers to // have seen those strings: - ASSERT_TRUE(RunLoopUntil([&cout_reader, &cerr_reader]() { + RunLoopUntil([&cout_reader, &cerr_reader]() { return cout_reader.GetString().find("potato") != std::string::npos && cerr_reader.GetString().find("tomato") != std::string::npos; - })); + }); } class FakeLoader : public fuchsia::sys::Loader { @@ -308,15 +306,13 @@ TEST_F(EnclosingEnvTest, CanLaunchMoreThanOneService) { svc_names.push_back(svc_name); } auto env = CreateNewEnclosingEnvironment("test-env", std::move(svc)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(env.get())); + WaitForEnclosingEnvToStart(env.get()); for (int i = 0; i < 3; i++) { echo::EchoPtr echo; env->ConnectToService(echo.NewRequest(), svc_names[i]); } - ASSERT_TRUE(RunLoopUntil([&loader]() { - return loader.component_urls().size() == 3; - })) << loader.component_urls().size(); + RunLoopUntil([&loader]() { return loader.component_urls().size() == 3; }); ASSERT_EQ(loader.component_urls(), urls); } @@ -355,7 +351,7 @@ TEST_F(EnclosingEnvTest, DebugDataServicePlumbedCorrectly) { auto svc = CreateServicesWithParentOverrides(std::move(parent_overrides)); auto env = CreateNewEnclosingEnvironment("test-env1", std::move(svc)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(env.get())); + WaitForEnclosingEnvToStart(env.get()); // make sure count was 0 ASSERT_EQ(0u, debug_data.call_count()); @@ -364,9 +360,7 @@ TEST_F(EnclosingEnvTest, DebugDataServicePlumbedCorrectly) { ASSERT_EQ(ZX_OK, zx::vmo::create(8, 0, &data)); ptr->Publish("data_sink", std::move(data)); - ASSERT_TRUE(RunLoopUntil([&debug_data]() { - return debug_data.call_count() == 1; - })) << debug_data.call_count(); + RunLoopUntil([&debug_data]() { return debug_data.call_count() == 1; }); // make sure service is automatically plumbed to sub environments auto sub_env = env->CreateNestedEnclosingEnvironment("test-env2"); @@ -377,9 +371,7 @@ TEST_F(EnclosingEnvTest, DebugDataServicePlumbedCorrectly) { ASSERT_EQ(ZX_OK, zx::vmo::create(8, 0, &data)); ptr->Publish("data_sink", std::move(data)); - ASSERT_TRUE(RunLoopUntil([&debug_data]() { - return debug_data.call_count() == 2; - })) << debug_data.call_count(); + RunLoopUntil([&debug_data]() { return debug_data.call_count() == 2; }); } } // namespace sys::testing::test diff --git a/sdk/lib/vfs/cpp/pseudo_file_unittest.cc b/sdk/lib/vfs/cpp/pseudo_file_unittest.cc index e92127832c8c1dafbbf861c835a234249b41bfb2..64c4777ce75b6cc1336d0001b50b4ae42cb0398f 100644 --- a/sdk/lib/vfs/cpp/pseudo_file_unittest.cc +++ b/sdk/lib/vfs/cpp/pseudo_file_unittest.cc @@ -104,7 +104,7 @@ class PseudoFileTest : public gtest::RealLoopFixture { } }; - ASSERT_TRUE(RunLoopUntil([&]() { return on_open_called; })); + RunLoopUntil([&]() { return on_open_called; }); } } @@ -204,9 +204,7 @@ class PseudoFileTest : public gtest::RealLoopFixture { void AssertFileWrapperState(FileWrapper& file_wrapper, const std::string& expected_str) { - ASSERT_TRUE(RunLoopUntil([&]() { - return file_wrapper.buffer() == expected_str; - })) << file_wrapper.buffer(); + RunLoopUntil([&]() { return file_wrapper.buffer() == expected_str; }); } int OpenAsFD(vfs::internal::Node* node, async_dispatcher_t* dispatcher) { diff --git a/sdk/lib/vfs/cpp/service_unittest.cc b/sdk/lib/vfs/cpp/service_unittest.cc index 00d14e01de0ffe973e7a46c9277140f86375e282..6ff46988623de501a871183c95598b748bef25f3 100644 --- a/sdk/lib/vfs/cpp/service_unittest.cc +++ b/sdk/lib/vfs/cpp/service_unittest.cc @@ -7,6 +7,7 @@ #include <fidl/examples/echo/cpp/fidl.h> #include <lib/fdio/vfs.h> #include <lib/fidl/cpp/binding_set.h> + #include "lib/gtest/real_loop_fixture.h" #include "lib/vfs/cpp/pseudo_dir.h" @@ -24,10 +25,9 @@ class ServiceTest : public gtest::RealLoopFixture, auto service = std::make_unique<vfs::Service>( bindings_.GetHandler(this, second_loop_.dispatcher())); - dir_.Serve(fuchsia::io::OPEN_RIGHT_READABLE | - fuchsia::io::OPEN_RIGHT_WRITABLE, - dir_ptr_.NewRequest().TakeChannel(), - second_loop_.dispatcher()); + dir_.Serve( + fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_WRITABLE, + dir_ptr_.NewRequest().TakeChannel(), second_loop_.dispatcher()); dir_.AddEntry(service_name_, std::move(service)); second_loop_.StartThread("vfs test thread"); } @@ -53,7 +53,7 @@ class ServiceTest : public gtest::RealLoopFixture, EXPECT_EQ(expected_status, status); }; - ASSERT_TRUE(RunLoopUntil([&]() { return on_open_called; }, zx::msec(1))); + RunLoopUntil([&]() { return on_open_called; }, zx::msec(1)); } fuchsia::io::DirectoryPtr& dir_ptr() { return dir_ptr_; } @@ -131,26 +131,20 @@ TEST_F(ServiceTest, CanOpenAsAService) { } TEST_F(ServiceTest, CannotOpenServiceWithInvalidFlags) { - uint32_t flags[] = {fuchsia::io::OPEN_FLAG_CREATE, - fuchsia::io::OPEN_FLAG_CREATE_IF_ABSENT, - fuchsia::io::OPEN_FLAG_TRUNCATE, - fuchsia::io::OPEN_FLAG_APPEND, - fuchsia::io::OPEN_FLAG_NO_REMOTE}; + uint32_t flags[] = { + fuchsia::io::OPEN_FLAG_CREATE, fuchsia::io::OPEN_FLAG_CREATE_IF_ABSENT, + fuchsia::io::OPEN_FLAG_TRUNCATE, fuchsia::io::OPEN_FLAG_APPEND, + fuchsia::io::OPEN_FLAG_NO_REMOTE}; for (uint32_t flag : flags) { - AssertInvalidOpen(flag | - fuchsia::io::OPEN_RIGHT_READABLE | + AssertInvalidOpen(flag | fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_RIGHT_WRITABLE, - 0, - ZX_ERR_NOT_SUPPORTED); + 0, ZX_ERR_NOT_SUPPORTED); } - AssertInvalidOpen(fuchsia::io::OPEN_RIGHT_ADMIN, - 0, - ZX_ERR_ACCESS_DENIED); - AssertInvalidOpen(fuchsia::io::OPEN_RIGHT_READABLE | - fuchsia::io::OPEN_FLAG_DIRECTORY, - 0, - ZX_ERR_NOT_DIR); + AssertInvalidOpen(fuchsia::io::OPEN_RIGHT_ADMIN, 0, ZX_ERR_ACCESS_DENIED); + AssertInvalidOpen( + fuchsia::io::OPEN_RIGHT_READABLE | fuchsia::io::OPEN_FLAG_DIRECTORY, 0, + ZX_ERR_NOT_DIR); } TEST_F(ServiceTest, CannotOpenServiceWithInvalidMode) { @@ -159,8 +153,7 @@ TEST_F(ServiceTest, CannotOpenServiceWithInvalidMode) { fuchsia::io::MODE_TYPE_FILE, fuchsia::io::MODE_TYPE_SOCKET}; for (uint32_t mode : modes) { - AssertInvalidOpen(fuchsia::io::OPEN_RIGHT_READABLE, - mode, + AssertInvalidOpen(fuchsia::io::OPEN_RIGHT_READABLE, mode, ZX_ERR_INVALID_ARGS); } } diff --git a/sdk/lib/vfs/cpp/testing/dir_test_util.cc b/sdk/lib/vfs/cpp/testing/dir_test_util.cc index d5f0ad2e74a660f66c21b40cda66635f4aaf6e07..307812a8fd923044f37bd27bd78fd9ac7d52e342 100644 --- a/sdk/lib/vfs/cpp/testing/dir_test_util.cc +++ b/sdk/lib/vfs/cpp/testing/dir_test_util.cc @@ -64,7 +64,7 @@ void DirConnection::AssertOpen(async_dispatcher_t* dispatcher, uint32_t flags, } }; - ASSERT_TRUE(RunLoopUntil([&]() { return on_open_called; }, zx::msec(1))); + RunLoopUntil([&]() { return on_open_called; }, zx::msec(1)); } } diff --git a/sdk/lib/vfs/cpp/testing/dir_test_util.h b/sdk/lib/vfs/cpp/testing/dir_test_util.h index f842aa3fc309e77b0de0ce965afc5f8531907093..0c16616e53441e0830eb31560aa3f469388a8b15 100644 --- a/sdk/lib/vfs/cpp/testing/dir_test_util.h +++ b/sdk/lib/vfs/cpp/testing/dir_test_util.h @@ -78,7 +78,7 @@ class DirConnection : public gtest::RealLoopFixture { << "from file " << caller_file << ", line " << caller_line; }; - ASSERT_TRUE(RunLoopUntil([&]() { return on_open_called; }, zx::msec(1))); + RunLoopUntil([&]() { return on_open_called; }, zx::msec(1)); // Bind channel to sync_ptr out_sync_ptr.Bind(node_ptr.Unbind().TakeChannel()); diff --git a/src/connectivity/network/testing/netemul/lib/network/network_service_unittest.cc b/src/connectivity/network/testing/netemul/lib/network/network_service_unittest.cc index c6a100a5b244624564558f13d2715784bb4ee435..d38320c75503370d7f68158cecdba2dd4ea48ec6 100644 --- a/src/connectivity/network/testing/netemul/lib/network/network_service_unittest.cc +++ b/src/connectivity/network/testing/netemul/lib/network/network_service_unittest.cc @@ -60,7 +60,7 @@ class NetworkServiceTest : public TestWithEnvironment { services->AddService(svc_->GetHandler()); test_env_ = CreateNewEnclosingEnvironment("env", std::move(services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(test_env_.get())); + WaitForEnclosingEnvToStart(test_env_.get()); } void GetNetworkManager(fidl::InterfaceRequest<FNetworkManager> nm) { diff --git a/src/connectivity/network/testing/netemul/lib/sync/barrier_unittest.cc b/src/connectivity/network/testing/netemul/lib/sync/barrier_unittest.cc index 38d9d5ec35dbbc063095013e017d6e9be17e2944..92898cadb0dcc33f556fc4269f8e84f631de047d 100644 --- a/src/connectivity/network/testing/netemul/lib/sync/barrier_unittest.cc +++ b/src/connectivity/network/testing/netemul/lib/sync/barrier_unittest.cc @@ -46,7 +46,7 @@ class BarrierTest : public TestWithEnvironment { services->AddService(svc_->GetHandler()); test_env_ = CreateNewEnclosingEnvironment("env", std::move(services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(test_env_.get())); + WaitForEnclosingEnvToStart(test_env_.get()); } void TearDown() override { diff --git a/src/connectivity/network/testing/netemul/lib/sync/bus_unittest.cc b/src/connectivity/network/testing/netemul/lib/sync/bus_unittest.cc index f830ea7dce97ae05c0ab1d0ff94ba4e46fbb1361..78b7736835ebd59c6c3c9393b04b9f8de66e54a5 100644 --- a/src/connectivity/network/testing/netemul/lib/sync/bus_unittest.cc +++ b/src/connectivity/network/testing/netemul/lib/sync/bus_unittest.cc @@ -49,7 +49,7 @@ class BusTest : public TestWithEnvironment { services->AddService(svc_->GetHandler()); test_env_ = CreateNewEnclosingEnvironment("env", std::move(services)); - ASSERT_TRUE(WaitForEnclosingEnvToStart(test_env_.get())); + WaitForEnclosingEnvToStart(test_env_.get()); } void TearDown() override { diff --git a/src/connectivity/network/testing/netemul/runner/logger_unittest.cc b/src/connectivity/network/testing/netemul/runner/logger_unittest.cc index 62bf22fd3dc2b87c8988f9647d6c7a559d0ae6c4..8e4d4936d10e1b9d6f0b93e2e68e94a953d75cce 100644 --- a/src/connectivity/network/testing/netemul/runner/logger_unittest.cc +++ b/src/connectivity/network/testing/netemul/runner/logger_unittest.cc @@ -66,7 +66,7 @@ class LoggerTest : public sys::testing::TestWithEnvironment { .inherit_parent_services = false, .kill_on_oom = true, .delete_storage_on_death = true}); - ASSERT_TRUE(WaitForEnclosingEnvToStart(env.get())); + WaitForEnclosingEnvToStart(env.get()); fuchsia::logger::LogSinkPtr sink; env->ConnectToService(sink.NewRequest(dispatcher())); diff --git a/src/virtualization/bin/vmm/device/test_with_device.cc b/src/virtualization/bin/vmm/device/test_with_device.cc index 766be1702d9c13ad792b36676560473f40f5ee2b..33326f6ebd7a520334784ae1f93b38af95adcb2e 100644 --- a/src/virtualization/bin/vmm/device/test_with_device.cc +++ b/src/virtualization/bin/vmm/device/test_with_device.cc @@ -28,10 +28,7 @@ zx_status_t TestWithDevice::LaunchDevice( // Create test environment. enclosing_environment_ = CreateNewEnclosingEnvironment(env_label, std::move(env_services)); - bool started = WaitForEnclosingEnvToStart(enclosing_environment_.get()); - if (!started) { - return ZX_ERR_TIMED_OUT; - } + WaitForEnclosingEnvToStart(enclosing_environment_.get()); zx::channel request; services_ = sys::ServiceDirectory::CreateWithRequest(&request);