1671d3e63SPavel Labath //===-- TestBase.h ----------------------------------------------*- C++ -*-===// 2671d3e63SPavel Labath // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6671d3e63SPavel Labath // 7671d3e63SPavel Labath //===----------------------------------------------------------------------===// 8671d3e63SPavel Labath 9*cdc514e4SJonas Devlieghere #ifndef LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H 10*cdc514e4SJonas Devlieghere #define LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H 11671d3e63SPavel Labath 12671d3e63SPavel Labath #include "TestClient.h" 133fbdde31SPavel Labath #include "lldb/Host/FileSystem.h" 14671d3e63SPavel Labath #include "lldb/Host/HostInfo.h" 155146a9eaSAaron Smith #include "lldb/Host/Socket.h" 16671d3e63SPavel Labath #include "llvm/Support/Path.h" 17671d3e63SPavel Labath #include "llvm/Testing/Support/Error.h" 18671d3e63SPavel Labath #include "gtest/gtest.h" 19671d3e63SPavel Labath 20671d3e63SPavel Labath namespace llgs_tests { 21671d3e63SPavel Labath 22671d3e63SPavel Labath class TestBase: public ::testing::Test { 23671d3e63SPavel Labath public: SetUpTestCase()243fbdde31SPavel Labath static void SetUpTestCase() { 253fbdde31SPavel Labath lldb_private::FileSystem::Initialize(); 263fbdde31SPavel Labath lldb_private::HostInfo::Initialize(); 275146a9eaSAaron Smith ASSERT_THAT_ERROR(lldb_private::Socket::Initialize(), llvm::Succeeded()); 283fbdde31SPavel Labath } 29671d3e63SPavel Labath TearDownTestCase()30dab879d7SAntonio Afonso static void TearDownTestCase() { 315146a9eaSAaron Smith lldb_private::Socket::Terminate(); 32dab879d7SAntonio Afonso lldb_private::HostInfo::Terminate(); 33dab879d7SAntonio Afonso lldb_private::FileSystem::Terminate(); 34dab879d7SAntonio Afonso } 35dab879d7SAntonio Afonso getInferiorPath(llvm::StringRef Name)36671d3e63SPavel Labath static std::string getInferiorPath(llvm::StringRef Name) { 37671d3e63SPavel Labath llvm::SmallString<64> Path(LLDB_TEST_INFERIOR_PATH); 38671d3e63SPavel Labath llvm::sys::path::append(Path, Name + LLDB_TEST_INFERIOR_SUFFIX); 39777180a3SBenjamin Kramer return std::string(Path.str()); 40671d3e63SPavel Labath } 41671d3e63SPavel Labath 42671d3e63SPavel Labath static std::string getLogFileName(); 43671d3e63SPavel Labath }; 44671d3e63SPavel Labath 45671d3e63SPavel Labath class StandardStartupTest: public TestBase { 46671d3e63SPavel Labath public: SetUp()47671d3e63SPavel Labath void SetUp() override { 48671d3e63SPavel Labath auto ClientOr = TestClient::launch(getLogFileName()); 49671d3e63SPavel Labath ASSERT_THAT_EXPECTED(ClientOr, llvm::Succeeded()); 50671d3e63SPavel Labath Client = std::move(*ClientOr); 51671d3e63SPavel Labath } 52671d3e63SPavel Labath 53671d3e63SPavel Labath protected: 54671d3e63SPavel Labath std::unique_ptr<TestClient> Client; 55671d3e63SPavel Labath }; 56671d3e63SPavel Labath 57671d3e63SPavel Labath } // namespace llgs_tests 58671d3e63SPavel Labath 59*cdc514e4SJonas Devlieghere #endif // LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H 60