blob: 777f860fc58487abc92ed178d9409a6a183bfb89 [file] [log] [blame]
// 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 GARNET_BIN_GUEST_INTEGRATION_TEST_SERIAL_H_
#define GARNET_BIN_GUEST_INTEGRATION_TEST_SERIAL_H_
#include <string>
#include <lib/zx/socket.h>
class TestSerial {
public:
zx_status_t Start(zx::socket socket);
// Executes a command and waits for a response. Uses a header and a footer to
// ensure the command finished executing and to capture output. Blocks on the
// serial socket being writable and readable at various points and on the
// command completing.
zx_status_t ExecuteBlocking(const std::string& command, const std::string& prompt,
std::string* result = nullptr);
private:
zx_status_t SendBlocking(const std::string& message);
zx_status_t WaitForMarker(const std::string& marker,
std::string* result = nullptr);
zx_status_t WaitForAny();
zx_status_t Drain();
zx::socket socket_;
std::string buffer_;
};
#endif // GARNET_BIN_GUEST_INTEGRATION_TEST_SERIAL_H_