| 1 |
//===---------- MachOPlatformTest.cpp - MachPlatform API Tests ------------===// |
| 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 "llvm/ExecutionEngine/Orc/MachOPlatform.h" |
| 10 |
#include "llvm/BinaryFormat/MachO.h" |
| 11 |
#include "gtest/gtest.h" |
| 12 |
|
| 13 |
using namespace llvm; |
| 14 |
using namespace llvm::orc; |
| 15 |
|
| 16 |
TEST(MachOPlatformTests, BuildVersionOptsFromTriple) { |
| 17 |
|
| 18 |
auto darwinOS = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 19 |
Triple("arm64-apple-darwin"), 0, 0); |
| 20 |
EXPECT_FALSE(darwinOS); |
| 21 |
|
| 22 |
auto macOS = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 23 |
Triple("arm64-apple-macosx"), 0, 0); |
| 24 |
EXPECT_TRUE(macOS); |
| 25 |
EXPECT_EQ(macOS->Platform, MachO::PLATFORM_MACOS); |
| 26 |
|
| 27 |
auto iOS = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 28 |
Triple("arm64-apple-ios"), 0, 0); |
| 29 |
EXPECT_TRUE(iOS); |
| 30 |
EXPECT_EQ(iOS->Platform, MachO::PLATFORM_IOS); |
| 31 |
|
| 32 |
auto iOSSim = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 33 |
Triple("arm64-apple-ios-simulator"), 0, 0); |
| 34 |
EXPECT_TRUE(iOSSim); |
| 35 |
EXPECT_EQ(iOSSim->Platform, MachO::PLATFORM_IOSSIMULATOR); |
| 36 |
|
| 37 |
auto tvOS = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 38 |
Triple("arm64-apple-tvos"), 0, 0); |
| 39 |
EXPECT_TRUE(tvOS); |
| 40 |
EXPECT_EQ(tvOS->Platform, MachO::PLATFORM_TVOS); |
| 41 |
|
| 42 |
auto tvOSSim = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 43 |
Triple("arm64-apple-tvos-simulator"), 0, 0); |
| 44 |
EXPECT_TRUE(tvOSSim); |
| 45 |
EXPECT_EQ(tvOSSim->Platform, MachO::PLATFORM_TVOSSIMULATOR); |
| 46 |
|
| 47 |
auto watchOS = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 48 |
Triple("arm64-apple-watchos"), 0, 0); |
| 49 |
EXPECT_TRUE(watchOS); |
| 50 |
EXPECT_EQ(watchOS->Platform, MachO::PLATFORM_WATCHOS); |
| 51 |
|
| 52 |
auto watchOSSim = MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple( |
| 53 |
Triple("arm64-apple-watchos-simulator"), 0, 0); |
| 54 |
EXPECT_TRUE(watchOSSim); |
| 55 |
EXPECT_EQ(watchOSSim->Platform, MachO::PLATFORM_WATCHOSSIMULATOR); |
| 56 |
} |