[Lldb-commits] [lldb] cf521e7 - [lldb] Add tests for TypeSystemMap::GetTypeSystemForLanguage
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Mon Aug 16 09:00:22 PDT 2021
Author: Raphael Isemann
Date: 2021-08-16T18:00:01+02:00
New Revision: cf521e78dfd2a418970358e5d55dcc9a862664e5
URL: https://github.com/llvm/llvm-project/commit/cf521e78dfd2a418970358e5d55dcc9a862664e5
DIFF: https://github.com/llvm/llvm-project/commit/cf521e78dfd2a418970358e5d55dcc9a862664e5.diff
LOG: [lldb] Add tests for TypeSystemMap::GetTypeSystemForLanguage
Regression tests for D108088 .
Reviewed By: mib
Differential Revision: https://reviews.llvm.org/D108121
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 lldb-commits
mailing list