| 1 |
//===-- DebuggerTest.cpp --------------------------------------------------===// |
| 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 |
#include "lldb/Core/Debugger.h" |
| 10 |
#include "Plugins/Platform/MacOSX/PlatformMacOSX.h" |
| 11 |
#include "Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h" |
| 12 |
#include "TestingSupport/TestUtilities.h" |
| 13 |
#include "lldb/Host/FileSystem.h" |
| 14 |
#include "lldb/Host/HostInfo.h" |
| 15 |
#include "gtest/gtest.h" |
| 16 |
|
| 17 |
using namespace lldb; |
| 18 |
using namespace lldb_private; |
| 19 |
|
| 20 |
namespace { |
| 21 |
class DebuggerTest : public ::testing::Test { |
| 22 |
public: |
| 23 |
void SetUp() override { |
| 24 |
FileSystem::Initialize(); |
| 25 |
HostInfo::Initialize(); |
| 26 |
PlatformMacOSX::Initialize(); |
| 27 |
std::call_once(TestUtilities::g_debugger_initialize_flag, |
| 28 |
[]() { Debugger::Initialize(nullptr); }); |
| 29 |
ArchSpec arch("x86_64-apple-macosx-"); |
| 30 |
Platform::SetHostPlatform( |
| 31 |
PlatformRemoteMacOSX::CreateInstance(true, &arch)); |
| 32 |
} |
| 33 |
void TearDown() override { |
| 34 |
PlatformMacOSX::Terminate(); |
| 35 |
HostInfo::Terminate(); |
| 36 |
FileSystem::Terminate(); |
| 37 |
} |
| 38 |
}; |
| 39 |
} // namespace |
| 40 |
|
| 41 |
TEST_F(DebuggerTest, TestSettings) { |
| 42 |
DebuggerSP debugger_sp = Debugger::CreateInstance(); |
| 43 |
|
| 44 |
EXPECT_TRUE(debugger_sp->SetUseColor(true)); |
| 45 |
EXPECT_TRUE(debugger_sp->GetUseColor()); |
| 46 |
|
| 47 |
FormatEntity::Entry format("foo"); |
| 48 |
EXPECT_TRUE(debugger_sp->SetStatuslineFormat(format)); |
| 49 |
EXPECT_EQ(debugger_sp->GetStatuslineFormat().string, "foo"); |
| 50 |
|
| 51 |
Debugger::Destroy(debugger_sp); |
| 52 |
} |