1 //===-- TestBase.h ----------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H
10 #define LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H
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"
20 namespace llgs_tests
{
22 class TestBase
: public ::testing::Test
{
24 static void SetUpTestCase() {
25 lldb_private::FileSystem::Initialize();
26 lldb_private::HostInfo::Initialize();
27 ASSERT_THAT_ERROR(lldb_private::Socket::Initialize(), llvm::Succeeded());
30 static void TearDownTestCase() {
31 lldb_private::Socket::Terminate();
32 lldb_private::HostInfo::Terminate();
33 lldb_private::FileSystem::Terminate();
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());
42 static std::string
getLogFileName();
45 class StandardStartupTest
: public TestBase
{
47 void SetUp() override
{
48 auto ClientOr
= TestClient::launch(getLogFileName());
49 ASSERT_THAT_EXPECTED(ClientOr
, llvm::Succeeded());
50 Client
= std::move(*ClientOr
);
54 std::unique_ptr
<TestClient
> Client
;
57 } // namespace llgs_tests
59 #endif // LLDB_UNITTESTS_TOOLS_LLDB_SERVER_TESTS_TESTBASE_H