blob: 7155eac1c4547c1bcdd93ede93c0107e61494692 [file] [log] [blame]
// 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.
use anyhow::Context as _;
use fidl_test_placeholders::{EchoRequest, EchoRequestStream};
use fuchsia_async as fasync;
use fuchsia_component::server::ServiceFs;
use futures::channel::mpsc;
use futures::prelude::*;
fn echo_server((send, stream): (mpsc::Sender<()>, EchoRequestStream)) -> impl Future<Output = ()> {
.try_for_each(move |EchoRequest::EchoString { value, responder }| {
let mut send = send.clone();
async move {
responder.send(value.as_ref().map(|s| &**s)).context("sending response")?;
send.send(()).await.expect("failed to send signal");
.unwrap_or_else(|e: anyhow::Error| panic!("error running echo server: {:?}", e))
async fn can_launch_test_with_gtest_v1_runner() {
let mut fs = ServiceFs::new();
let (send, mut recv) = mpsc::channel(0);
fs.add_fidl_service(move |stream| (send.clone(), stream));
let (_new_env_controller, _child_app) = fs
.expect("Cannot launch test client.");
fasync::Task::spawn(fs.for_each_concurrent(None, echo_server)).detach();"client failed to connect to echo service");