1 //===-- PlatformAppleSimulatorTest.cpp ------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "gtest/gtest.h"
11 #include "Plugins/Platform/MacOSX/PlatformAppleSimulator.h"
12 #include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h"
13 #include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
14 #include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
15 #include "TestingSupport/SubsystemRAII.h"
16 #include "lldb/Host/FileSystem.h"
17 #include "lldb/Host/HostInfo.h"
18 #include "lldb/Target/Platform.h"
21 using namespace lldb_private
;
23 class PlatformAppleSimulatorTest
: public ::testing::Test
{
24 SubsystemRAII
<FileSystem
, HostInfo
, PlatformAppleSimulator
, PlatformRemoteiOS
,
25 PlatformRemoteAppleTV
, PlatformRemoteAppleWatch
>
31 static void testSimPlatformArchHasSimEnvironment(llvm::StringRef name
) {
32 auto platform_sp
= Platform::Create(name
);
33 ASSERT_TRUE(platform_sp
);
36 for (auto arch
: platform_sp
->GetSupportedArchitectures({})) {
37 EXPECT_EQ(arch
.GetTriple().getEnvironment(), llvm::Triple::Simulator
);
41 EXPECT_GT(num_arches
, 0);
44 TEST_F(PlatformAppleSimulatorTest
, TestSimHasSimEnvionament
) {
45 testSimPlatformArchHasSimEnvironment("ios-simulator");
46 testSimPlatformArchHasSimEnvironment("tvos-simulator");
47 testSimPlatformArchHasSimEnvironment("watchos-simulator");
50 TEST_F(PlatformAppleSimulatorTest
, TestHostPlatformToSim
) {
51 static const ArchSpec
platform_arch(
52 HostInfo::GetArchitecture(HostInfo::eArchKindDefault
));
54 const llvm::Triple::OSType sim_platforms
[] = {
57 llvm::Triple::WatchOS
,
60 for (auto sim
: sim_platforms
) {
62 ArchSpec arch
= platform_arch
;
63 arch
.GetTriple().setOS(sim
);
64 arch
.GetTriple().setEnvironment(llvm::Triple::Simulator
);
66 auto platform_sp
= list
.GetOrCreate(arch
, {}, nullptr);
67 EXPECT_TRUE(platform_sp
);
71 TEST_F(PlatformAppleSimulatorTest
, TestPlatformSelectionOrder
) {
72 static const ArchSpec
platform_arch(
73 HostInfo::GetArchitecture(HostInfo::eArchKindDefault
));
75 const llvm::Triple::OSType sim_platforms
[] = {
78 llvm::Triple::WatchOS
,
82 list
.GetOrCreate("remote-ios");
83 list
.GetOrCreate("remote-tvos");
84 list
.GetOrCreate("remote-watchos");
86 for (auto sim
: sim_platforms
) {
87 ArchSpec arch
= platform_arch
;
88 arch
.GetTriple().setOS(sim
);
89 arch
.GetTriple().setEnvironment(llvm::Triple::Simulator
);
92 auto platform_sp
= list
.GetOrCreate(arch
, {}, nullptr, error
);
93 EXPECT_TRUE(platform_sp
);
94 EXPECT_TRUE(platform_sp
->GetName().contains("simulator"));