[llvm-branch-commits] [lldb] 10a4a86 - [lldb] Add tests for TypeSystemMap::GetTypeSystemForLanguage

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 19 21:49:36 PDT 2021


Author: Raphael Isemann
Date: 2021-08-19T21:49:18-07:00
New Revision: 10a4a861837dc97dc4c75f1b9e33213b547dc24b

URL: https://github.com/llvm/llvm-project/commit/10a4a861837dc97dc4c75f1b9e33213b547dc24b
DIFF: https://github.com/llvm/llvm-project/commit/10a4a861837dc97dc4c75f1b9e33213b547dc24b.diff

LOG: [lldb] Add tests for TypeSystemMap::GetTypeSystemForLanguage

Regression tests for D108088 .

Reviewed By: mib

Differential Revision: https://reviews.llvm.org/D108121

(cherry picked from commit cf521e78dfd2a418970358e5d55dcc9a862664e5)

Added: 
    lldb/unittests/Symbol/TestTypeSystem.cpp

Modified: 
    lldb/unittests/Symbol/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/lldb/unittests/Symbol/CMakeLists.txt b/lldb/unittests/Symbol/CMakeLists.txt
index 76c7b645f277a..748faf33b556b 100644
--- a/lldb/unittests/Symbol/CMakeLists.txt
+++ b/lldb/unittests/Symbol/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_lldb_unittest(SymbolTests
   LocateSymbolFileTest.cpp
   PostfixExpressionTest.cpp
+  TestTypeSystem.cpp
   TestTypeSystemClang.cpp
   TestClangASTImporter.cpp
   TestDWARFCallFrameInfo.cpp

diff  --git a/lldb/unittests/Symbol/TestTypeSystem.cpp b/lldb/unittests/Symbol/TestTypeSystem.cpp
new file mode 100644
index 0000000000000..59297a7475d27
--- /dev/null
+++ b/lldb/unittests/Symbol/TestTypeSystem.cpp
@@ -0,0 +1,92 @@
+//===-- TestTypeSystem.cpp -------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "TestingSupport/SubsystemRAII.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/TypeSystem.h"
+#include "gtest/gtest.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+class TestTypeSystemMap : public testing::Test {
+public:
+  SubsystemRAII<FileSystem, HostInfo> subsystems;
+};
+
+TEST_F(TestTypeSystemMap, GetTypeSystemForLanguageWithInvalidModule) {
+  // GetTypeSystemForLanguage called with an invalid Module.
+  TypeSystemMap map;
+  Module module{ModuleSpec()};
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeUnknown, &module,
+                                   /*can_create=*/true),
+      llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
+
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeUnknown, &module,
+                                   /*can_create=*/false),
+      llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
+
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeC, &module,
+                                   /*can_create=*/true),
+      llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeC, &module,
+                                   /*can_create=*/false),
+      llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
+}
+
+TEST_F(TestTypeSystemMap, GetTypeSystemForLanguageWithNoModule) {
+  // GetTypeSystemForLanguage called with no Module.
+  TypeSystemMap map;
+  Module *module = nullptr;
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeUnknown, module,
+                                   /*can_create=*/true),
+      llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
+
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeUnknown, module,
+                                   /*can_create=*/false),
+      llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
+
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeC, module, /*can_create=*/true),
+      llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeC, module,
+                                   /*can_create=*/false),
+      llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
+}
+
+TEST_F(TestTypeSystemMap, GetTypeSystemForLanguageWithNoTarget) {
+  // GetTypeSystemForLanguage called with no Target.
+  TypeSystemMap map;
+  Target *target = nullptr;
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeUnknown, target,
+                                   /*can_create=*/true),
+      llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
+
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeUnknown, target,
+                                   /*can_create=*/false),
+      llvm::FailedWithMessage("TypeSystem for language unknown doesn't exist"));
+
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeC, target, /*can_create=*/true),
+      llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
+  EXPECT_THAT_EXPECTED(
+      map.GetTypeSystemForLanguage(eLanguageTypeC, target,
+                                   /*can_create=*/false),
+      llvm::FailedWithMessage("TypeSystem for language c doesn't exist"));
+}


        


More information about the llvm-branch-commits mailing list