| 1 |
//===-- TestBase.h ----------------------------------------------*- C++ -*-===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
#ifndef LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H |
| 10 |
#define LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H |
| 11 |
|
| 12 |
#include "TestClient.h" |
| 13 |
#include "lldb/Host/FileSystem.h" |
| 14 |
#include "lldb/Host/HostInfo.h" |
| 15 |
#include "lldb/Host/Socket.h" |
| 16 |
#include "llvm/Support/Path.h" |
| 17 |
#include "llvm/Testing/Support/Error.h" |
| 18 |
#include "gtest/gtest.h" |
| 19 |
|
| 20 |
namespace llgs_tests { |
| 21 |
|
| 22 |
class TestBase: public ::testing::Test { |
| 23 |
public: |
| 24 |
static void SetUpTestCase() { |
| 25 |
lldb_private::FileSystem::Initialize(); |
| 26 |
lldb_private::HostInfo::Initialize(); |
| 27 |
ASSERT_THAT_ERROR(lldb_private::Socket::Initialize(), llvm::Succeeded()); |
| 28 |
} |
| 29 |
|
| 30 |
static void TearDownTestCase() { |
| 31 |
lldb_private::Socket::Terminate(); |
| 32 |
lldb_private::HostInfo::Terminate(); |
| 33 |
lldb_private::FileSystem::Terminate(); |
| 34 |
} |
| 35 |
|
| 36 |
static std::string getInferiorPath(llvm::StringRef Name) { |
| 37 |
llvm::SmallString<64> Path(LLDB_TEST_INFERIOR_PATH); |
| 38 |
llvm::sys::path::append(Path, Name + LLDB_TEST_INFERIOR_SUFFIX); |
| 39 |
return std::string(Path.str()); |
| 40 |
} |
| 41 |
|
| 42 |
static std::string getLogFileName(); |
| 43 |
}; |
| 44 |
|
| 45 |
class StandardStartupTest: public TestBase { |
| 46 |
public: |
| 47 |
void SetUp() override { |
| 48 |
auto ClientOr = TestClient::launch(getLogFileName()); |
| 49 |
ASSERT_THAT_EXPECTED(ClientOr, llvm::Succeeded()); |
| 50 |
Client = std::move(*ClientOr); |
| 51 |
} |
| 52 |
|
| 53 |
protected: |
| 54 |
std::unique_ptr<TestClient> Client; |
| 55 |
}; |
| 56 |
|
| 57 |
} // namespace llgs_tests |
| 58 |
|
| 59 |
#endif // LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H |