Author: labath Date: Thu Jun 28 07:23:04 2018 New Revision: 335859 URL: http://llvm.org/viewvc/llvm-project?rev=335859&view=rev Log: Skip core file tests on build configurations lacking necessary components
Summary: To successfully open a core file, we need to have LLVM built with support for the relevant target. Right now, if one does not have the appropriate targets configured, the tests will fail. This patch uses the GetBuildConfiguration SB API to inform the test (and anyone else who cares) about the list of supported LLVM targets. The test then uses this information to approriately skip the tests. Reviewers: clayborg, jingham Subscribers: martong, lldb-commits Differential Revision: https://reviews.llvm.org/D48641 Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=335859&r1=335858&r2=335859&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Thu Jun 28 07:23:04 2018 @@ -783,6 +783,17 @@ def skipIfXmlSupportMissing(func): have_xml = xml.GetValueForKey("value").GetBooleanValue(fail_value) return unittest2.skipIf(not have_xml, "requires xml support")(func) +def skipIfLLVMTargetMissing(target): + config = lldb.SBDebugger.GetBuildConfiguration() + targets = config.GetValueForKey("targets").GetValueForKey("value") + found = False + for i in range(targets.GetSize()): + if targets.GetItemAtIndex(i).GetStringValue(99) == target: + found = True + break + + return unittest2.skipIf(not found, "requires " + target) + # Call sysctl on darwin to see if a specified hardware feature is available on this machine. def skipUnlessFeature(feature): def is_feature_enabled(self): Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py?rev=335859&r1=335858&r2=335859&view=diff ============================================================================== --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/postmortem/elf-core/TestLinuxCore.py Thu Jun 28 07:23:04 2018 @@ -42,23 +42,27 @@ class LinuxCoreTestCase(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_i386(self): """Test that lldb can read the process information from an i386 linux core file.""" self.do_test("linux-i386", self._i386_pid, self._i386_regions, "a.out") @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_o32(self): """Test that lldb can read the process information from an MIPS O32 linux core file.""" self.do_test("linux-mipsel-gnuabio32", self._mips_o32_pid, self._mips_regions, "linux-mipsel-gn") @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_n32(self): """Test that lldb can read the process information from an MIPS N32 linux core file """ self.do_test("linux-mips64el-gnuabin32", self._mips64_n32_pid, self._mips_regions, "linux-mips64el-") @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) + @skipIfLLVMTargetMissing("Mips") def test_mips_n64(self): """Test that lldb can read the process information from an MIPS N64 linux core file """ self.do_test("linux-mips64el-gnuabi64", self._mips64_n64_pid, @@ -66,6 +70,7 @@ class LinuxCoreTestCase(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("PowerPC") def test_ppc64le(self): """Test that lldb can read the process information from an ppc64le linux core file.""" self.do_test("linux-ppc64le", self._ppc64le_pid, self._ppc64le_regions, @@ -73,6 +78,7 @@ class LinuxCoreTestCase(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_x86_64(self): """Test that lldb can read the process information from an x86_64 linux core file.""" self.do_test("linux-x86_64", self._x86_64_pid, self._x86_64_regions, @@ -80,6 +86,7 @@ class LinuxCoreTestCase(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("SystemZ") def test_s390x(self): """Test that lldb can read the process information from an s390x linux core file.""" self.do_test("linux-s390x", self._s390x_pid, self._s390x_regions, @@ -87,6 +94,7 @@ class LinuxCoreTestCase(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_same_pid_running(self): """Test that we read the information from the core correctly even if we have a running process with the same PID around""" @@ -115,6 +123,7 @@ class LinuxCoreTestCase(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_two_cores_same_pid(self): """Test that we handle the situation if we have two core files with the same PID around""" @@ -145,6 +154,7 @@ class LinuxCoreTestCase(TestBase): @expectedFailureAll(bugnumber="llvm.org/pr37371", hostoslist=["windows"]) @skipIf(triple='^mips') + @skipIfLLVMTargetMissing("X86") def test_FPR_SSE(self): # check x86_64 core file target = self.dbg.CreateTarget(None) Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=335859&r1=335858&r2=335859&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Thu Jun 28 07:23:04 2018 @@ -500,11 +500,23 @@ static void AddBoolConfigEntry(Structure dict.AddItem(name, std::move(entry_up)); } +static void AddLLVMTargets(StructuredData::Dictionary &dict) { + auto array_up = llvm::make_unique<StructuredData::Array>(); +#define LLVM_TARGET(target) \ + array_up->AddItem(llvm::make_unique<StructuredData::String>(#target)); +#include "llvm/Config/Targets.def" + auto entry_up = llvm::make_unique<StructuredData::Dictionary>(); + entry_up->AddItem("value", std::move(array_up)); + entry_up->AddStringItem("description", "A list of configured LLVM targets."); + dict.AddItem("targets", std::move(entry_up)); +} + SBStructuredData SBDebugger::GetBuildConfiguration() { auto config_up = llvm::make_unique<StructuredData::Dictionary>(); AddBoolConfigEntry( *config_up, "xml", XMLDocument::XMLEnabled(), "A boolean value that indicates if XML support is enabled in LLDB"); + AddLLVMTargets(*config_up); SBStructuredData data; data.m_impl_up->SetObjectSP(std::move(config_up)); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits