[Lldb-commits] [lldb] 9097920 - [lldb] Add a test to prefer exact triple matches in platform selection
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 11 16:35:56 PDT 2022
Author: Jonas Devlieghere
Date: 2022-07-11T16:35:51-07:00
New Revision: 9097920ebabb6ab29f94e4051572c42459edcda8
URL: https://github.com/llvm/llvm-project/commit/9097920ebabb6ab29f94e4051572c42459edcda8
DIFF: https://github.com/llvm/llvm-project/commit/9097920ebabb6ab29f94e4051572c42459edcda8.diff
LOG: [lldb] Add a test to prefer exact triple matches in platform selection
Add a test that ensures we always prioritize exact triple matches when
creating platforms. This is a regression test for a (now resolved) bug
that that resulted in the remote tvOS platform being selected for a tvOS
simulator binary because the ArchSpecs are compatible.
Added:
Modified:
lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
Removed:
################################################################################
diff --git a/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp b/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
index 7cb07cbe55d35..f30edfb9541ae 100644
--- a/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
+++ b/lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp
@@ -9,6 +9,9 @@
#include "gtest/gtest.h"
#include "Plugins/Platform/MacOSX/PlatformAppleSimulator.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
#include "TestingSupport/SubsystemRAII.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/HostInfo.h"
@@ -18,7 +21,8 @@ using namespace lldb;
using namespace lldb_private;
class PlatformAppleSimulatorTest : public ::testing::Test {
- SubsystemRAII<FileSystem, HostInfo, PlatformAppleSimulator>
+ SubsystemRAII<FileSystem, HostInfo, PlatformAppleSimulator, PlatformRemoteiOS,
+ PlatformRemoteAppleTV, PlatformRemoteAppleWatch>
subsystems;
};
@@ -64,4 +68,31 @@ TEST_F(PlatformAppleSimulatorTest, TestHostPlatformToSim) {
}
}
+TEST_F(PlatformAppleSimulatorTest, TestPlatformSelectionOrder) {
+ static const ArchSpec platform_arch(
+ HostInfo::GetArchitecture(HostInfo::eArchKindDefault));
+
+ const llvm::Triple::OSType sim_platforms[] = {
+ llvm::Triple::IOS,
+ llvm::Triple::TvOS,
+ llvm::Triple::WatchOS,
+ };
+
+ PlatformList list;
+ list.GetOrCreate("remote-ios");
+ list.GetOrCreate("remote-tvos");
+ list.GetOrCreate("remote-watchos");
+
+ for (auto sim : sim_platforms) {
+ ArchSpec arch = platform_arch;
+ arch.GetTriple().setOS(sim);
+ arch.GetTriple().setEnvironment(llvm::Triple::Simulator);
+
+ Status error;
+ auto platform_sp = list.GetOrCreate(arch, {}, nullptr, error);
+ EXPECT_TRUE(platform_sp);
+ EXPECT_TRUE(platform_sp->GetName().contains("simulator"));
+ }
+}
+
#endif
More information about the lldb-commits
mailing list