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