[appmgr] Fix RealmFakeLoaderTest.CreateWebComponent_HTTP(S)
Test isn't hermetic and was failing if web_runner package was not
present on device.
Also updates web_runner_prototype runner_url in Realm to use
fuchsia-pkg URL.
Test: appmgr_integration_tests
CF-156 #comment
Change-Id: I616355dcf67ad56aaa24f4b64da772c6dbf662dc
diff --git a/bin/appmgr/integration_tests/BUILD.gn b/bin/appmgr/integration_tests/BUILD.gn
index 0e2b328..b80870d 100644
--- a/bin/appmgr/integration_tests/BUILD.gn
+++ b/bin/appmgr/integration_tests/BUILD.gn
@@ -30,6 +30,7 @@
"//garnet/public/lib/fxl/test:gtest_main",
"//garnet/public/lib/gtest",
"//third_party/googletest:gtest",
+ "//third_party/googletest:gmock",
"//zircon/public/lib/async-loop-cpp",
]
}
diff --git a/bin/appmgr/integration_tests/realm_integration_test.cc b/bin/appmgr/integration_tests/realm_integration_test.cc
index 32eb61a..75a1359 100644
--- a/bin/appmgr/integration_tests/realm_integration_test.cc
+++ b/bin/appmgr/integration_tests/realm_integration_test.cc
@@ -20,6 +20,7 @@
#include <lib/async/default.h>
#include <lib/fdio/util.h>
#include "garnet/bin/appmgr/util.h"
+#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "lib/component/cpp/testing/test_util.h"
#include "lib/component/cpp/testing/test_with_environment.h"
@@ -32,6 +33,9 @@
using fuchsia::sys::TerminationReason;
+using ::testing::AnyOf;
+using ::testing::Eq;
+
using testing::CloneFileDescriptor;
using testing::EnclosingEnvironment;
using testing::TestWithEnvironment;
@@ -262,15 +266,21 @@
TEST_F(RealmFakeLoaderTest, CreateWebComponent_HTTP) {
RunComponent(enclosing_environment_.get(), "http://example.com");
ASSERT_TRUE(WaitForComponentLoad());
- EXPECT_EQ("fuchsia-pkg://fuchsia.com/web_runner#meta/web_runner.cmx",
- component_url());
+ EXPECT_THAT(
+ component_url(),
+ AnyOf(Eq("fuchsia-pkg://fuchsia.com/web_runner#meta/web_runner.cmx"),
+ Eq("fuchsia-pkg://fuchsia.com/web_runner_prototype#meta/"
+ "web_runner_prototype.cmx")));
}
TEST_F(RealmFakeLoaderTest, CreateWebComponent_HTTPS) {
RunComponent(enclosing_environment_.get(), "https://example.com");
ASSERT_TRUE(WaitForComponentLoad());
- EXPECT_EQ("fuchsia-pkg://fuchsia.com/web_runner#meta/web_runner.cmx",
- component_url());
+ EXPECT_THAT(
+ component_url(),
+ AnyOf(Eq("fuchsia-pkg://fuchsia.com/web_runner#meta/web_runner.cmx"),
+ Eq("fuchsia-pkg://fuchsia.com/web_runner_prototype#meta/"
+ "web_runner_prototype.cmx")));
}
TEST_F(RealmFakeLoaderTest, CreateCastComponent_CAST) {
diff --git a/bin/appmgr/realm.cc b/bin/appmgr/realm.cc
index 2f45637..10d75c4 100644
--- a/bin/appmgr/realm.cc
+++ b/bin/appmgr/realm.cc
@@ -571,7 +571,9 @@
"fuchsia-pkg://fuchsia.com/web_runner#meta/web_runner.cmx" &&
!files::IsDirectory("/pkgfs/packages/web_runner") &&
files::IsDirectory("/pkgfs/packages/web_runner_prototype")) {
- runner_url = "web_runner_prototype";
+ runner_url =
+ "fuchsia-pkg://fuchsia.com/web_runner_prototype#meta/"
+ "web_runner_prototype.cmx";
}
fuchsia::sys::Package package;
@@ -684,9 +686,8 @@
"Realm::CreateComponentFromPackage:VmoFromFilenameAt");
if (!app_data) {
FXL_LOG(ERROR) << "component '" << package->resolved_url.get()
- << "' has neither runner (error: '"
- << runtime_parse_error << "') nor elf binary: '"
- << bin_path << "'";
+ << "' has neither runner (error: '" << runtime_parse_error
+ << "') nor elf binary: '" << bin_path << "'";
component_request.SetReturnValues(kComponentCreationFailed,
TerminationReason::INTERNAL_ERROR);
return;