1 //===- unittest/Support/YAMLRemarksParsingTest.cpp - OptTable 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-c/Remarks.h"
10 #include "llvm/Remarks/Remark.h"
11 #include "llvm/Remarks/RemarkParser.h"
12 #include "gtest/gtest.h"
17 template <size_t N
> void parseGood(const char (&Buf
)[N
]) {
18 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
19 remarks::createRemarkParser(remarks::Format::YAML
, {Buf
, N
- 1});
20 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
21 EXPECT_TRUE(*MaybeParser
!= nullptr);
23 remarks::RemarkParser
&Parser
= **MaybeParser
;
24 Expected
<std::unique_ptr
<remarks::Remark
>> Remark
= Parser
.next();
25 EXPECT_FALSE(errorToBool(Remark
.takeError())); // Check for parsing errors.
26 EXPECT_TRUE(*Remark
!= nullptr); // At least one remark.
27 Remark
= Parser
.next();
28 Error E
= Remark
.takeError();
29 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
30 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
33 void parseGoodMeta(StringRef Buf
) {
34 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
35 remarks::createRemarkParserFromMeta(remarks::Format::YAML
, Buf
);
36 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
37 EXPECT_TRUE(*MaybeParser
!= nullptr);
39 remarks::RemarkParser
&Parser
= **MaybeParser
;
40 Expected
<std::unique_ptr
<remarks::Remark
>> Remark
= Parser
.next();
41 EXPECT_FALSE(errorToBool(Remark
.takeError())); // Check for parsing errors.
42 EXPECT_TRUE(*Remark
!= nullptr); // At least one remark.
43 Remark
= Parser
.next();
44 Error E
= Remark
.takeError();
45 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
46 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
50 bool parseExpectError(const char (&Buf
)[N
], const char *Error
) {
51 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
52 remarks::createRemarkParser(remarks::Format::YAML
, {Buf
, N
- 1});
53 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
54 EXPECT_TRUE(*MaybeParser
!= nullptr);
56 remarks::RemarkParser
&Parser
= **MaybeParser
;
57 Expected
<std::unique_ptr
<remarks::Remark
>> Remark
= Parser
.next();
58 EXPECT_FALSE(Remark
); // Check for parsing errors.
61 raw_string_ostream
Stream(ErrorStr
);
62 handleAllErrors(Remark
.takeError(),
63 [&](const ErrorInfoBase
&EIB
) { EIB
.log(Stream
); });
64 return StringRef(Stream
.str()).contains(Error
);
72 void parseExpectErrorMeta(
73 StringRef Buf
, const char *Error
, CmpType Cmp
,
74 std::optional
<StringRef
> ExternalFilePrependPath
= std::nullopt
) {
76 raw_string_ostream
Stream(ErrorStr
);
78 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
79 remarks::createRemarkParserFromMeta(remarks::Format::YAML
, Buf
,
80 /*StrTab=*/std::nullopt
,
81 std::move(ExternalFilePrependPath
));
82 handleAllErrors(MaybeParser
.takeError(),
83 [&](const ErrorInfoBase
&EIB
) { EIB
.log(Stream
); });
85 // Use a case insensitive comparision due to case differences in error strings
87 if (Cmp
== CmpType::Equal
) {
88 EXPECT_EQ(StringRef(Stream
.str()).lower(), StringRef(Error
).lower());
91 if (Cmp
== CmpType::Contains
) {
92 EXPECT_TRUE(StringRef(Stream
.str()).contains(StringRef(Error
)));
96 TEST(YAMLRemarks
, ParsingEmpty
) {
97 EXPECT_TRUE(parseExpectError("\n\n", "document root is not of mapping type."));
100 TEST(YAMLRemarks
, ParsingNotYAML
) {
102 parseExpectError("\x01\x02\x03\x04\x05\x06", "Got empty plain scalar"));
105 TEST(YAMLRemarks
, ParsingGood
) {
109 "Name: NoDefinition\n"
110 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
114 " - String: ' will not be inlined into '\n"
116 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
117 " - String: ' because its definition is unavailable'\n"
120 // No debug loc should also pass.
124 "Name: NoDefinition\n"
128 " - String: ' will not be inlined into '\n"
130 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
131 " - String: ' because its definition is unavailable'\n"
134 // No args is also ok.
138 "Name: NoDefinition\n"
139 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
146 "DebugLoc: { Line: 3, Column: 12, File: file.c }\n"
148 "Name: NoDefinition\n"
151 " - String: ' will not be inlined into '\n"
153 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
154 " - String: ' because its definition is unavailable'\n"
162 "Name: NoDefinition\n"
164 " - String: |\n \n \n blocks\n"
169 // Mandatory common part of a remark.
170 #define COMMON_REMARK "\nPass: inline\nName: NoDefinition\nFunction: foo\n\n"
171 // Test all the types.
172 TEST(YAMLRemarks
, ParsingTypes
) {
174 parseGood("--- !Passed" COMMON_REMARK
);
176 parseGood("--- !Missed" COMMON_REMARK
);
178 parseGood("--- !Analysis" COMMON_REMARK
);
179 // Type: AnalysisFPCommute
180 parseGood("--- !AnalysisFPCommute" COMMON_REMARK
);
181 // Type: AnalysisAliasing
182 parseGood("--- !AnalysisAliasing" COMMON_REMARK
);
184 parseGood("--- !Failure" COMMON_REMARK
);
188 TEST(YAMLRemarks
, ParsingMissingFields
) {
190 EXPECT_TRUE(parseExpectError("\n"
193 "Name: NoDefinition\n"
196 "expected a remark tag."));
198 EXPECT_TRUE(parseExpectError("\n"
200 "Name: NoDefinition\n"
203 "Type, Pass, Name or Function missing."));
205 EXPECT_TRUE(parseExpectError("\n"
210 "Type, Pass, Name or Function missing."));
212 EXPECT_TRUE(parseExpectError("\n"
215 "Name: NoDefinition\n"
217 "Type, Pass, Name or Function missing."));
218 // Debug loc but no file.
219 EXPECT_TRUE(parseExpectError("\n"
222 "Name: NoDefinition\n"
224 "DebugLoc: { Line: 3, Column: 12 }\n"
226 "DebugLoc node incomplete."));
227 // Debug loc but no line.
228 EXPECT_TRUE(parseExpectError("\n"
231 "Name: NoDefinition\n"
233 "DebugLoc: { File: file.c, Column: 12 }\n"
235 "DebugLoc node incomplete."));
236 // Debug loc but no column.
237 EXPECT_TRUE(parseExpectError("\n"
240 "Name: NoDefinition\n"
242 "DebugLoc: { File: file.c, Line: 3 }\n"
244 "DebugLoc node incomplete."));
247 TEST(YAMLRemarks
, ParsingWrongTypes
) {
248 // Wrong debug loc type.
249 EXPECT_TRUE(parseExpectError("\n"
252 "Name: NoDefinition\n"
256 "expected a value of mapping type."));
258 EXPECT_TRUE(parseExpectError("\n"
261 "Name: NoDefinition\n"
263 "DebugLoc: { File: file.c, Line: b, Column: 12 }\n"
265 "expected a value of integer type."));
266 // Wrong column type.
267 EXPECT_TRUE(parseExpectError("\n"
270 "Name: NoDefinition\n"
272 "DebugLoc: { File: file.c, Line: 3, Column: c }\n"
274 "expected a value of integer type."));
276 EXPECT_TRUE(parseExpectError("\n"
279 "Name: NoDefinition\n"
283 "wrong value type for key."));
285 EXPECT_TRUE(parseExpectError("\n"
288 "Name: NoDefinition\n"
291 "key is not a string."));
292 // Debug loc with unknown entry.
293 EXPECT_TRUE(parseExpectError("\n"
296 "Name: NoDefinition\n"
298 "DebugLoc: { File: file.c, Column: 12, Unknown: 12 }\n"
300 "unknown entry in DebugLoc map."));
302 EXPECT_TRUE(parseExpectError("\n"
308 EXPECT_TRUE(parseExpectError("\n"
310 "Pass: { File: a, Line: 1, Column: 2 }\n"
311 "Name: NoDefinition\n"
314 "expected a value of scalar type."));
315 // Not a string file in debug loc.
316 EXPECT_TRUE(parseExpectError("\n"
319 "Name: NoDefinition\n"
321 "DebugLoc: { File: { a: b }, Column: 12, Line: 12 }\n"
323 "expected a value of scalar type."));
324 // Not a integer column in debug loc.
325 EXPECT_TRUE(parseExpectError("\n"
328 "Name: NoDefinition\n"
330 "DebugLoc: { File: file.c, Column: { a: b }, Line: 12 }\n"
332 "expected a value of scalar type."));
333 // Not a integer line in debug loc.
334 EXPECT_TRUE(parseExpectError("\n"
337 "Name: NoDefinition\n"
339 "DebugLoc: { File: file.c, Column: 12, Line: { a: b } }\n"
341 "expected a value of scalar type."));
342 // Not a mapping type value for args.
343 EXPECT_TRUE(parseExpectError("\n"
346 "Name: NoDefinition\n"
348 "DebugLoc: { File: file.c, Column: 12, Line: { a: b } }\n"
350 "expected a value of scalar type."));
353 TEST(YAMLRemarks
, ParsingWrongArgs
) {
354 // Multiple debug locs per arg.
355 EXPECT_TRUE(parseExpectError("\n"
358 "Name: NoDefinition\n"
362 " DebugLoc: { File: a, Line: 1, Column: 2 }\n"
363 " DebugLoc: { File: a, Line: 1, Column: 2 }\n"
365 "only one DebugLoc entry is allowed per argument."));
366 // Multiple strings per arg.
367 EXPECT_TRUE(parseExpectError("\n"
370 "Name: NoDefinition\n"
375 " DebugLoc: { File: a, Line: 1, Column: 2 }\n"
377 "only one string entry is allowed per argument."));
379 EXPECT_TRUE(parseExpectError("\n"
382 "Name: NoDefinition\n"
385 " - DebugLoc: { File: a, Line: 1, Column: 2 }\n"
387 "argument key is missing."));
390 static inline StringRef
checkStr(StringRef Str
, unsigned ExpectedLen
) {
391 const char *StrData
= Str
.data();
392 unsigned StrLen
= Str
.size();
393 EXPECT_EQ(StrLen
, ExpectedLen
);
394 return StringRef(StrData
, StrLen
);
397 TEST(YAMLRemarks
, Contents
) {
401 "Name: NoDefinition\n"
402 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
407 " - String: ' will not be inlined into '\n"
409 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
410 " - String: ' because its definition is unavailable'\n"
413 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
414 remarks::createRemarkParser(remarks::Format::YAML
, Buf
);
415 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
416 EXPECT_TRUE(*MaybeParser
!= nullptr);
418 remarks::RemarkParser
&Parser
= **MaybeParser
;
419 Expected
<std::unique_ptr
<remarks::Remark
>> MaybeRemark
= Parser
.next();
421 errorToBool(MaybeRemark
.takeError())); // Check for parsing errors.
422 EXPECT_TRUE(*MaybeRemark
!= nullptr); // At least one remark.
424 const remarks::Remark
&Remark
= **MaybeRemark
;
425 EXPECT_EQ(Remark
.RemarkType
, remarks::Type::Missed
);
426 EXPECT_EQ(checkStr(Remark
.PassName
, 6), "inline");
427 EXPECT_EQ(checkStr(Remark
.RemarkName
, 12), "NoDefinition");
428 EXPECT_EQ(checkStr(Remark
.FunctionName
, 3), "foo");
429 EXPECT_TRUE(Remark
.Loc
);
430 const remarks::RemarkLocation
&RL
= *Remark
.Loc
;
431 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
432 EXPECT_EQ(RL
.SourceLine
, 3U);
433 EXPECT_EQ(RL
.SourceColumn
, 12U);
434 EXPECT_TRUE(Remark
.Hotness
);
435 EXPECT_EQ(*Remark
.Hotness
, 4U);
436 EXPECT_EQ(Remark
.Args
.size(), 4U);
439 for (const remarks::Argument
&Arg
: Remark
.Args
) {
442 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Callee");
443 EXPECT_EQ(checkStr(Arg
.Val
, 3), "bar");
444 EXPECT_FALSE(Arg
.Loc
);
447 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
448 EXPECT_EQ(checkStr(Arg
.Val
, 26), " will not be inlined into ");
449 EXPECT_FALSE(Arg
.Loc
);
452 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Caller");
453 EXPECT_EQ(checkStr(Arg
.Val
, 3), "foo");
454 EXPECT_TRUE(Arg
.Loc
);
455 const remarks::RemarkLocation
&RL
= *Arg
.Loc
;
456 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
457 EXPECT_EQ(RL
.SourceLine
, 2U);
458 EXPECT_EQ(RL
.SourceColumn
, 0U);
462 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
463 EXPECT_EQ(checkStr(Arg
.Val
, 38),
464 " because its definition is unavailable");
465 EXPECT_FALSE(Arg
.Loc
);
473 MaybeRemark
= Parser
.next();
474 Error E
= MaybeRemark
.takeError();
475 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
476 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
479 static inline StringRef
checkStr(LLVMRemarkStringRef Str
,
480 unsigned ExpectedLen
) {
481 const char *StrData
= LLVMRemarkStringGetData(Str
);
482 unsigned StrLen
= LLVMRemarkStringGetLen(Str
);
483 EXPECT_EQ(StrLen
, ExpectedLen
);
484 return StringRef(StrData
, StrLen
);
487 TEST(YAMLRemarks
, ContentsCAPI
) {
491 "Name: NoDefinition\n"
492 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
496 " - String: ' will not be inlined into '\n"
498 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
499 " - String: ' because its definition is unavailable'\n"
502 LLVMRemarkParserRef Parser
=
503 LLVMRemarkParserCreateYAML(Buf
.data(), Buf
.size());
504 LLVMRemarkEntryRef Remark
= LLVMRemarkParserGetNext(Parser
);
505 EXPECT_FALSE(Remark
== nullptr);
506 EXPECT_EQ(LLVMRemarkEntryGetType(Remark
), LLVMRemarkTypeMissed
);
507 EXPECT_EQ(checkStr(LLVMRemarkEntryGetPassName(Remark
), 6), "inline");
508 EXPECT_EQ(checkStr(LLVMRemarkEntryGetRemarkName(Remark
), 12), "NoDefinition");
509 EXPECT_EQ(checkStr(LLVMRemarkEntryGetFunctionName(Remark
), 3), "foo");
510 LLVMRemarkDebugLocRef DL
= LLVMRemarkEntryGetDebugLoc(Remark
);
511 EXPECT_EQ(checkStr(LLVMRemarkDebugLocGetSourceFilePath(DL
), 6), "file.c");
512 EXPECT_EQ(LLVMRemarkDebugLocGetSourceLine(DL
), 3U);
513 EXPECT_EQ(LLVMRemarkDebugLocGetSourceColumn(DL
), 12U);
514 EXPECT_EQ(LLVMRemarkEntryGetHotness(Remark
), 0U);
515 EXPECT_EQ(LLVMRemarkEntryGetNumArgs(Remark
), 4U);
518 LLVMRemarkArgRef Arg
= LLVMRemarkEntryGetFirstArg(Remark
);
522 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "Callee");
523 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 3), "bar");
524 EXPECT_EQ(LLVMRemarkArgGetDebugLoc(Arg
), nullptr);
527 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "String");
528 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 26),
529 " will not be inlined into ");
530 EXPECT_EQ(LLVMRemarkArgGetDebugLoc(Arg
), nullptr);
533 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "Caller");
534 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 3), "foo");
535 LLVMRemarkDebugLocRef DL
= LLVMRemarkArgGetDebugLoc(Arg
);
536 EXPECT_EQ(checkStr(LLVMRemarkDebugLocGetSourceFilePath(DL
), 6), "file.c");
537 EXPECT_EQ(LLVMRemarkDebugLocGetSourceLine(DL
), 2U);
538 EXPECT_EQ(LLVMRemarkDebugLocGetSourceColumn(DL
), 0U);
542 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "String");
543 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 38),
544 " because its definition is unavailable");
545 EXPECT_EQ(LLVMRemarkArgGetDebugLoc(Arg
), nullptr);
551 } while ((Arg
= LLVMRemarkEntryGetNextArg(Arg
, Remark
)));
553 LLVMRemarkEntryDispose(Remark
);
555 EXPECT_EQ(LLVMRemarkParserGetNext(Parser
), nullptr);
557 EXPECT_FALSE(LLVMRemarkParserHasError(Parser
));
558 LLVMRemarkParserDispose(Parser
);
561 TEST(YAMLRemarks
, ContentsStrTab
) {
566 "DebugLoc: { File: 2, Line: 3, Column: 12 }\n"
573 " DebugLoc: { File: 2, Line: 2, Column: 0 }\n"
577 StringRef StrTabBuf
=
578 StringRef("inline\0NoDefinition\0file.c\0foo\0Callee\0bar\0String\0 "
579 "will not be inlined into \0 because its definition is "
583 remarks::ParsedStringTable
StrTab(StrTabBuf
);
584 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
585 remarks::createRemarkParser(remarks::Format::YAMLStrTab
, Buf
,
587 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
588 EXPECT_TRUE(*MaybeParser
!= nullptr);
590 remarks::RemarkParser
&Parser
= **MaybeParser
;
591 Expected
<std::unique_ptr
<remarks::Remark
>> MaybeRemark
= Parser
.next();
593 errorToBool(MaybeRemark
.takeError())); // Check for parsing errors.
594 EXPECT_TRUE(*MaybeRemark
!= nullptr); // At least one remark.
596 const remarks::Remark
&Remark
= **MaybeRemark
;
597 EXPECT_EQ(Remark
.RemarkType
, remarks::Type::Missed
);
598 EXPECT_EQ(checkStr(Remark
.PassName
, 6), "inline");
599 EXPECT_EQ(checkStr(Remark
.RemarkName
, 12), "NoDefinition");
600 EXPECT_EQ(checkStr(Remark
.FunctionName
, 3), "foo");
601 EXPECT_TRUE(Remark
.Loc
);
602 const remarks::RemarkLocation
&RL
= *Remark
.Loc
;
603 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
604 EXPECT_EQ(RL
.SourceLine
, 3U);
605 EXPECT_EQ(RL
.SourceColumn
, 12U);
606 EXPECT_TRUE(Remark
.Hotness
);
607 EXPECT_EQ(*Remark
.Hotness
, 4U);
608 EXPECT_EQ(Remark
.Args
.size(), 4U);
611 for (const remarks::Argument
&Arg
: Remark
.Args
) {
614 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Callee");
615 EXPECT_EQ(checkStr(Arg
.Val
, 3), "bar");
616 EXPECT_FALSE(Arg
.Loc
);
619 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
620 EXPECT_EQ(checkStr(Arg
.Val
, 26), " will not be inlined into ");
621 EXPECT_FALSE(Arg
.Loc
);
624 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Caller");
625 EXPECT_EQ(checkStr(Arg
.Val
, 3), "foo");
626 EXPECT_TRUE(Arg
.Loc
);
627 const remarks::RemarkLocation
&RL
= *Arg
.Loc
;
628 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
629 EXPECT_EQ(RL
.SourceLine
, 2U);
630 EXPECT_EQ(RL
.SourceColumn
, 0U);
634 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
635 EXPECT_EQ(checkStr(Arg
.Val
, 38),
636 " because its definition is unavailable");
637 EXPECT_FALSE(Arg
.Loc
);
645 MaybeRemark
= Parser
.next();
646 Error E
= MaybeRemark
.takeError();
647 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
648 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
651 TEST(YAMLRemarks
, ParsingBadStringTableIndex
) {
657 StringRef StrTabBuf
= StringRef("inline");
659 remarks::ParsedStringTable
StrTab(StrTabBuf
);
660 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
661 remarks::createRemarkParser(remarks::Format::YAMLStrTab
, Buf
,
663 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
664 EXPECT_TRUE(*MaybeParser
!= nullptr);
666 remarks::RemarkParser
&Parser
= **MaybeParser
;
667 Expected
<std::unique_ptr
<remarks::Remark
>> MaybeRemark
= Parser
.next();
668 EXPECT_FALSE(MaybeRemark
); // Expect an error here.
670 std::string ErrorStr
;
671 raw_string_ostream
Stream(ErrorStr
);
672 handleAllErrors(MaybeRemark
.takeError(),
673 [&](const ErrorInfoBase
&EIB
) { EIB
.log(Stream
); });
675 StringRef(Stream
.str())
676 .contains("String with index 50 is out of bounds (size = 1)."));
679 TEST(YAMLRemarks
, ParsingGoodMeta
) {
680 // No metadata should also work.
681 parseGoodMeta("--- !Missed\n"
683 "Name: NoDefinition\n"
687 parseGoodMeta(StringRef("REMARKS\0"
692 "Name: NoDefinition\n"
696 // Use the string table from the metadata.
697 parseGoodMeta(StringRef("REMARKS\0"
708 TEST(YAMLRemarks
, ParsingBadMeta
) {
709 parseExpectErrorMeta(StringRef("REMARKSS", 9),
710 "Expecting \\0 after magic number.", CmpType::Equal
);
712 parseExpectErrorMeta(StringRef("REMARKS\0", 8), "Expecting version number.",
715 parseExpectErrorMeta(StringRef("REMARKS\0"
716 "\x09\0\0\0\0\0\0\0",
718 "Mismatching remark version. Got 9, expected 0.",
721 parseExpectErrorMeta(StringRef("REMARKS\0"
724 "Expecting string table size.", CmpType::Equal
);
726 parseExpectErrorMeta(StringRef("REMARKS\0"
728 "\x01\0\0\0\0\0\0\0",
730 "Expecting string table.", CmpType::Equal
);
732 parseExpectErrorMeta(StringRef("REMARKS\0"
737 "'/path/'", CmpType::Contains
);
739 parseExpectErrorMeta(StringRef("REMARKS\0"
744 "'/baddir/path/'", CmpType::Contains
,
745 StringRef("/baddir/"));