blob: e34e3243cfca79916ed412df1ca202c7bf372486 [file] [log] [blame]
// Copyright 2020 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 SRC_STORAGE_FSHOST_TESTING_FSHOST_INTEGRATION_TEST_H_
#define SRC_STORAGE_FSHOST_TESTING_FSHOST_INTEGRATION_TEST_H_
#include <fidl/fuchsia.component/cpp/wire.h>
#include <fidl/fuchsia.fshost/cpp/wire.h>
#include <fidl/fuchsia.io/cpp/wire.h>
#include <lib/fdio/directory.h>
#include <string_view>
#include <fbl/unique_fd.h>
#include <gtest/gtest.h>
namespace fshost::testing {
class FshostIntegrationTest : public ::testing::Test {
public:
void SetUp() override;
void TearDown() override;
void ResetFshost();
std::string DataFilesystemFormat() const;
std::string FshostComponentName() const;
std::string FshostComponentCollection() const;
const fidl::WireSyncClient<fuchsia_io::Directory>& exposed_dir() const { return exposed_dir_; }
const fidl::WireSyncClient<fuchsia_fshost::BlockWatcher>& block_watcher() const {
return block_watcher_;
}
void PauseWatcher() const;
void ResumeWatcher() const;
// Waits for a mount to happen at the given toplevel path. If successful returns a file
// descriptor opened on the root and the filesystem type (VFS_TYPE_MINFS, etc.).
//
// Times out after 10s.
std::pair<fbl::unique_fd, uint64_t> WaitForMount(const std::string& name);
private:
fidl::WireSyncClient<fuchsia_io::Directory> exposed_dir_;
fidl::WireSyncClient<fuchsia_component::Realm> realm_;
fidl::WireSyncClient<fuchsia_fshost::BlockWatcher> block_watcher_;
};
} // namespace fshost::testing
#endif // SRC_STORAGE_FSHOST_TESTING_FSHOST_INTEGRATION_TEST_H_