1 //===-- TextStubV2Tests.cpp - TBD V2 File Test ----------------------------===// 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/TextAPI/MachO/InterfaceFile.h" 10 #include "llvm/TextAPI/MachO/TextAPIReader.h" 11 #include "llvm/TextAPI/MachO/TextAPIWriter.h" 12 #include "gtest/gtest.h" 13 #include <string> 14 #include <vector> 15 16 using namespace llvm; 17 using namespace llvm::MachO; 18 19 struct ExportedSymbol { 20 SymbolKind Kind; 21 std::string Name; 22 bool WeakDefined; 23 bool ThreadLocalValue; 24 }; 25 using ExportedSymbolSeq = std::vector<ExportedSymbol>; 26 27 inline bool operator<(const ExportedSymbol &lhs, const ExportedSymbol &rhs) { 28 return std::tie(lhs.Kind, lhs.Name) < std::tie(rhs.Kind, rhs.Name); 29 } 30 31 inline bool operator==(const ExportedSymbol &lhs, const ExportedSymbol &rhs) { 32 return std::tie(lhs.Kind, lhs.Name, lhs.WeakDefined, lhs.ThreadLocalValue) == 33 std::tie(rhs.Kind, rhs.Name, rhs.WeakDefined, rhs.ThreadLocalValue); 34 } 35 36 static ExportedSymbol TBDv2Symbols[] = { 37 {SymbolKind::GlobalSymbol, "$ld$hide$os9.0$_sym1", false, false}, 38 {SymbolKind::GlobalSymbol, "_sym1", false, false}, 39 {SymbolKind::GlobalSymbol, "_sym2", false, false}, 40 {SymbolKind::GlobalSymbol, "_sym3", false, false}, 41 {SymbolKind::GlobalSymbol, "_sym4", false, false}, 42 {SymbolKind::GlobalSymbol, "_sym5", false, false}, 43 {SymbolKind::GlobalSymbol, "_tlv1", false, true}, 44 {SymbolKind::GlobalSymbol, "_tlv2", false, true}, 45 {SymbolKind::GlobalSymbol, "_tlv3", false, true}, 46 {SymbolKind::GlobalSymbol, "_weak1", true, false}, 47 {SymbolKind::GlobalSymbol, "_weak2", true, false}, 48 {SymbolKind::GlobalSymbol, "_weak3", true, false}, 49 {SymbolKind::ObjectiveCClass, "class1", false, false}, 50 {SymbolKind::ObjectiveCClass, "class2", false, false}, 51 {SymbolKind::ObjectiveCClass, "class3", false, false}, 52 {SymbolKind::ObjectiveCInstanceVariable, "class1._ivar1", false, false}, 53 {SymbolKind::ObjectiveCInstanceVariable, "class1._ivar2", false, false}, 54 {SymbolKind::ObjectiveCInstanceVariable, "class1._ivar3", false, false}, 55 }; 56 57 namespace TBDv2 { 58 59 TEST(TBDv2, ReadFile) { 60 static const char tbd_v2_file1[] = 61 "--- !tapi-tbd-v2\n" 62 "archs: [ armv7, armv7s, armv7k, arm64 ]\n" 63 "platform: ios\n" 64 "flags: [ installapi ]\n" 65 "install-name: Test.dylib\n" 66 "current-version: 2.3.4\n" 67 "compatibility-version: 1.0\n" 68 "swift-version: 1.1\n" 69 "parent-umbrella: Umbrella.dylib\n" 70 "exports:\n" 71 " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" 72 " allowable-clients: [ clientA ]\n" 73 " re-exports: [ /usr/lib/libfoo.dylib ]\n" 74 " symbols: [ _sym1, _sym2, _sym3, _sym4, $ld$hide$os9.0$_sym1 ]\n" 75 " objc-classes: [ _class1, _class2 ]\n" 76 " objc-ivars: [ _class1._ivar1, _class1._ivar2 ]\n" 77 " weak-def-symbols: [ _weak1, _weak2 ]\n" 78 " thread-local-symbols: [ _tlv1, _tlv2 ]\n" 79 " - archs: [ armv7, armv7s, armv7k ]\n" 80 " symbols: [ _sym5 ]\n" 81 " objc-classes: [ _class3 ]\n" 82 " objc-ivars: [ _class1._ivar3 ]\n" 83 " weak-def-symbols: [ _weak3 ]\n" 84 " thread-local-symbols: [ _tlv3 ]\n" 85 "...\n"; 86 87 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v2_file1, "Test.tbd"); 88 auto Result = TextAPIReader::get(std::move(Buffer)); 89 EXPECT_TRUE(!!Result); 90 auto File = std::move(Result.get()); 91 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 92 auto Archs = Architecture::armv7 | Architecture::armv7s | 93 Architecture::armv7k | Architecture::arm64; 94 EXPECT_EQ(Archs, File->getArchitectures()); 95 EXPECT_EQ(PlatformKind::iOS, File->getPlatform()); 96 EXPECT_EQ(std::string("Test.dylib"), File->getInstallName()); 97 EXPECT_EQ(PackedVersion(2, 3, 4), File->getCurrentVersion()); 98 EXPECT_EQ(PackedVersion(1, 0, 0), File->getCompatibilityVersion()); 99 EXPECT_EQ(2U, File->getSwiftABIVersion()); 100 EXPECT_EQ(ObjCConstraintType::Retain_Release, File->getObjCConstraint()); 101 EXPECT_TRUE(File->isTwoLevelNamespace()); 102 EXPECT_TRUE(File->isApplicationExtensionSafe()); 103 EXPECT_TRUE(File->isInstallAPI()); 104 InterfaceFileRef client("clientA", Archs); 105 InterfaceFileRef reexport("/usr/lib/libfoo.dylib", Archs); 106 EXPECT_EQ(1U, File->allowableClients().size()); 107 EXPECT_EQ(client, File->allowableClients().front()); 108 EXPECT_EQ(1U, File->reexportedLibraries().size()); 109 EXPECT_EQ(reexport, File->reexportedLibraries().front()); 110 111 ExportedSymbolSeq Exports; 112 for (const auto *Sym : File->symbols()) { 113 EXPECT_FALSE(Sym->isWeakReferenced()); 114 EXPECT_FALSE(Sym->isUndefined()); 115 Exports.emplace_back(ExportedSymbol{Sym->getKind(), Sym->getName(), 116 Sym->isWeakDefined(), 117 Sym->isThreadLocalValue()}); 118 } 119 llvm::sort(Exports.begin(), Exports.end()); 120 121 EXPECT_EQ(sizeof(TBDv2Symbols) / sizeof(ExportedSymbol), Exports.size()); 122 EXPECT_TRUE( 123 std::equal(Exports.begin(), Exports.end(), std::begin(TBDv2Symbols))); 124 } 125 126 TEST(TBDv2, ReadFile2) { 127 static const char tbd_v2_file2[] = 128 "--- !tapi-tbd-v2\n" 129 "archs: [ armv7, armv7s, armv7k, arm64 ]\n" 130 "platform: ios\n" 131 "flags: [ flat_namespace, not_app_extension_safe ]\n" 132 "install-name: Test.dylib\n" 133 "swift-version: 1.1\n" 134 "exports:\n" 135 " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" 136 " symbols: [ _sym1, _sym2, _sym3, _sym4, $ld$hide$os9.0$_sym1 ]\n" 137 " objc-classes: [ _class1, _class2 ]\n" 138 " objc-ivars: [ _class1._ivar1, _class1._ivar2 ]\n" 139 " weak-def-symbols: [ _weak1, _weak2 ]\n" 140 " thread-local-symbols: [ _tlv1, _tlv2 ]\n" 141 " - archs: [ armv7, armv7s, armv7k ]\n" 142 " symbols: [ _sym5 ]\n" 143 " objc-classes: [ _class3 ]\n" 144 " objc-ivars: [ _class1._ivar3 ]\n" 145 " weak-def-symbols: [ _weak3 ]\n" 146 " thread-local-symbols: [ _tlv3 ]\n" 147 "undefineds:\n" 148 " - archs: [ armv7, armv7s, armv7k, arm64 ]\n" 149 " symbols: [ _undefSym1, _undefSym2, _undefSym3 ]\n" 150 " objc-classes: [ _undefClass1, _undefClass2 ]\n" 151 " objc-ivars: [ _undefClass1._ivar1, _undefClass1._ivar2 ]\n" 152 " weak-ref-symbols: [ _undefWeak1, _undefWeak2 ]\n" 153 "...\n"; 154 155 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v2_file2, "Test.tbd"); 156 auto Result = TextAPIReader::get(std::move(Buffer)); 157 EXPECT_TRUE(!!Result); 158 auto File = std::move(Result.get()); 159 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 160 auto Archs = Architecture::armv7 | Architecture::armv7s | 161 Architecture::armv7k | Architecture::arm64; 162 EXPECT_EQ(Archs, File->getArchitectures()); 163 EXPECT_EQ(PlatformKind::iOS, File->getPlatform()); 164 EXPECT_EQ(std::string("Test.dylib"), File->getInstallName()); 165 EXPECT_EQ(PackedVersion(1, 0, 0), File->getCurrentVersion()); 166 EXPECT_EQ(PackedVersion(1, 0, 0), File->getCompatibilityVersion()); 167 EXPECT_EQ(2U, File->getSwiftABIVersion()); 168 EXPECT_EQ(ObjCConstraintType::Retain_Release, File->getObjCConstraint()); 169 EXPECT_FALSE(File->isTwoLevelNamespace()); 170 EXPECT_FALSE(File->isApplicationExtensionSafe()); 171 EXPECT_FALSE(File->isInstallAPI()); 172 EXPECT_EQ(0U, File->allowableClients().size()); 173 EXPECT_EQ(0U, File->reexportedLibraries().size()); 174 } 175 176 // Disable test for windows. 177 #ifndef _WIN32 178 TEST(TBDv2, WriteFile) { 179 static const char tbd_v2_file3[] = 180 "--- !tapi-tbd-v2\n" 181 "archs: [ i386, x86_64 ]\n" 182 "platform: macosx\n" 183 "install-name: '/usr/lib/libfoo.dylib'\n" 184 "current-version: 1.2.3\n" 185 "compatibility-version: 0\n" 186 "swift-version: 5\n" 187 "exports: \n" 188 " - archs: [ i386 ]\n" 189 " symbols: [ _sym1 ]\n" 190 " weak-def-symbols: [ _sym2 ]\n" 191 " thread-local-symbols: [ _sym3 ]\n" 192 " - archs: [ x86_64 ]\n" 193 " allowable-clients: [ clientA ]\n" 194 " re-exports: [ '/usr/lib/libfoo.dylib' ]\n" 195 " symbols: [ '_OBJC_EHTYPE_$_Class1' ]\n" 196 " objc-classes: [ _Class1 ]\n" 197 " objc-ivars: [ _Class1._ivar1 ]\n" 198 "...\n"; 199 200 InterfaceFile File; 201 File.setPath("libfoo.dylib"); 202 File.setInstallName("/usr/lib/libfoo.dylib"); 203 File.setFileType(FileType::TBD_V2); 204 File.setArchitectures(Architecture::i386 | Architecture::x86_64); 205 File.setPlatform(PlatformKind::macOS); 206 File.setCurrentVersion(PackedVersion(1, 2, 3)); 207 File.setTwoLevelNamespace(); 208 File.setApplicationExtensionSafe(); 209 File.setSwiftABIVersion(5); 210 File.setObjCConstraint(ObjCConstraintType::Retain_Release); 211 File.addAllowableClient("clientA", Architecture::x86_64); 212 File.addReexportedLibrary("/usr/lib/libfoo.dylib", Architecture::x86_64); 213 File.addSymbol(SymbolKind::GlobalSymbol, "_sym1", Architecture::i386); 214 File.addSymbol(SymbolKind::GlobalSymbol, "_sym2", Architecture::i386, 215 SymbolFlags::WeakDefined); 216 File.addSymbol(SymbolKind::GlobalSymbol, "_sym3", Architecture::i386, 217 SymbolFlags::ThreadLocalValue); 218 File.addSymbol(SymbolKind::ObjectiveCClass, "Class1", Architecture::x86_64); 219 File.addSymbol(SymbolKind::ObjectiveCClassEHType, "Class1", 220 Architecture::x86_64); 221 File.addSymbol(SymbolKind::ObjectiveCInstanceVariable, "Class1._ivar1", 222 Architecture::x86_64); 223 224 SmallString<4096> Buffer; 225 raw_svector_ostream OS(Buffer); 226 auto Result = TextAPIWriter::writeToStream(OS, File); 227 EXPECT_FALSE(Result); 228 EXPECT_STREQ(tbd_v2_file3, Buffer.c_str()); 229 } 230 #endif // _WIN32 231 232 TEST(TBDv2, Platform_macOS) { 233 static const char tbd_v1_platform_macos[] = "--- !tapi-tbd-v2\n" 234 "archs: [ x86_64 ]\n" 235 "platform: macosx\n" 236 "install-name: Test.dylib\n" 237 "...\n"; 238 239 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_macos, "Test.tbd"); 240 auto Result = TextAPIReader::get(std::move(Buffer)); 241 EXPECT_TRUE(!!Result); 242 auto File = std::move(Result.get()); 243 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 244 EXPECT_EQ(PlatformKind::macOS, File->getPlatform()); 245 } 246 247 TEST(TBDv2, Platform_iOS) { 248 static const char tbd_v1_platform_ios[] = "--- !tapi-tbd-v2\n" 249 "archs: [ arm64 ]\n" 250 "platform: ios\n" 251 "install-name: Test.dylib\n" 252 "...\n"; 253 254 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_ios, "Test.tbd"); 255 auto Result = TextAPIReader::get(std::move(Buffer)); 256 EXPECT_TRUE(!!Result); 257 auto File = std::move(Result.get()); 258 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 259 EXPECT_EQ(PlatformKind::iOS, File->getPlatform()); 260 } 261 262 TEST(TBDv2, Platform_watchOS) { 263 static const char tbd_v1_platform_watchos[] = "--- !tapi-tbd-v2\n" 264 "archs: [ armv7k ]\n" 265 "platform: watchos\n" 266 "install-name: Test.dylib\n" 267 "...\n"; 268 269 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_watchos, "Test.tbd"); 270 auto Result = TextAPIReader::get(std::move(Buffer)); 271 EXPECT_TRUE(!!Result); 272 auto File = std::move(Result.get()); 273 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 274 EXPECT_EQ(PlatformKind::watchOS, File->getPlatform()); 275 } 276 277 TEST(TBDv2, Platform_tvOS) { 278 static const char tbd_v1_platform_tvos[] = "--- !tapi-tbd-v2\n" 279 "archs: [ arm64 ]\n" 280 "platform: tvos\n" 281 "install-name: Test.dylib\n" 282 "...\n"; 283 284 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_platform_tvos, "Test.tbd"); 285 auto Result = TextAPIReader::get(std::move(Buffer)); 286 EXPECT_TRUE(!!Result); 287 auto File = std::move(Result.get()); 288 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 289 EXPECT_EQ(PlatformKind::tvOS, File->getPlatform()); 290 } 291 292 TEST(TBDv2, Platform_bridgeOS) { 293 static const char tbd_v1_platform_bridgeos[] = "--- !tapi-tbd-v2\n" 294 "archs: [ armv7k ]\n" 295 "platform: bridgeos\n" 296 "install-name: Test.dylib\n" 297 "...\n"; 298 299 auto Buffer = 300 MemoryBuffer::getMemBuffer(tbd_v1_platform_bridgeos, "Test.tbd"); 301 auto Result = TextAPIReader::get(std::move(Buffer)); 302 EXPECT_TRUE(!!Result); 303 auto File = std::move(Result.get()); 304 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 305 EXPECT_EQ(PlatformKind::bridgeOS, File->getPlatform()); 306 } 307 308 TEST(TBDv2, Swift_1_0) { 309 static const char tbd_v1_swift_1_0[] = "--- !tapi-tbd-v2\n" 310 "archs: [ arm64 ]\n" 311 "platform: ios\n" 312 "install-name: Test.dylib\n" 313 "swift-version: 1.0\n" 314 "...\n"; 315 316 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_0, "Test.tbd"); 317 auto Result = TextAPIReader::get(std::move(Buffer)); 318 EXPECT_TRUE(!!Result); 319 auto File = std::move(Result.get()); 320 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 321 EXPECT_EQ(1U, File->getSwiftABIVersion()); 322 } 323 324 TEST(TBDv2, Swift_1_1) { 325 static const char tbd_v1_swift_1_1[] = "--- !tapi-tbd-v2\n" 326 "archs: [ arm64 ]\n" 327 "platform: ios\n" 328 "install-name: Test.dylib\n" 329 "swift-version: 1.1\n" 330 "...\n"; 331 332 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_1_1, "Test.tbd"); 333 auto Result = TextAPIReader::get(std::move(Buffer)); 334 EXPECT_TRUE(!!Result); 335 auto File = std::move(Result.get()); 336 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 337 EXPECT_EQ(2U, File->getSwiftABIVersion()); 338 } 339 340 TEST(TBDv2, Swift_2_0) { 341 static const char tbd_v1_swift_2_0[] = "--- !tapi-tbd-v2\n" 342 "archs: [ arm64 ]\n" 343 "platform: ios\n" 344 "install-name: Test.dylib\n" 345 "swift-version: 2.0\n" 346 "...\n"; 347 348 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_2_0, "Test.tbd"); 349 auto Result = TextAPIReader::get(std::move(Buffer)); 350 EXPECT_TRUE(!!Result); 351 auto File = std::move(Result.get()); 352 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 353 EXPECT_EQ(3U, File->getSwiftABIVersion()); 354 } 355 356 TEST(TBDv2, Swift_3_0) { 357 static const char tbd_v1_swift_3_0[] = "--- !tapi-tbd-v2\n" 358 "archs: [ arm64 ]\n" 359 "platform: ios\n" 360 "install-name: Test.dylib\n" 361 "swift-version: 3.0\n" 362 "...\n"; 363 364 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_3_0, "Test.tbd"); 365 auto Result = TextAPIReader::get(std::move(Buffer)); 366 EXPECT_TRUE(!!Result); 367 auto File = std::move(Result.get()); 368 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 369 EXPECT_EQ(4U, File->getSwiftABIVersion()); 370 } 371 372 TEST(TBDv2, Swift_4_0) { 373 static const char tbd_v1_swift_4_0[] = "--- !tapi-tbd-v2\n" 374 "archs: [ arm64 ]\n" 375 "platform: ios\n" 376 "install-name: Test.dylib\n" 377 "swift-version: 4.0\n" 378 "...\n"; 379 380 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_4_0, "Test.tbd"); 381 auto Result = TextAPIReader::get(std::move(Buffer)); 382 EXPECT_FALSE(!!Result); 383 auto errorMessage = toString(Result.takeError()); 384 EXPECT_EQ("malformed file\nTest.tbd:5:16: error: invalid Swift ABI " 385 "version.\nswift-version: 4.0\n ^~~\n", 386 errorMessage); 387 } 388 389 TEST(TBDv2, Swift_5) { 390 static const char tbd_v1_swift_5[] = "--- !tapi-tbd-v2\n" 391 "archs: [ arm64 ]\n" 392 "platform: ios\n" 393 "install-name: Test.dylib\n" 394 "swift-version: 5\n" 395 "...\n"; 396 397 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_5, "Test.tbd"); 398 auto Result = TextAPIReader::get(std::move(Buffer)); 399 EXPECT_TRUE(!!Result); 400 auto File = std::move(Result.get()); 401 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 402 EXPECT_EQ(5U, File->getSwiftABIVersion()); 403 } 404 405 TEST(TBDv2, Swift_99) { 406 static const char tbd_v1_swift_99[] = "--- !tapi-tbd-v2\n" 407 "archs: [ arm64 ]\n" 408 "platform: ios\n" 409 "install-name: Test.dylib\n" 410 "swift-version: 99\n" 411 "...\n"; 412 413 auto Buffer = MemoryBuffer::getMemBuffer(tbd_v1_swift_99, "Test.tbd"); 414 auto Result = TextAPIReader::get(std::move(Buffer)); 415 EXPECT_TRUE(!!Result); 416 auto File = std::move(Result.get()); 417 EXPECT_EQ(FileType::TBD_V2, File->getFileType()); 418 EXPECT_EQ(99U, File->getSwiftABIVersion()); 419 } 420 421 TEST(TBDv2, UnknownArchitecture) { 422 static const char tbd_v2_file_unknown_architecture[] = 423 "--- !tapi-tbd-v2\n" 424 "archs: [ foo ]\n" 425 "platform: macosx\n" 426 "install-name: Test.dylib\n" 427 "...\n"; 428 429 auto Buffer = 430 MemoryBuffer::getMemBuffer(tbd_v2_file_unknown_architecture, "Test.tbd"); 431 auto Result = TextAPIReader::get(std::move(Buffer)); 432 EXPECT_TRUE(!!Result); 433 } 434 435 TEST(TBDv2, UnknownPlatform) { 436 static const char tbd_v2_file_unknown_platform[] = "--- !tapi-tbd-v2\n" 437 "archs: [ i386 ]\n" 438 "platform: newOS\n" 439 "...\n"; 440 441 auto Buffer = 442 MemoryBuffer::getMemBuffer(tbd_v2_file_unknown_platform, "Test.tbd"); 443 auto Result = TextAPIReader::get(std::move(Buffer)); 444 EXPECT_FALSE(!!Result); 445 auto errorMessage = toString(Result.takeError()); 446 EXPECT_EQ("malformed file\nTest.tbd:3:11: error: unknown platform\nplatform: " 447 "newOS\n ^~~~~\n", 448 errorMessage); 449 } 450 451 TEST(TBDv2, MalformedFile1) { 452 static const char malformed_file1[] = "--- !tapi-tbd-v2\n" 453 "archs: [ arm64 ]\n" 454 "foobar: \"Unsupported key\"\n" 455 "...\n"; 456 457 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file1, "Test.tbd"); 458 auto Result = TextAPIReader::get(std::move(Buffer)); 459 EXPECT_FALSE(!!Result); 460 auto errorMessage = toString(Result.takeError()); 461 ASSERT_EQ("malformed file\nTest.tbd:2:1: error: missing required key " 462 "'platform'\narchs: [ arm64 ]\n^\n", 463 errorMessage); 464 } 465 466 TEST(TBDv2, MalformedFile2) { 467 static const char malformed_file2[] = "--- !tapi-tbd-v2\n" 468 "archs: [ arm64 ]\n" 469 "platform: ios\n" 470 "install-name: Test.dylib\n" 471 "foobar: \"Unsupported key\"\n" 472 "...\n"; 473 474 auto Buffer = MemoryBuffer::getMemBuffer(malformed_file2, "Test.tbd"); 475 auto Result = TextAPIReader::get(std::move(Buffer)); 476 EXPECT_FALSE(!!Result); 477 auto errorMessage = toString(Result.takeError()); 478 ASSERT_EQ( 479 "malformed file\nTest.tbd:5:9: error: unknown key 'foobar'\nfoobar: " 480 "\"Unsupported key\"\n ^~~~~~~~~~~~~~~~~\n", 481 errorMessage); 482 } 483 484 } // namespace TBDv2 485