diff --git a/peridot/packages/tests/BUILD.gn b/peridot/packages/tests/BUILD.gn index e7375906efdfb55f05082b7dde6a9320fa6f8f28..b29548865f212ffd0a9c0d1e3e59f46a3e12b510 100644 --- a/peridot/packages/tests/BUILD.gn +++ b/peridot/packages/tests/BUILD.gn @@ -21,6 +21,8 @@ group("ledger") { "//src/ledger/bin:ledger_fuzzers", "//src/ledger/bin/testing/ledger_test_instance_provider:ledger_test_instance_provider", "//src/ledger/cloud_provider_in_memory/bin", + "//src/ledger/cloud_provider_memory_diff", + "//src/ledger/cloud_provider_memory_diff:cloud_provider_memory_diff_tests", ] } diff --git a/src/ledger/cloud_provider_memory_diff/BUILD.gn b/src/ledger/cloud_provider_memory_diff/BUILD.gn index 1ee8b3fe83ad2f5b912b1d14a4c1801fdfdacf5e..62ce591fa1d0090efb51c96cc4a3fc4f1254a5d2 100644 --- a/src/ledger/cloud_provider_memory_diff/BUILD.gn +++ b/src/ledger/cloud_provider_memory_diff/BUILD.gn @@ -34,3 +34,25 @@ package("cloud_provider_memory_diff") { }, ] } + +package("cloud_provider_memory_diff_tests") { + testonly = true + + deps = [ + "validation", + ] + + meta = [ + { + path = rebase_path("validation/validation_memory_diff.cmx") + dest = "validation_memory_diff.cmx" + }, + ] + + tests = [ + { + name = "launch_validation_tests_memory_diff" + environments = basic_envs + }, + ] +} diff --git a/src/ledger/cloud_provider_memory_diff/validation/BUILD.gn b/src/ledger/cloud_provider_memory_diff/validation/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1e272c49015dd10600002eb7b09fd2415bb13b30 --- /dev/null +++ b/src/ledger/cloud_provider_memory_diff/validation/BUILD.gn @@ -0,0 +1,22 @@ +# Copyright 2019 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. + +visibility = [ "//src/ledger/cloud_provider_memory_diff/*" ] + +executable("validation") { + output_name = "launch_validation_tests_memory_diff" + testonly = true + + sources = [ + "launch.cc", + ] + + deps = [ + "//sdk/fidl/fuchsia.ledger.cloud", + "//src/ledger/bin/tests/cloud_provider/launcher", + "//src/lib/fxl", + "//zircon/public/lib/async-cpp", + "//zircon/public/lib/async-loop-cpp", + ] +} diff --git a/src/ledger/cloud_provider_memory_diff/validation/launch.cc b/src/ledger/cloud_provider_memory_diff/validation/launch.cc new file mode 100644 index 0000000000000000000000000000000000000000..deac4209f1f78bbe552c24052662ca501d0876d3 --- /dev/null +++ b/src/ledger/cloud_provider_memory_diff/validation/launch.cc @@ -0,0 +1,56 @@ +// Copyright 2019 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 <fuchsia/ledger/cloud/cpp/fidl.h> +#include <lib/async-loop/cpp/loop.h> +#include <lib/async/cpp/task.h> +#include <lib/sys/cpp/component_context.h> +#include <lib/sys/cpp/service_directory.h> + +#include <iostream> + +#include "src/ledger/bin/tests/cloud_provider/launcher/validation_tests_launcher.h" +#include "src/lib/fxl/logging.h" +#include "src/lib/fxl/strings/string_view.h" + +namespace { + +constexpr fxl::StringView kCloudProviderUrl = + "fuchsia-pkg://fuchsia.com/cloud_provider_memory_diff#meta/" + "cloud_provider_memory_diff.cmx"; +} // namespace + +int main(int argc, char** argv) { + async::Loop loop(&kAsyncLoopConfigAttachToThread); + std::unique_ptr<sys::ComponentContext> component_context = + sys::ComponentContext::Create(); + fuchsia::sys::LauncherPtr component_launcher; + component_context->svc()->Connect(component_launcher.NewRequest()); + cloud_provider::ValidationTestsLauncher launcher( + component_context.get(), + [component_launcher = std::move(component_launcher), + &loop](auto request) { + fuchsia::sys::LaunchInfo launch_info; + launch_info.url = kCloudProviderUrl.ToString(); + auto cloud_provider_services = sys::ServiceDirectory::CreateWithRequest( + &launch_info.directory_request); + + fuchsia::sys::ComponentControllerPtr cloud_instance; + component_launcher->CreateComponent(std::move(launch_info), + cloud_instance.NewRequest()); + cloud_provider_services->Connect( + std::move(request), fuchsia::ledger::cloud::CloudProvider::Name_); + return cloud_instance; + }); + + int32_t return_code = -1; + async::PostTask(loop.dispatcher(), [&launcher, &return_code, &loop] { + launcher.Run({}, [&return_code, &loop](int32_t result) { + return_code = result; + loop.Quit(); + }); + }); + loop.Run(); + return return_code; +} diff --git a/src/ledger/cloud_provider_memory_diff/validation/validation_memory_diff.cmx b/src/ledger/cloud_provider_memory_diff/validation/validation_memory_diff.cmx new file mode 100644 index 0000000000000000000000000000000000000000..44d7f240b13799c31d1d89417305818c1a81d204 --- /dev/null +++ b/src/ledger/cloud_provider_memory_diff/validation/validation_memory_diff.cmx @@ -0,0 +1,5 @@ +{ + "program": { + "binary": "test/launch_validation_tests_memory_diff" + } +}