diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:04:10 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:04:10 +0000 |
| commit | 74a628f776edb588bff8f8f5cc16eac947c9d631 (patch) | |
| tree | dc32e010ac4902621e5a279bfeb48628f7f0e166 /unittests/Process | |
| parent | afed7be32164a598f8172282c249af7266c48b46 (diff) | |
Notes
Diffstat (limited to 'unittests/Process')
6 files changed, 95 insertions, 31 deletions
diff --git a/unittests/Process/gdb-remote/CMakeLists.txt b/unittests/Process/gdb-remote/CMakeLists.txt index de4cac11b233..694ba182d42f 100644 --- a/unittests/Process/gdb-remote/CMakeLists.txt +++ b/unittests/Process/gdb-remote/CMakeLists.txt @@ -2,4 +2,13 @@ add_lldb_unittest(ProcessGdbRemoteTests GDBRemoteClientBaseTest.cpp GDBRemoteCommunicationClientTest.cpp GDBRemoteTestUtils.cpp + + LINK_LIBS + lldbCore + lldbHost + lldbPluginPlatformMacOSX + lldbPluginProcessUtility + lldbPluginProcessGDBRemote + LINK_COMPONENTS + Support ) diff --git a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp index 2cfd52f5767a..5e709815b2d5 100644 --- a/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp @@ -6,13 +6,6 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// - -#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0) -// Workaround for MSVC standard library bug, which fails to include <thread> -// when -// exceptions are disabled. -#include <eh.h> -#endif #include <future> #include "GDBRemoteTestUtils.h" @@ -20,7 +13,7 @@ #include "Plugins/Process/Utility/LinuxSignals.h" #include "Plugins/Process/gdb-remote/GDBRemoteClientBase.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.h" -#include "lldb/Core/StreamGDBRemote.h" +#include "lldb/Utility/StreamGDBRemote.h" #include "llvm/ADT/STLExtras.h" diff --git a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp index 4bac9ebd404f..d1eb3a7e9c9e 100644 --- a/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp @@ -6,21 +6,15 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// - -#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0) -// Workaround for MSVC standard library bug, which fails to include <thread> -// when -// exceptions are disabled. -#include <eh.h> -#endif #include <future> #include "GDBRemoteTestUtils.h" #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h" -#include "lldb/Core/DataBuffer.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/StructuredData.h" +#include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/DataBuffer.h" #include "llvm/ADT/ArrayRef.h" @@ -298,6 +292,7 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) { client.Disconnect(); server_thread.join(); + GTEST_LOG_(INFO) << "Formatted output: " << ss.GetData(); auto object_sp = StructuredData::ParseJSON(ss.GetString()); ASSERT_TRUE(bool(object_sp)); auto dict_sp = object_sp->GetAsDictionary(); @@ -313,3 +308,65 @@ TEST_F(GDBRemoteCommunicationClientTest, TestPacketSpeedJSON) { << ss.GetString(); ASSERT_EQ(10, num_packets); } + +TEST_F(GDBRemoteCommunicationClientTest, SendSignalsToIgnore) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::tid_t tid = 0x47; + const uint32_t reg_num = 4; + std::future<Error> result = std::async(std::launch::async, [&] { + return client.SendSignalsToIgnore({2, 3, 5, 7, 0xB, 0xD, 0x11}); + }); + + HandlePacket(server, "QPassSignals:02;03;05;07;0b;0d;11", "OK"); + EXPECT_TRUE(result.get().Success()); + + result = std::async(std::launch::async, [&] { + return client.SendSignalsToIgnore(std::vector<int32_t>()); + }); + + HandlePacket(server, "QPassSignals:", "OK"); + EXPECT_TRUE(result.get().Success()); +} + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfo) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0xa000; + MemoryRegionInfo region_info; + std::future<Error> result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + // name is: /foo/bar.so + HandlePacket(server, + "qMemoryRegionInfo:a000", + "start:a000;size:2000;permissions:rx;name:2f666f6f2f6261722e736f;"); + EXPECT_TRUE(result.get().Success()); + +} + +TEST_F(GDBRemoteCommunicationClientTest, GetMemoryRegionInfoInvalidResponse) { + TestClient client; + MockServer server; + Connect(client, server); + if (HasFailure()) + return; + + const lldb::addr_t addr = 0x4000; + MemoryRegionInfo region_info; + std::future<Error> result = std::async(std::launch::async, [&] { + return client.GetMemoryRegionInfo(addr, region_info); + }); + + HandlePacket(server, "qMemoryRegionInfo:4000", "start:4000;size:0000;"); + EXPECT_FALSE(result.get().Success()); +} diff --git a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp index 58cc9f50586a..08501f50f65a 100644 --- a/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp +++ b/unittests/Process/gdb-remote/GDBRemoteTestUtils.cpp @@ -7,13 +7,6 @@ // //===----------------------------------------------------------------------===// -#if defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0) -// Workaround for MSVC standard library bug, which fails to include <thread> -// when -// exceptions are disabled. -#include <eh.h> -#endif - #include "GDBRemoteTestUtils.h" #include "lldb/Host/common/TCPSocket.h" diff --git a/unittests/Process/minidump/CMakeLists.txt b/unittests/Process/minidump/CMakeLists.txt index 10cb8c34f352..2b2df6327e9a 100644 --- a/unittests/Process/minidump/CMakeLists.txt +++ b/unittests/Process/minidump/CMakeLists.txt @@ -1,5 +1,14 @@ add_lldb_unittest(LLDBMinidumpTests MinidumpParserTest.cpp + + LINK_LIBS + lldbCore + lldbHost + lldbTarget + lldbPluginProcessUtility + lldbPluginProcessMinidump + LINK_COMPONENTS + Support ) set(test_inputs diff --git a/unittests/Process/minidump/MinidumpParserTest.cpp b/unittests/Process/minidump/MinidumpParserTest.cpp index 83225e88ee03..755095f75918 100644 --- a/unittests/Process/minidump/MinidumpParserTest.cpp +++ b/unittests/Process/minidump/MinidumpParserTest.cpp @@ -19,13 +19,15 @@ #include "gtest/gtest.h" #include "lldb/Core/ArchSpec.h" -#include "lldb/Core/DataExtractor.h" -#include "lldb/Host/FileSpec.h" #include "lldb/Target/MemoryRegionInfo.h" +#include "lldb/Utility/DataBufferLLVM.h" +#include "lldb/Utility/DataExtractor.h" +#include "lldb/Utility/FileSpec.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" // C includes @@ -46,14 +48,15 @@ public: llvm::sys::path::append(inputs_folder, "Inputs"); } - void SetUpData(const char *minidump_filename, size_t load_size = SIZE_MAX) { + void SetUpData(const char *minidump_filename, + uint64_t load_size = UINT64_MAX) { llvm::SmallString<128> filename = inputs_folder; llvm::sys::path::append(filename, minidump_filename); - FileSpec minidump_file(filename.c_str(), false); - lldb::DataBufferSP data_sp( - minidump_file.MemoryMapFileContents(0, load_size)); + + auto BufferPtr = DataBufferLLVM::CreateSliceFromPath(filename, load_size, 0); + llvm::Optional<MinidumpParser> optional_parser = - MinidumpParser::Create(data_sp); + MinidumpParser::Create(BufferPtr); ASSERT_TRUE(optional_parser.hasValue()); parser.reset(new MinidumpParser(optional_parser.getValue())); ASSERT_GT(parser->GetData().size(), 0UL); @@ -450,4 +453,4 @@ TEST_F(MinidumpParserTest, ConvertMinidumpContext_x86_32_wow64) { REG_VAL32(buf->GetBytes() + reg_info[reg_index].byte_offset)); } } -}
\ No newline at end of file +} |
