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 //===----------------------------------------------------------------------===// 8 9 #include "gtest/gtest.h" 10 11 #include "Plugins/Platform/MacOSX/PlatformAppleSimulator.h" 12 #include "TestingSupport/SubsystemRAII.h" 13 #include "lldb/Host/FileSystem.h" 14 #include "lldb/Host/HostInfo.h" 15 #include "lldb/Target/Platform.h" 16 17 using namespace lldb; 18 using namespace lldb_private; 19 20 class PlatformAppleSimulatorTest : public ::testing::Test { 21 SubsystemRAII<FileSystem, HostInfo, PlatformAppleSimulator> 22 subsystems; 23 }; 24 25 #ifdef __APPLE__ 26 27 static void testSimPlatformArchHasSimEnvironment(llvm::StringRef name) { 28 Status error; 29 auto platform_sp = Platform::Create(ConstString(name), error); 30 ASSERT_TRUE(platform_sp); 31 int num_arches = 0; 32 33 for (auto arch : platform_sp->GetSupportedArchitectures()) { 34 EXPECT_EQ(arch.GetTriple().getEnvironment(), llvm::Triple::Simulator); 35 num_arches++; 36 } 37 38 EXPECT_GT(num_arches, 0); 39 } 40 41 TEST_F(PlatformAppleSimulatorTest, TestSimHasSimEnvionament) { 42 testSimPlatformArchHasSimEnvironment("ios-simulator"); 43 testSimPlatformArchHasSimEnvironment("tvos-simulator"); 44 testSimPlatformArchHasSimEnvironment("watchos-simulator"); 45 } 46 47 TEST_F(PlatformAppleSimulatorTest, TestHostPlatformToSim) { 48 static const ArchSpec platform_arch( 49 HostInfo::GetArchitecture(HostInfo::eArchKindDefault)); 50 51 const llvm::Triple::OSType sim_platforms[] = { 52 llvm::Triple::IOS, 53 llvm::Triple::TvOS, 54 llvm::Triple::WatchOS, 55 }; 56 57 for (auto sim : sim_platforms) { 58 ArchSpec arch = platform_arch; 59 arch.GetTriple().setOS(sim); 60 arch.GetTriple().setEnvironment(llvm::Triple::Simulator); 61 62 Status error; 63 auto platform_sp = Platform::Create(arch, nullptr, error); 64 EXPECT_TRUE(platform_sp); 65 } 66 } 67 68 #endif 69