1 //===---------- MachOPlatformTest.cpp - MachPlatform API Tests ------------===//
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 "llvm/ExecutionEngine/Orc/MachOPlatform.h"
10 #include "llvm/BinaryFormat/MachO.h"
11 #include "gtest/gtest.h"
14 using namespace llvm::orc
;
16 TEST(MachOPlatformTests
, BuildVersionOptsFromTriple
) {
18 auto darwinOS
= MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(
19 Triple("arm64-apple-darwin"), 0, 0);
20 EXPECT_FALSE(darwinOS
);
22 auto macOS
= MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(
23 Triple("arm64-apple-macosx"), 0, 0);
25 EXPECT_EQ(macOS
->Platform
, MachO::PLATFORM_MACOS
);
27 auto iOS
= MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(
28 Triple("arm64-apple-ios"), 0, 0);
30 EXPECT_EQ(iOS
->Platform
, MachO::PLATFORM_IOS
);
32 auto iOSSim
= MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(
33 Triple("arm64-apple-ios-simulator"), 0, 0);
35 EXPECT_EQ(iOSSim
->Platform
, MachO::PLATFORM_IOSSIMULATOR
);
37 auto tvOS
= MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(
38 Triple("arm64-apple-tvos"), 0, 0);
40 EXPECT_EQ(tvOS
->Platform
, MachO::PLATFORM_TVOS
);
42 auto tvOSSim
= MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(
43 Triple("arm64-apple-tvos-simulator"), 0, 0);
45 EXPECT_EQ(tvOSSim
->Platform
, MachO::PLATFORM_TVOSSIMULATOR
);
47 auto watchOS
= MachOPlatform::HeaderOptions::BuildVersionOpts::fromTriple(
48 Triple("arm64-apple-watchos"), 0, 0);
50 EXPECT_EQ(watchOS
->Platform
, MachO::PLATFORM_WATCHOS
);
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
);