[Lldb-commits] [PATCH] D40475: DWZ 10/11: DWZ test mode

2018-02-25 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 135847.
jankratochvil added a comment.

> The way we do these sorts of things is that we explicitly add the category to 
> the list of skipped categories (take a look at `checkLibcxxSupport` in 
> dotest.py).

I have implemented `dwz` category like `gmodules` but even when 
`checkDWZSupport` makes `configuration.skipCategories.append("dwz")` the 
DWZ-variants of tests are still being run.  I will investigate it more.


https://reviews.llvm.org/D40475

Files:
  packages/Python/lldbsuite/test/dotest.py
  packages/Python/lldbsuite/test/lldbinline.py
  packages/Python/lldbsuite/test/lldbtest.py
  packages/Python/lldbsuite/test/make/Makefile.rules
  packages/Python/lldbsuite/test/plugins/builder_base.py
  packages/Python/lldbsuite/test/test_categories.py
  unittests/SymbolFile/CMakeLists.txt
  unittests/SymbolFile/DWZ/CMakeLists.txt
  unittests/SymbolFile/DWZ/Inputs/dwztest.c
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug
  unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz
  unittests/SymbolFile/DWZ/Inputs/dwztest.out
  unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp

Index: unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
@@ -0,0 +1,89 @@
+//===-- SymbolFileDWZTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#include 
+#endif
+
+#include 
+
+using namespace lldb_private;
+
+class SymbolFileDWZTests : public testing::Test {
+public:
+  void SetUp() override {
+// Initialize and TearDown the plugin every time, so we get a brand new
+// AST every time so that modifications to the AST from each test don't
+// leak into the next test.
+#if defined(_MSC_VER)
+::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+#endif
+
+HostInfo::Initialize();
+SymbolFileDWARF::Initialize();
+ClangASTContext::Initialize();
+ObjectFileELF::Initialize();
+SymbolVendorELF::Initialize();
+
+m_dwztest_out = GetInputFilePath("dwztest.out");
+  }
+
+  void TearDown() override {
+SymbolVendorELF::Terminate();
+ObjectFileELF::Terminate();
+ClangASTContext::Terminate();
+SymbolFileDWARF::Terminate();
+HostInfo::Terminate();
+
+#if defined(_MSC_VER)
+::CoUninitialize();
+#endif
+  }
+
+protected:
+  std::string m_dwztest_out;
+};
+
+TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) {
+  FileSpec fspec(m_dwztest_out.c_str(), false);
+  ArchSpec aspec("x86_64-pc-linux");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+
+  SymbolVendor *plugin = module->GetSymbolVendor();
+  EXPECT_NE(nullptr, plugin);
+  SymbolFile *symfile = plugin->GetSymbolFile();
+  EXPECT_NE(nullptr, symfile);
+  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+  SymbolContext sc;
+  llvm::DenseSet searched_files;
+  TypeMap results;
+  EXPECT_EQ(1u,
+  symfile->FindTypes(sc, ConstString("StructMovedToDWZCommonFile"), nullptr,
+  false, 0, searched_files, results));
+  EXPECT_EQ(1u, results.GetSize());
+  lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+  EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName());
+  CompilerType compiler_type = udt_type->GetForwardCompilerType();
+  EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType()));
+}
Index: unittests/SymbolFile/DWZ/Inputs/dwztest.c
===
--- /dev/null
+++ unittests/SymbolFile/DWZ/Inputs/dwztest.c
@@ -0,0 +1,9 @@
+// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup; /usr/lib/rpm/sepdebugcrcfix . dwztest.out 
+
+struct StructMovedToDWZCommonFile {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} VarWithStructMovedToDWZCommonFile;
+static const int sizeof_StructMovedToDWZCommonFile = sizeof(struct StructMovedToDWZCommonFile);
+int main() {
+  return sizeof_StructMovedToDWZCommonFile;
+}
Index: unittests/SymbolFile/DWZ/CMakeLists.txt
===
--- /d

[Lldb-commits] [PATCH] D40475: DWZ 10/11: DWZ test mode

2018-02-25 Thread Davide Italiano via Phabricator via lldb-commits
davide added a comment.

fwiw, you don't need unit tests or python tests to implement this.
If I understand the feature correctly you can probably extend `lldb-test` 
(which is run as part of `check-lldb-lit`).
Up to you though.


https://reviews.llvm.org/D40475



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits