2019-10-10 06:24:44 +02:00
|
|
|
//===-- TextStubV4Tests.cpp - TBD V4 File Test ----------------------------===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//===-----------------------------------------------------------------------===/
|
2020-02-13 21:51:19 +01:00
|
|
|
|
|
|
|
#include "TextStubHelpers.h"
|
2021-04-05 18:59:50 +02:00
|
|
|
#include "llvm/TextAPI/InterfaceFile.h"
|
|
|
|
#include "llvm/TextAPI/TextAPIReader.h"
|
|
|
|
#include "llvm/TextAPI/TextAPIWriter.h"
|
2019-10-10 06:24:44 +02:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::MachO;
|
|
|
|
|
|
|
|
|
|
|
|
namespace TBDv4 {
|
|
|
|
|
|
|
|
TEST(TBDv4, ReadFile) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4File[] =
|
2019-10-10 06:24:44 +02:00
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-macos\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: x86_64-macos\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
" - target: x86_64-ios\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
"flags: [ flat_namespace, installapi ]\n"
|
|
|
|
"install-name: Umbrella.framework/Umbrella\n"
|
|
|
|
"current-version: 1.2.3\n"
|
|
|
|
"compatibility-version: 1.2\n"
|
|
|
|
"swift-abi-version: 5\n"
|
|
|
|
"parent-umbrella:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
|
|
|
|
" umbrella: System\n"
|
|
|
|
"allowable-clients:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
|
|
|
|
" clients: [ ClientA ]\n"
|
|
|
|
"reexported-libraries:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symA ]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
" - targets: [ x86_64-ios ]\n"
|
|
|
|
" symbols: [_symB]\n"
|
|
|
|
" - targets: [ x86_64-macos, x86_64-ios ]\n"
|
|
|
|
" symbols: [_symAB]\n"
|
|
|
|
"reexports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [_symC]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
"undefineds:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symD ]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4File, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
PlatformSet Platforms;
|
2021-05-07 01:18:55 +02:00
|
|
|
Platforms.insert(getPlatformFromName("macos"));
|
|
|
|
Platforms.insert(getPlatformFromName("ios"));
|
2019-10-10 06:24:44 +02:00
|
|
|
auto Archs = AK_i386 | AK_x86_64;
|
|
|
|
TargetList Targets = {
|
|
|
|
Target(AK_i386, PlatformKind::macOS),
|
|
|
|
Target(AK_x86_64, PlatformKind::macOS),
|
|
|
|
Target(AK_x86_64, PlatformKind::iOS),
|
|
|
|
};
|
|
|
|
UUIDs uuids = {{Targets[0], "00000000-0000-0000-0000-000000000000"},
|
|
|
|
{Targets[1], "11111111-1111-1111-1111-111111111111"},
|
|
|
|
{Targets[2], "11111111-1111-1111-1111-111111111111"}};
|
|
|
|
EXPECT_EQ(Archs, File->getArchitectures());
|
|
|
|
EXPECT_EQ(uuids, File->uuids());
|
|
|
|
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
|
|
|
|
for (auto Platform : File->getPlatforms())
|
|
|
|
EXPECT_EQ(Platforms.count(Platform), 1U);
|
|
|
|
EXPECT_EQ(std::string("Umbrella.framework/Umbrella"), File->getInstallName());
|
|
|
|
EXPECT_EQ(PackedVersion(1, 2, 3), File->getCurrentVersion());
|
|
|
|
EXPECT_EQ(PackedVersion(1, 2, 0), File->getCompatibilityVersion());
|
|
|
|
EXPECT_EQ(5U, File->getSwiftABIVersion());
|
|
|
|
EXPECT_FALSE(File->isTwoLevelNamespace());
|
|
|
|
EXPECT_TRUE(File->isApplicationExtensionSafe());
|
|
|
|
EXPECT_TRUE(File->isInstallAPI());
|
|
|
|
InterfaceFileRef client("ClientA", Targets);
|
|
|
|
InterfaceFileRef reexport("/System/Library/Frameworks/A.framework/A",
|
|
|
|
{Targets[0]});
|
|
|
|
EXPECT_EQ(1U, File->allowableClients().size());
|
|
|
|
EXPECT_EQ(client, File->allowableClients().front());
|
|
|
|
EXPECT_EQ(1U, File->reexportedLibraries().size());
|
|
|
|
EXPECT_EQ(reexport, File->reexportedLibraries().front());
|
|
|
|
|
2020-02-13 21:51:19 +01:00
|
|
|
ExportedSymbolSeq Exports, Reexports, Undefineds;
|
|
|
|
ExportedSymbol temp;
|
2019-10-10 06:24:44 +02:00
|
|
|
for (const auto *Sym : File->symbols()) {
|
2020-02-13 21:51:19 +01:00
|
|
|
temp = ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
|
|
|
|
Sym->isWeakDefined(), Sym->isThreadLocalValue()};
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_FALSE(Sym->isWeakReferenced());
|
|
|
|
if (Sym->isUndefined())
|
|
|
|
Undefineds.emplace_back(std::move(temp));
|
|
|
|
else
|
|
|
|
Sym->isReexported() ? Reexports.emplace_back(std::move(temp))
|
|
|
|
: Exports.emplace_back(std::move(temp));
|
|
|
|
}
|
|
|
|
llvm::sort(Exports.begin(), Exports.end());
|
|
|
|
llvm::sort(Reexports.begin(), Reexports.end());
|
|
|
|
llvm::sort(Undefineds.begin(), Undefineds.end());
|
|
|
|
|
2020-04-01 18:41:39 +02:00
|
|
|
static ExportedSymbol ExpectedExportedSymbols[] = {
|
|
|
|
{SymbolKind::GlobalSymbol, "_symA", false, false},
|
|
|
|
{SymbolKind::GlobalSymbol, "_symAB", false, false},
|
|
|
|
{SymbolKind::GlobalSymbol, "_symB", false, false},
|
|
|
|
};
|
|
|
|
|
|
|
|
static ExportedSymbol ExpectedReexportedSymbols[] = {
|
|
|
|
{SymbolKind::GlobalSymbol, "_symC", false, false},
|
|
|
|
};
|
|
|
|
|
|
|
|
static ExportedSymbol ExpectedUndefinedSymbols[] = {
|
|
|
|
{SymbolKind::GlobalSymbol, "_symD", false, false},
|
|
|
|
};
|
|
|
|
|
|
|
|
EXPECT_EQ(sizeof(ExpectedExportedSymbols) / sizeof(ExportedSymbol),
|
|
|
|
Exports.size());
|
|
|
|
EXPECT_EQ(sizeof(ExpectedReexportedSymbols) / sizeof(ExportedSymbol),
|
|
|
|
Reexports.size());
|
|
|
|
EXPECT_EQ(sizeof(ExpectedUndefinedSymbols) / sizeof(ExportedSymbol),
|
|
|
|
Undefineds.size());
|
|
|
|
EXPECT_TRUE(std::equal(Exports.begin(), Exports.end(),
|
|
|
|
std::begin(ExpectedExportedSymbols)));
|
|
|
|
EXPECT_TRUE(std::equal(Reexports.begin(), Reexports.end(),
|
|
|
|
std::begin(ExpectedReexportedSymbols)));
|
|
|
|
EXPECT_TRUE(std::equal(Undefineds.begin(), Undefineds.end(),
|
|
|
|
std::begin(ExpectedUndefinedSymbols)));
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, ReadMultipleDocuments) {
|
|
|
|
static const char TBDv4Inlines[] =
|
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-macos, i386-maccatalyst, x86_64-macos, "
|
|
|
|
"x86_64-maccatalyst ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-macos\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: i386-maccatalyst\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000002\n"
|
|
|
|
" - target: x86_64-macos\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
" - target: x86_64-maccatalyst\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111112\n"
|
|
|
|
"install-name: /System/Library/Frameworks/Umbrella.framework/Umbrella\n"
|
|
|
|
"parent-umbrella:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
" umbrella: System\n"
|
|
|
|
"reexported-libraries:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
|
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-macos\n"
|
|
|
|
" value: 20000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: x86_64-macos\n"
|
|
|
|
" value: 21111111-1111-1111-1111-111111111111\n"
|
|
|
|
"flags: [ flat_namespace ]\n"
|
|
|
|
"install-name: /System/Library/Frameworks/A.framework/A\n"
|
|
|
|
"current-version: 1.2.3\n"
|
|
|
|
"compatibility-version: 1.2\n"
|
|
|
|
"swift-abi-version: 5\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symA ]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
" - targets: [ x86_64-macos ]\n"
|
|
|
|
" symbols: [_symAB]\n"
|
|
|
|
"reexports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [_symC]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
"undefineds:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symD ]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
PlatformSet Platforms;
|
|
|
|
Platforms.insert(PlatformKind::macOS);
|
|
|
|
Platforms.insert(PlatformKind::macCatalyst);
|
|
|
|
ArchitectureSet Archs = AK_i386 | AK_x86_64;
|
|
|
|
TargetList Targets;
|
|
|
|
for (auto &&Arch : Archs)
|
|
|
|
for (auto &&Platform : Platforms)
|
|
|
|
Targets.emplace_back(Target(Arch, Platform));
|
|
|
|
UUIDs Uuids = {
|
|
|
|
{Targets[0], "00000000-0000-0000-0000-000000000000"},
|
|
|
|
{Targets[1], "00000000-0000-0000-0000-000000000002"},
|
|
|
|
{Targets[2], "11111111-1111-1111-1111-111111111111"},
|
|
|
|
{Targets[3], "11111111-1111-1111-1111-111111111112"},
|
|
|
|
};
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4Inlines, "Test.tbd"));
|
2020-04-01 18:41:39 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2020-04-01 18:41:39 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(Archs, File->getArchitectures());
|
|
|
|
EXPECT_EQ(Uuids, File->uuids());
|
|
|
|
EXPECT_EQ(Platforms, File->getPlatforms());
|
|
|
|
EXPECT_EQ(
|
|
|
|
std::string("/System/Library/Frameworks/Umbrella.framework/Umbrella"),
|
|
|
|
File->getInstallName());
|
|
|
|
EXPECT_TRUE(File->isTwoLevelNamespace());
|
|
|
|
EXPECT_TRUE(File->isApplicationExtensionSafe());
|
|
|
|
EXPECT_FALSE(File->isInstallAPI());
|
|
|
|
EXPECT_EQ(PackedVersion(1, 0, 0), File->getCurrentVersion());
|
|
|
|
EXPECT_EQ(PackedVersion(1, 0, 0), File->getCompatibilityVersion());
|
|
|
|
InterfaceFileRef reexport("/System/Library/Frameworks/A.framework/A",
|
|
|
|
{Targets[0], Targets[2]});
|
|
|
|
EXPECT_EQ(1U, File->reexportedLibraries().size());
|
|
|
|
EXPECT_EQ(reexport, File->reexportedLibraries().front());
|
2021-01-15 18:11:31 +01:00
|
|
|
EXPECT_TRUE(File->symbols().empty());
|
2020-04-01 18:41:39 +02:00
|
|
|
|
|
|
|
// Check Inlined Document
|
|
|
|
Targets.clear();
|
|
|
|
Uuids.clear();
|
|
|
|
PlatformKind Platform = PlatformKind::macOS;
|
|
|
|
for (auto &&Arch : Archs)
|
|
|
|
Targets.emplace_back(Target(Arch, Platform));
|
|
|
|
Uuids = {
|
|
|
|
{Targets[0], "20000000-0000-0000-0000-000000000000"},
|
|
|
|
{Targets[1], "21111111-1111-1111-1111-111111111111"},
|
|
|
|
};
|
|
|
|
|
2020-09-18 21:22:46 +02:00
|
|
|
TBDReexportFile Document = File->documents().front();
|
2020-04-01 18:41:39 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, Document->getFileType());
|
|
|
|
EXPECT_EQ(Archs, Document->getArchitectures());
|
|
|
|
EXPECT_EQ(Uuids, Document->uuids());
|
|
|
|
EXPECT_EQ(1U, Document->getPlatforms().size());
|
|
|
|
EXPECT_EQ(Platform, *(Document->getPlatforms().begin()));
|
|
|
|
EXPECT_EQ(std::string("/System/Library/Frameworks/A.framework/A"),
|
|
|
|
Document->getInstallName());
|
|
|
|
EXPECT_EQ(PackedVersion(1, 2, 3), Document->getCurrentVersion());
|
|
|
|
EXPECT_EQ(PackedVersion(1, 2, 0), Document->getCompatibilityVersion());
|
|
|
|
EXPECT_EQ(5U, Document->getSwiftABIVersion());
|
|
|
|
EXPECT_FALSE(Document->isTwoLevelNamespace());
|
|
|
|
EXPECT_TRUE(Document->isApplicationExtensionSafe());
|
|
|
|
EXPECT_FALSE(Document->isInstallAPI());
|
|
|
|
|
2021-01-15 18:11:31 +01:00
|
|
|
ExportedSymbolSeq Exports;
|
2020-04-01 18:41:39 +02:00
|
|
|
ExportedSymbolSeq Reexports, Undefineds;
|
|
|
|
for (const auto *Sym : Document->symbols()) {
|
|
|
|
ExportedSymbol Temp =
|
|
|
|
ExportedSymbol{Sym->getKind(), std::string(Sym->getName()),
|
|
|
|
Sym->isWeakDefined(), Sym->isThreadLocalValue()};
|
|
|
|
EXPECT_FALSE(Sym->isWeakReferenced());
|
|
|
|
if (Sym->isUndefined())
|
|
|
|
Undefineds.emplace_back(std::move(Temp));
|
|
|
|
else
|
|
|
|
Sym->isReexported() ? Reexports.emplace_back(std::move(Temp))
|
|
|
|
: Exports.emplace_back(std::move(Temp));
|
|
|
|
}
|
|
|
|
llvm::sort(Exports.begin(), Exports.end());
|
|
|
|
llvm::sort(Reexports.begin(), Reexports.end());
|
|
|
|
llvm::sort(Undefineds.begin(), Undefineds.end());
|
|
|
|
|
|
|
|
static ExportedSymbol ExpectedExportedSymbols[] = {
|
|
|
|
{SymbolKind::GlobalSymbol, "_symA", false, false},
|
|
|
|
{SymbolKind::GlobalSymbol, "_symAB", false, false},
|
|
|
|
};
|
|
|
|
|
|
|
|
static ExportedSymbol ExpectedReexportedSymbols[] = {
|
|
|
|
{SymbolKind::GlobalSymbol, "_symC", false, false},
|
|
|
|
};
|
|
|
|
|
|
|
|
static ExportedSymbol ExpectedUndefinedSymbols[] = {
|
|
|
|
{SymbolKind::GlobalSymbol, "_symD", false, false},
|
|
|
|
};
|
|
|
|
|
|
|
|
EXPECT_EQ(sizeof(ExpectedExportedSymbols) / sizeof(ExportedSymbol),
|
2019-10-10 06:24:44 +02:00
|
|
|
Exports.size());
|
2020-04-01 18:41:39 +02:00
|
|
|
EXPECT_EQ(sizeof(ExpectedReexportedSymbols) / sizeof(ExportedSymbol),
|
2019-10-10 06:24:44 +02:00
|
|
|
Reexports.size());
|
2020-04-01 18:41:39 +02:00
|
|
|
EXPECT_EQ(sizeof(ExpectedUndefinedSymbols) / sizeof(ExportedSymbol),
|
2019-10-10 06:24:44 +02:00
|
|
|
Undefineds.size());
|
|
|
|
EXPECT_TRUE(std::equal(Exports.begin(), Exports.end(),
|
2020-04-01 18:41:39 +02:00
|
|
|
std::begin(ExpectedExportedSymbols)));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(std::equal(Reexports.begin(), Reexports.end(),
|
2020-04-01 18:41:39 +02:00
|
|
|
std::begin(ExpectedReexportedSymbols)));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(std::equal(Undefineds.begin(), Undefineds.end(),
|
2020-04-01 18:41:39 +02:00
|
|
|
std::begin(ExpectedUndefinedSymbols)));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, WriteFile) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4File[] =
|
2019-10-10 06:24:44 +02:00
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-macos, x86_64-ios-simulator ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-macos\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: x86_64-ios-simulator\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
"flags: [ installapi ]\n"
|
|
|
|
"install-name: 'Umbrella.framework/Umbrella'\n"
|
|
|
|
"current-version: 1.2.3\n"
|
|
|
|
"compatibility-version: 0\n"
|
|
|
|
"swift-abi-version: 5\n"
|
|
|
|
"parent-umbrella:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-ios-simulator ]\n"
|
|
|
|
" umbrella: System\n"
|
|
|
|
"allowable-clients:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" clients: [ ClientA ]\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symA ]\n"
|
|
|
|
" objc-classes: [ Class1 ]\n"
|
|
|
|
" weak-symbols: [ _symC ]\n"
|
|
|
|
" - targets: [ x86_64-ios-simulator ]\n"
|
|
|
|
" symbols: [ _symB ]\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
InterfaceFile File;
|
|
|
|
TargetList Targets = {
|
|
|
|
Target(AK_i386, PlatformKind::macOS),
|
|
|
|
Target(AK_x86_64, PlatformKind::iOSSimulator),
|
|
|
|
};
|
|
|
|
UUIDs uuids = {{Targets[0], "00000000-0000-0000-0000-000000000000"},
|
|
|
|
{Targets[1], "11111111-1111-1111-1111-111111111111"}};
|
|
|
|
File.setInstallName("Umbrella.framework/Umbrella");
|
|
|
|
File.setFileType(FileType::TBD_V4);
|
|
|
|
File.addTargets(Targets);
|
|
|
|
File.addUUID(uuids[0].first, uuids[0].second);
|
|
|
|
File.addUUID(uuids[1].first, uuids[1].second);
|
|
|
|
File.setCurrentVersion(PackedVersion(1, 2, 3));
|
|
|
|
File.setTwoLevelNamespace();
|
|
|
|
File.setInstallAPI(true);
|
|
|
|
File.setApplicationExtensionSafe(true);
|
|
|
|
File.setSwiftABIVersion(5);
|
|
|
|
File.addAllowableClient("ClientA", Targets[0]);
|
|
|
|
File.addParentUmbrella(Targets[0], "System");
|
|
|
|
File.addParentUmbrella(Targets[1], "System");
|
|
|
|
File.addSymbol(SymbolKind::GlobalSymbol, "_symA", {Targets[0]});
|
|
|
|
File.addSymbol(SymbolKind::GlobalSymbol, "_symB", {Targets[1]});
|
|
|
|
File.addSymbol(SymbolKind::GlobalSymbol, "_symC", {Targets[0]},
|
|
|
|
SymbolFlags::WeakDefined);
|
|
|
|
File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", {Targets[0]});
|
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-06-16 04:59:42 +02:00
|
|
|
Error Result = TextAPIWriter::writeToStream(OS, File);
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_FALSE(Result);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_STREQ(TBDv4File, Buffer.c_str());
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
2020-04-01 18:41:39 +02:00
|
|
|
TEST(TBDv4, WriteMultipleDocuments) {
|
|
|
|
static const char TBDv4Inlines[] =
|
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-maccatalyst\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000002\n"
|
|
|
|
" - target: x86_64-maccatalyst\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111112\n"
|
|
|
|
"install-name: "
|
|
|
|
"'/System/Library/Frameworks/Umbrella.framework/Umbrella'\n"
|
|
|
|
"reexported-libraries:\n"
|
|
|
|
" - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
|
|
|
|
" libraries: [ '/System/Library/Frameworks/A.framework/A' ]\n"
|
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-maccatalyst\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: x86_64-maccatalyst\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
"install-name: '/System/Library/Frameworks/A.framework/A'\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - targets: [ i386-maccatalyst ]\n"
|
|
|
|
" weak-symbols: [ _symC ]\n"
|
|
|
|
" - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
|
|
|
|
" symbols: [ _symA ]\n"
|
|
|
|
" objc-classes: [ Class1 ]\n"
|
|
|
|
" - targets: [ x86_64-maccatalyst ]\n"
|
|
|
|
" symbols: [ _symAB ]\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
InterfaceFile File;
|
|
|
|
PlatformKind Platform = PlatformKind::macCatalyst;
|
|
|
|
TargetList Targets = {
|
|
|
|
Target(AK_i386, Platform),
|
|
|
|
Target(AK_x86_64, Platform),
|
|
|
|
};
|
|
|
|
UUIDs Uuids = {{Targets[0], "00000000-0000-0000-0000-000000000002"},
|
|
|
|
{Targets[1], "11111111-1111-1111-1111-111111111112"}};
|
|
|
|
File.setInstallName("/System/Library/Frameworks/Umbrella.framework/Umbrella");
|
|
|
|
File.setFileType(FileType::TBD_V4);
|
|
|
|
File.addTargets(Targets);
|
|
|
|
File.addUUID(Uuids[0].first, Uuids[0].second);
|
|
|
|
File.addUUID(Uuids[1].first, Uuids[1].second);
|
|
|
|
File.setCompatibilityVersion(PackedVersion(1, 0, 0));
|
|
|
|
File.setCurrentVersion(PackedVersion(1, 0, 0));
|
|
|
|
File.setTwoLevelNamespace();
|
|
|
|
File.setApplicationExtensionSafe(true);
|
|
|
|
File.addReexportedLibrary("/System/Library/Frameworks/A.framework/A",
|
|
|
|
Targets[0]);
|
|
|
|
File.addReexportedLibrary("/System/Library/Frameworks/A.framework/A",
|
|
|
|
Targets[1]);
|
|
|
|
|
|
|
|
// Write Second Document
|
|
|
|
Uuids = {{Targets[0], "00000000-0000-0000-0000-000000000000"},
|
|
|
|
{Targets[1], "11111111-1111-1111-1111-111111111111"}};
|
|
|
|
InterfaceFile Document;
|
|
|
|
Document.setInstallName("/System/Library/Frameworks/A.framework/A");
|
|
|
|
Document.setFileType(FileType::TBD_V4);
|
|
|
|
Document.addTargets(Targets);
|
|
|
|
Document.addUUID(Uuids[0].first, Uuids[0].second);
|
|
|
|
Document.addUUID(Uuids[1].first, Uuids[1].second);
|
|
|
|
Document.setCompatibilityVersion(PackedVersion(1, 0, 0));
|
|
|
|
Document.setCurrentVersion(PackedVersion(1, 0, 0));
|
|
|
|
Document.setTwoLevelNamespace();
|
|
|
|
Document.setApplicationExtensionSafe(true);
|
|
|
|
Document.addSymbol(SymbolKind::GlobalSymbol, "_symA", Targets);
|
|
|
|
Document.addSymbol(SymbolKind::GlobalSymbol, "_symAB", {Targets[1]});
|
|
|
|
Document.addSymbol(SymbolKind::GlobalSymbol, "_symC", {Targets[0]},
|
|
|
|
SymbolFlags::WeakDefined);
|
|
|
|
Document.addSymbol(SymbolKind::ObjectiveCClass, "Class1", Targets);
|
|
|
|
File.addDocument(std::make_shared<InterfaceFile>(std::move(Document)));
|
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-06-16 04:59:42 +02:00
|
|
|
Error Result = TextAPIWriter::writeToStream(OS, File);
|
2020-04-01 18:41:39 +02:00
|
|
|
EXPECT_FALSE(Result);
|
|
|
|
EXPECT_STREQ(TBDv4Inlines, Buffer.c_str());
|
|
|
|
}
|
|
|
|
|
2019-10-10 06:24:44 +02:00
|
|
|
TEST(TBDv4, MultipleTargets) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4MultipleTargets[] =
|
2019-10-10 06:24:44 +02:00
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-maccatalyst, x86_64-tvos, arm64-ios ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4MultipleTargets, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
|
|
|
PlatformSet Platforms;
|
|
|
|
Platforms.insert(PlatformKind::macCatalyst);
|
|
|
|
Platforms.insert(PlatformKind::tvOS);
|
|
|
|
Platforms.insert(PlatformKind::iOS);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(AK_x86_64 | AK_arm64 | AK_i386, File->getArchitectures());
|
|
|
|
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
|
|
|
|
for (auto Platform : File->getPlatforms())
|
|
|
|
EXPECT_EQ(Platforms.count(Platform), 1U);
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4MultipleTargets),
|
2020-02-13 21:47:40 +01:00
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, MultipleTargetsSameArch) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4TargetsSameArch[] =
|
2019-10-10 06:24:44 +02:00
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
2020-02-13 21:47:40 +01:00
|
|
|
"targets: [ x86_64-tvos , x86_64-maccatalyst ]\n"
|
2019-10-10 06:24:44 +02:00
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4TargetsSameArch, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
|
|
|
PlatformSet Platforms;
|
|
|
|
Platforms.insert(PlatformKind::tvOS);
|
|
|
|
Platforms.insert(PlatformKind::macCatalyst);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
|
|
|
|
EXPECT_EQ(Platforms.size(), File->getPlatforms().size());
|
|
|
|
for (auto Platform : File->getPlatforms())
|
|
|
|
EXPECT_EQ(Platforms.count(Platform), 1U);
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4TargetsSameArch),
|
2020-02-13 21:47:40 +01:00
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, MultipleTargetsSamePlatform) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4MultipleTargetsSamePlatform[] =
|
2019-10-10 06:24:44 +02:00
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
2020-02-13 21:47:40 +01:00
|
|
|
"targets: [ armv7k-ios , arm64-ios]\n"
|
2019-10-10 06:24:44 +02:00
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result = TextAPIReader::get(
|
2020-03-27 00:29:21 +01:00
|
|
|
MemoryBufferRef(TBDv4MultipleTargetsSamePlatform, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(AK_arm64 | AK_armv7k, File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::iOS, *File->getPlatforms().begin());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4MultipleTargetsSamePlatform),
|
2020-02-13 21:47:40 +01:00
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Target_maccatalyst) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4TargetMacCatalyst[] =
|
2019-10-10 06:24:44 +02:00
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-maccatalyst ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4TargetMacCatalyst, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::macCatalyst, *File->getPlatforms().begin());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4TargetMacCatalyst),
|
2020-02-13 21:47:40 +01:00
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Target_x86_ios) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4Targetx86iOS[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-ios ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86iOS, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::iOS, *File->getPlatforms().begin());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4Targetx86iOS),
|
2020-02-13 21:47:40 +01:00
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Target_arm_bridgeOS) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4PlatformBridgeOS[] = "--- !tapi-tbd\n"
|
2019-10-10 06:24:44 +02:00
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ armv7k-bridgeos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4PlatformBridgeOS, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::bridgeOS, *File->getPlatforms().begin());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_armv7k), File->getArchitectures());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4PlatformBridgeOS),
|
2020-02-13 21:47:40 +01:00
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
2020-03-05 19:04:32 +01:00
|
|
|
TEST(TBDv4, Target_arm_iOS) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4ArchArm64e[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ arm64e-ios ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
2020-03-05 19:04:32 +01:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4ArchArm64e, "Test.tbd"));
|
2020-03-05 19:04:32 +01:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2020-03-05 19:04:32 +01:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::iOS, *File->getPlatforms().begin());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_arm64e), File->getArchitectures());
|
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-03-05 19:04:32 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4ArchArm64e), stripWhitespace(Buffer.c_str()));
|
2020-03-05 19:04:32 +01:00
|
|
|
}
|
|
|
|
|
2019-10-10 06:24:44 +02:00
|
|
|
TEST(TBDv4, Target_x86_macos) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4Targetx86MacOS[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86MacOS, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::macOS, *File->getPlatforms().begin());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4Targetx86MacOS),
|
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Target_x86_ios_simulator) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4Targetx86iOSSim[] =
|
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-ios-simulator ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4Targetx86iOSSim, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::iOSSimulator, *File->getPlatforms().begin());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4Targetx86iOSSim),
|
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Target_x86_tvos_simulator) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4x86tvOSSim[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-tvos-simulator ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4x86tvOSSim, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_x86_64), File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::tvOSSimulator, *File->getPlatforms().begin());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4x86tvOSSim), stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Target_i386_watchos_simulator) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4i386watchOSSim[] =
|
2019-10-10 06:24:44 +02:00
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-watchos-simulator ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4i386watchOSSim, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_i386), File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::watchOSSimulator, *File->getPlatforms().begin());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4i386watchOSSim),
|
2020-02-13 21:47:40 +01:00
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 21:34:20 +02:00
|
|
|
TEST(TBDv4, Target_i386_driverkit) {
|
|
|
|
static const char TBDv4i386DriverKit[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-driverkit ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
Expected<TBDFile> Result =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4i386DriverKit, "Test.tbd"));
|
|
|
|
EXPECT_TRUE(!!Result);
|
|
|
|
TBDFile File = std::move(Result.get());
|
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(ArchitectureSet(AK_i386), File->getArchitectures());
|
|
|
|
EXPECT_EQ(File->getPlatforms().size(), 1U);
|
|
|
|
EXPECT_EQ(PlatformKind::driverKit, *File->getPlatforms().begin());
|
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-08-14 21:34:20 +02:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4i386DriverKit),
|
|
|
|
stripWhitespace(Buffer.c_str()));
|
|
|
|
}
|
|
|
|
|
2019-10-10 06:24:44 +02:00
|
|
|
TEST(TBDv4, Swift_1) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4SwiftVersion1[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"swift-abi-version: 1\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion1, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(1U, File->getSwiftABIVersion());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
// No writer test because we emit "swift-abi-version:1.0".
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Swift_2) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4Swift2[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"swift-abi-version: 2\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4Swift2, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(2U, File->getSwiftABIVersion());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
// No writer test because we emit "swift-abi-version:2.0".
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Swift_5) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4SwiftVersion5[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"swift-abi-version: 5\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion5, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(5U, File->getSwiftABIVersion());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4SwiftVersion5),
|
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, Swift_99) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4SwiftVersion99[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"swift-abi-version: 99\n"
|
|
|
|
"...\n";
|
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4SwiftVersion99, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_TRUE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
TBDFile File = std::move(Result.get());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ(FileType::TBD_V4, File->getFileType());
|
|
|
|
EXPECT_EQ(99U, File->getSwiftABIVersion());
|
2020-02-13 21:47:40 +01:00
|
|
|
|
|
|
|
SmallString<4096> Buffer;
|
|
|
|
raw_svector_ostream OS(Buffer);
|
2020-09-18 21:22:46 +02:00
|
|
|
Error WriteResult = TextAPIWriter::writeToStream(OS, *File);
|
2020-02-13 21:47:40 +01:00
|
|
|
EXPECT_TRUE(!WriteResult);
|
2020-03-27 00:29:21 +01:00
|
|
|
EXPECT_EQ(stripWhitespace(TBDv4SwiftVersion99),
|
|
|
|
stripWhitespace(Buffer.c_str()));
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, InvalidArchitecture) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4UnknownArch[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ foo-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4UnknownArch, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_FALSE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
std::string ErrorMessage = toString(Result.takeError());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ("malformed file\nTest.tbd:3:12: error: unknown "
|
|
|
|
"architecture\ntargets: [ foo-macos ]\n"
|
|
|
|
" ^~~~~~~~~~\n",
|
2020-06-16 04:59:42 +02:00
|
|
|
ErrorMessage);
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, InvalidPlatform) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4FInvalidPlatform[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-maos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4FInvalidPlatform, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_FALSE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
std::string ErrorMessage = toString(Result.takeError());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ("malformed file\nTest.tbd:3:12: error: unknown platform\ntargets: "
|
|
|
|
"[ x86_64-maos ]\n"
|
|
|
|
" ^~~~~~~~~~~~\n",
|
2020-06-16 04:59:42 +02:00
|
|
|
ErrorMessage);
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, MalformedFile1) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4MalformedFile1[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedFile1, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_FALSE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
std::string ErrorMessage = toString(Result.takeError());
|
2019-10-10 06:24:44 +02:00
|
|
|
ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key "
|
|
|
|
"'targets'\ntbd-version: 4\n^\n",
|
2020-06-16 04:59:42 +02:00
|
|
|
ErrorMessage);
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, MalformedFile2) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4MalformedFile2[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"foobar: \"unsupported key\"\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedFile2, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_FALSE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
std::string ErrorMessage = toString(Result.takeError());
|
2019-10-10 06:24:44 +02:00
|
|
|
ASSERT_EQ(
|
2020-12-11 17:34:06 +01:00
|
|
|
"malformed file\nTest.tbd:5:1: error: unknown key 'foobar'\nfoobar: "
|
|
|
|
"\"unsupported key\"\n^~~~~~\n",
|
2020-06-16 04:59:42 +02:00
|
|
|
ErrorMessage);
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, MalformedFile3) {
|
2020-03-27 00:29:21 +01:00
|
|
|
static const char TBDv4MalformedSwift[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ x86_64-macos ]\n"
|
|
|
|
"install-name: Test.dylib\n"
|
|
|
|
"swift-abi-version: 1.1\n"
|
|
|
|
"...\n";
|
2019-10-10 06:24:44 +02:00
|
|
|
|
2020-06-16 04:59:42 +02:00
|
|
|
Expected<TBDFile> Result =
|
2020-03-27 00:29:21 +01:00
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4MalformedSwift, "Test.tbd"));
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_FALSE(!!Result);
|
2020-06-16 04:59:42 +02:00
|
|
|
std::string ErrorMessage = toString(Result.takeError());
|
2019-10-10 06:24:44 +02:00
|
|
|
EXPECT_EQ("malformed file\nTest.tbd:5:20: error: invalid Swift ABI "
|
|
|
|
"version.\nswift-abi-version: 1.1\n ^~~\n",
|
2020-06-16 04:59:42 +02:00
|
|
|
ErrorMessage);
|
2019-10-10 06:24:44 +02:00
|
|
|
}
|
|
|
|
|
2021-02-18 20:27:54 +01:00
|
|
|
TEST(TBDv4, InterfaceEquality) {
|
|
|
|
static const char TBDv4File[] =
|
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-macos\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: x86_64-macos\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
" - target: x86_64-ios\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
"flags: [ flat_namespace, installapi ]\n"
|
|
|
|
"install-name: Umbrella.framework/Umbrella\n"
|
|
|
|
"current-version: 1.2.3\n"
|
|
|
|
"compatibility-version: 1.2\n"
|
|
|
|
"swift-abi-version: 5\n"
|
|
|
|
"parent-umbrella:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
|
|
|
|
" umbrella: System\n"
|
|
|
|
"allowable-clients:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos, x86_64-ios ]\n"
|
|
|
|
" clients: [ ClientA ]\n"
|
|
|
|
"reexported-libraries:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symA ]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
" - targets: [ x86_64-ios ]\n"
|
|
|
|
" symbols: [_symB]\n"
|
|
|
|
" - targets: [ x86_64-macos, x86_64-ios ]\n"
|
|
|
|
" symbols: [_symAB]\n"
|
|
|
|
"reexports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [_symC]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
"undefineds:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symD ]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-maccatalyst\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: x86_64-maccatalyst\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
"install-name: '/System/Library/Frameworks/A.framework/A'\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - targets: [ i386-maccatalyst ]\n"
|
|
|
|
" weak-symbols: [ _symC ]\n"
|
|
|
|
" - targets: [ i386-maccatalyst, x86_64-maccatalyst ]\n"
|
|
|
|
" symbols: [ _symA ]\n"
|
|
|
|
" objc-classes: [ Class1 ]\n"
|
|
|
|
" - targets: [ x86_64-maccatalyst ]\n"
|
|
|
|
" symbols: [ _symAB ]\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
Expected<TBDFile> ResultA =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestA.tbd"));
|
|
|
|
EXPECT_TRUE(!!ResultA);
|
|
|
|
InterfaceFile FileA = std::move(*ResultA.get());
|
|
|
|
Expected<TBDFile> ResultB =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestB.tbd"));
|
|
|
|
EXPECT_TRUE(!!ResultB);
|
|
|
|
InterfaceFile FileB = std::move(*ResultB.get());
|
|
|
|
EXPECT_TRUE(FileA == FileB);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, InterfaceDiffVersionsEquality) {
|
|
|
|
static const char TBDv4File[] =
|
|
|
|
"--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
"uuids:\n"
|
|
|
|
" - target: i386-macos\n"
|
|
|
|
" value: 00000000-0000-0000-0000-000000000000\n"
|
|
|
|
" - target: x86_64-macos\n"
|
|
|
|
" value: 11111111-1111-1111-1111-111111111111\n"
|
|
|
|
"flags: [ installapi ]\n"
|
|
|
|
"install-name: Umbrella.framework/Umbrella\n"
|
|
|
|
"current-version: 1.2.3\n"
|
|
|
|
"compatibility-version: 1.0\n"
|
|
|
|
"swift-abi-version: 5\n"
|
|
|
|
"parent-umbrella:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
" umbrella: System\n"
|
|
|
|
"allowable-clients:\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
" clients: [ ClientA ]\n"
|
|
|
|
"reexported-libraries:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" libraries: [ /System/Library/Frameworks/A.framework/A ]\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _sym5 ]\n"
|
|
|
|
" objc-classes: [ class3]\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: [ class1._ivar3 ]\n"
|
|
|
|
" weak-symbols: [ _weak3 ]\n"
|
|
|
|
" - targets: [ x86_64-macos ]\n"
|
|
|
|
" symbols: [_symAB]\n"
|
|
|
|
" - targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
" symbols: [_symA]\n"
|
|
|
|
" objc-classes: [ class1, class2 ]\n"
|
|
|
|
" objc-eh-types: [ class1 ]\n"
|
|
|
|
" objc-ivars: [ class1._ivar1, class1._ivar2 ]\n"
|
|
|
|
" weak-symbols: [ _weak1, _weak2 ]\n"
|
|
|
|
" thread-local-symbols: [ _tlv1, _tlv3 ]\n"
|
|
|
|
"undefineds:\n"
|
|
|
|
" - targets: [ i386-macos ]\n"
|
|
|
|
" symbols: [ _symC ]\n"
|
|
|
|
" objc-classes: []\n"
|
|
|
|
" objc-eh-types: []\n"
|
|
|
|
" objc-ivars: []\n"
|
|
|
|
" weak-symbols: []\n"
|
|
|
|
" thread-local-symbols: []\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
static const char TBDv3File[] =
|
|
|
|
"--- !tapi-tbd-v3\n"
|
|
|
|
"archs: [ i386, x86_64 ]\n"
|
|
|
|
"uuids: [ 'i386: 00000000-0000-0000-0000-000000000000',\n"
|
|
|
|
" 'x86_64: 22222222-2222-2222-2222-222222222222']\n"
|
|
|
|
"platform: macosx\n"
|
|
|
|
"flags: [ installapi ]\n"
|
|
|
|
"install-name: Umbrella.framework/Umbrella\n"
|
|
|
|
"current-version: 1.2.3\n"
|
|
|
|
"compatibility-version: 1.0\n"
|
|
|
|
"swift-abi-version: 5\n"
|
|
|
|
"parent-umbrella: System\n"
|
|
|
|
"exports:\n"
|
|
|
|
" - archs: [ i386, x86_64 ]\n"
|
|
|
|
" allowable-clients: [ ClientA ]\n"
|
|
|
|
" symbols: [ _symA ]\n"
|
|
|
|
" objc-classes: [ class1, class2 ]\n"
|
|
|
|
" objc-eh-types: [ class1 ]\n"
|
|
|
|
" objc-ivars: [ class1._ivar1, class1._ivar2 ]\n"
|
|
|
|
" weak-def-symbols: [ _weak1, _weak2 ]\n"
|
|
|
|
" thread-local-symbols: [ _tlv1, _tlv3 ]\n"
|
|
|
|
" - archs: [ i386 ]\n"
|
|
|
|
" re-exports: [ /System/Library/Frameworks/A.framework/A ]\n"
|
|
|
|
" symbols: [ _sym5 ]\n"
|
|
|
|
" objc-classes: [ class3 ]\n"
|
|
|
|
" objc-ivars: [ class1._ivar3 ]\n"
|
|
|
|
" weak-def-symbols: [ _weak3 ]\n"
|
|
|
|
" - archs: [ x86_64 ]\n"
|
|
|
|
" symbols: [ _symAB ]\n"
|
|
|
|
"undefineds:\n"
|
|
|
|
" - archs: [ i386 ]\n"
|
|
|
|
" symbols: [ _symC ]\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
Expected<TBDFile> ResultA =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestA.tbd"));
|
|
|
|
EXPECT_TRUE(!!ResultA);
|
|
|
|
InterfaceFile FileA = std::move(*ResultA.get());
|
|
|
|
Expected<TBDFile> ResultB =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv3File, "TestB.tbd"));
|
|
|
|
EXPECT_TRUE(!!ResultB);
|
|
|
|
InterfaceFile FileB = std::move(*ResultB.get());
|
|
|
|
EXPECT_NE(FileA.uuids(), FileB.uuids());
|
|
|
|
EXPECT_TRUE(FileA == FileB);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(TBDv4, InterfaceInequality) {
|
|
|
|
static const char TBDv4File[] = "--- !tapi-tbd\n"
|
|
|
|
"tbd-version: 4\n"
|
|
|
|
"targets: [ i386-macos, x86_64-macos ]\n"
|
|
|
|
"install-name: Umbrella.framework/Umbrella\n"
|
|
|
|
"...\n";
|
|
|
|
|
|
|
|
Expected<TBDFile> ResultA =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestA.tbd"));
|
|
|
|
EXPECT_TRUE(!!ResultA);
|
|
|
|
InterfaceFile FileA = std::move(*ResultA.get());
|
|
|
|
Expected<TBDFile> ResultB =
|
|
|
|
TextAPIReader::get(MemoryBufferRef(TBDv4File, "TestB.tbd"));
|
|
|
|
EXPECT_TRUE(!!ResultB);
|
|
|
|
InterfaceFile FileB = std::move(*ResultB.get());
|
|
|
|
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->addTarget(Target(AK_x86_64, PlatformKind::iOS));
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->setCurrentVersion(PackedVersion(1, 2, 3));
|
|
|
|
File->setCompatibilityVersion(PackedVersion(1, 0, 0));
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(
|
|
|
|
FileA, FileB, [](InterfaceFile *File) { File->setSwiftABIVersion(5); }));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->setTwoLevelNamespace(false);
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(
|
|
|
|
FileA, FileB, [](InterfaceFile *File) { File->setInstallAPI(true); }));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->setApplicationExtensionSafe(false);
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->addParentUmbrella(Target(AK_x86_64, PlatformKind::macOS), "System.dylib");
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->addAllowableClient("ClientA", Target(AK_i386, PlatformKind::macOS));
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->addReexportedLibrary("/System/Library/Frameworks/A.framework/A",
|
|
|
|
Target(AK_i386, PlatformKind::macOS));
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
File->addSymbol(SymbolKind::GlobalSymbol, "_symA", {Target(AK_x86_64, PlatformKind::macOS)});
|
|
|
|
}));
|
|
|
|
EXPECT_TRUE(checkEqualityOnTransform(FileA, FileB, [](InterfaceFile *File) {
|
|
|
|
InterfaceFile Document;
|
|
|
|
Document.addTargets(TargetList {Target(AK_i386, PlatformKind::macOS),
|
|
|
|
Target(AK_x86_64, PlatformKind::macOS)});
|
|
|
|
Document.setInstallName("/System/Library/Frameworks/A.framework/A");
|
|
|
|
File->addDocument(std::make_shared<InterfaceFile>(std::move(Document)));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2019-10-10 06:24:44 +02:00
|
|
|
} // end namespace TBDv4
|