Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / unittests / Platform / PlatformAppleSimulatorTest.cpp
blobf30edfb9541aeb4cbd82bfb4297d6a38b6d4a125
1 //===-- PlatformAppleSimulatorTest.cpp ------------------------------------===//
2 //
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
6 //
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"
20 using namespace lldb;
21 using namespace lldb_private;
23 class PlatformAppleSimulatorTest : public ::testing::Test {
24 SubsystemRAII<FileSystem, HostInfo, PlatformAppleSimulator, PlatformRemoteiOS,
25 PlatformRemoteAppleTV, PlatformRemoteAppleWatch>
26 subsystems;
29 #ifdef __APPLE__
31 static void testSimPlatformArchHasSimEnvironment(llvm::StringRef name) {
32 auto platform_sp = Platform::Create(name);
33 ASSERT_TRUE(platform_sp);
34 int num_arches = 0;
36 for (auto arch : platform_sp->GetSupportedArchitectures({})) {
37 EXPECT_EQ(arch.GetTriple().getEnvironment(), llvm::Triple::Simulator);
38 num_arches++;
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[] = {
55 llvm::Triple::IOS,
56 llvm::Triple::TvOS,
57 llvm::Triple::WatchOS,
60 for (auto sim : sim_platforms) {
61 PlatformList list;
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[] = {
76 llvm::Triple::IOS,
77 llvm::Triple::TvOS,
78 llvm::Triple::WatchOS,
81 PlatformList list;
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);
91 Status error;
92 auto platform_sp = list.GetOrCreate(arch, {}, nullptr, error);
93 EXPECT_TRUE(platform_sp);
94 EXPECT_TRUE(platform_sp->GetName().contains("simulator"));
98 #endif