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"
16 template <size_t N
> void parseGood(const char (&Buf
)[N
]) {
17 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
18 remarks::createRemarkParser(remarks::Format::YAML
, {Buf
, N
- 1});
19 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
20 EXPECT_TRUE(*MaybeParser
!= nullptr);
22 remarks::RemarkParser
&Parser
= **MaybeParser
;
23 Expected
<std::unique_ptr
<remarks::Remark
>> Remark
= Parser
.next();
24 EXPECT_FALSE(errorToBool(Remark
.takeError())); // Check for parsing errors.
25 EXPECT_TRUE(*Remark
!= nullptr); // At least one remark.
26 Remark
= Parser
.next();
27 Error E
= Remark
.takeError();
28 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
29 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
32 void parseGoodMeta(StringRef Buf
) {
33 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
34 remarks::createRemarkParserFromMeta(remarks::Format::YAML
, Buf
);
35 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
36 EXPECT_TRUE(*MaybeParser
!= nullptr);
38 remarks::RemarkParser
&Parser
= **MaybeParser
;
39 Expected
<std::unique_ptr
<remarks::Remark
>> Remark
= Parser
.next();
40 EXPECT_FALSE(errorToBool(Remark
.takeError())); // Check for parsing errors.
41 EXPECT_TRUE(*Remark
!= nullptr); // At least one remark.
42 Remark
= Parser
.next();
43 Error E
= Remark
.takeError();
44 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
45 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
49 bool parseExpectError(const char (&Buf
)[N
], const char *Error
) {
50 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
51 remarks::createRemarkParser(remarks::Format::YAML
, {Buf
, N
- 1});
52 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
53 EXPECT_TRUE(*MaybeParser
!= nullptr);
55 remarks::RemarkParser
&Parser
= **MaybeParser
;
56 Expected
<std::unique_ptr
<remarks::Remark
>> Remark
= Parser
.next();
57 EXPECT_FALSE(Remark
); // Check for parsing errors.
60 raw_string_ostream
Stream(ErrorStr
);
61 handleAllErrors(Remark
.takeError(),
62 [&](const ErrorInfoBase
&EIB
) { EIB
.log(Stream
); });
63 return StringRef(Stream
.str()).contains(Error
);
71 void parseExpectErrorMeta(StringRef Buf
, const char *Error
, CmpType Cmp
,
72 Optional
<StringRef
> ExternalFilePrependPath
= None
) {
74 raw_string_ostream
Stream(ErrorStr
);
76 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
77 remarks::createRemarkParserFromMeta(remarks::Format::YAML
, Buf
,
79 std::move(ExternalFilePrependPath
));
80 handleAllErrors(MaybeParser
.takeError(),
81 [&](const ErrorInfoBase
&EIB
) { EIB
.log(Stream
); });
83 // Use a case insensitive comparision due to case differences in error strings
85 if (Cmp
== CmpType::Equal
) {
86 EXPECT_EQ(StringRef(Stream
.str()).lower(), StringRef(Error
).lower());
89 if (Cmp
== CmpType::Contains
) {
90 EXPECT_TRUE(StringRef(Stream
.str()).contains(StringRef(Error
)));
94 TEST(YAMLRemarks
, ParsingEmpty
) {
95 EXPECT_TRUE(parseExpectError("\n\n", "document root is not of mapping type."));
98 TEST(YAMLRemarks
, ParsingNotYAML
) {
100 parseExpectError("\x01\x02\x03\x04\x05\x06", "Got empty plain scalar"));
103 TEST(YAMLRemarks
, ParsingGood
) {
107 "Name: NoDefinition\n"
108 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
112 " - String: ' will not be inlined into '\n"
114 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
115 " - String: ' because its definition is unavailable'\n"
118 // No debug loc should also pass.
122 "Name: NoDefinition\n"
126 " - String: ' will not be inlined into '\n"
128 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
129 " - String: ' because its definition is unavailable'\n"
132 // No args is also ok.
136 "Name: NoDefinition\n"
137 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
144 "DebugLoc: { Line: 3, Column: 12, File: file.c }\n"
146 "Name: NoDefinition\n"
149 " - String: ' will not be inlined into '\n"
151 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
152 " - String: ' because its definition is unavailable'\n"
157 // Mandatory common part of a remark.
158 #define COMMON_REMARK "\nPass: inline\nName: NoDefinition\nFunction: foo\n\n"
159 // Test all the types.
160 TEST(YAMLRemarks
, ParsingTypes
) {
162 parseGood("--- !Passed" COMMON_REMARK
);
164 parseGood("--- !Missed" COMMON_REMARK
);
166 parseGood("--- !Analysis" COMMON_REMARK
);
167 // Type: AnalysisFPCommute
168 parseGood("--- !AnalysisFPCommute" COMMON_REMARK
);
169 // Type: AnalysisAliasing
170 parseGood("--- !AnalysisAliasing" COMMON_REMARK
);
172 parseGood("--- !Failure" COMMON_REMARK
);
176 TEST(YAMLRemarks
, ParsingMissingFields
) {
178 EXPECT_TRUE(parseExpectError("\n"
181 "Name: NoDefinition\n"
184 "expected a remark tag."));
186 EXPECT_TRUE(parseExpectError("\n"
188 "Name: NoDefinition\n"
191 "Type, Pass, Name or Function missing."));
193 EXPECT_TRUE(parseExpectError("\n"
198 "Type, Pass, Name or Function missing."));
200 EXPECT_TRUE(parseExpectError("\n"
203 "Name: NoDefinition\n"
205 "Type, Pass, Name or Function missing."));
206 // Debug loc but no file.
207 EXPECT_TRUE(parseExpectError("\n"
210 "Name: NoDefinition\n"
212 "DebugLoc: { Line: 3, Column: 12 }\n"
214 "DebugLoc node incomplete."));
215 // Debug loc but no line.
216 EXPECT_TRUE(parseExpectError("\n"
219 "Name: NoDefinition\n"
221 "DebugLoc: { File: file.c, Column: 12 }\n"
223 "DebugLoc node incomplete."));
224 // Debug loc but no column.
225 EXPECT_TRUE(parseExpectError("\n"
228 "Name: NoDefinition\n"
230 "DebugLoc: { File: file.c, Line: 3 }\n"
232 "DebugLoc node incomplete."));
235 TEST(YAMLRemarks
, ParsingWrongTypes
) {
236 // Wrong debug loc type.
237 EXPECT_TRUE(parseExpectError("\n"
240 "Name: NoDefinition\n"
244 "expected a value of mapping type."));
246 EXPECT_TRUE(parseExpectError("\n"
249 "Name: NoDefinition\n"
251 "DebugLoc: { File: file.c, Line: b, Column: 12 }\n"
253 "expected a value of integer type."));
254 // Wrong column type.
255 EXPECT_TRUE(parseExpectError("\n"
258 "Name: NoDefinition\n"
260 "DebugLoc: { File: file.c, Line: 3, Column: c }\n"
262 "expected a value of integer type."));
264 EXPECT_TRUE(parseExpectError("\n"
267 "Name: NoDefinition\n"
271 "wrong value type for key."));
273 EXPECT_TRUE(parseExpectError("\n"
276 "Name: NoDefinition\n"
279 "key is not a string."));
280 // Debug loc with unknown entry.
281 EXPECT_TRUE(parseExpectError("\n"
284 "Name: NoDefinition\n"
286 "DebugLoc: { File: file.c, Column: 12, Unknown: 12 }\n"
288 "unknown entry in DebugLoc map."));
290 EXPECT_TRUE(parseExpectError("\n"
296 EXPECT_TRUE(parseExpectError("\n"
298 "Pass: { File: a, Line: 1, Column: 2 }\n"
299 "Name: NoDefinition\n"
302 "expected a value of scalar type."));
303 // Not a string file in debug loc.
304 EXPECT_TRUE(parseExpectError("\n"
307 "Name: NoDefinition\n"
309 "DebugLoc: { File: { a: b }, Column: 12, Line: 12 }\n"
311 "expected a value of scalar type."));
312 // Not a integer column in debug loc.
313 EXPECT_TRUE(parseExpectError("\n"
316 "Name: NoDefinition\n"
318 "DebugLoc: { File: file.c, Column: { a: b }, Line: 12 }\n"
320 "expected a value of scalar type."));
321 // Not a integer line in debug loc.
322 EXPECT_TRUE(parseExpectError("\n"
325 "Name: NoDefinition\n"
327 "DebugLoc: { File: file.c, Column: 12, Line: { a: b } }\n"
329 "expected a value of scalar type."));
330 // Not a mapping type value for args.
331 EXPECT_TRUE(parseExpectError("\n"
334 "Name: NoDefinition\n"
336 "DebugLoc: { File: file.c, Column: 12, Line: { a: b } }\n"
338 "expected a value of scalar type."));
341 TEST(YAMLRemarks
, ParsingWrongArgs
) {
342 // Multiple debug locs per arg.
343 EXPECT_TRUE(parseExpectError("\n"
346 "Name: NoDefinition\n"
350 " DebugLoc: { File: a, Line: 1, Column: 2 }\n"
351 " DebugLoc: { File: a, Line: 1, Column: 2 }\n"
353 "only one DebugLoc entry is allowed per argument."));
354 // Multiple strings per arg.
355 EXPECT_TRUE(parseExpectError("\n"
358 "Name: NoDefinition\n"
363 " DebugLoc: { File: a, Line: 1, Column: 2 }\n"
365 "only one string entry is allowed per argument."));
367 EXPECT_TRUE(parseExpectError("\n"
370 "Name: NoDefinition\n"
373 " - DebugLoc: { File: a, Line: 1, Column: 2 }\n"
375 "argument key is missing."));
378 static inline StringRef
checkStr(StringRef Str
, unsigned ExpectedLen
) {
379 const char *StrData
= Str
.data();
380 unsigned StrLen
= Str
.size();
381 EXPECT_EQ(StrLen
, ExpectedLen
);
382 return StringRef(StrData
, StrLen
);
385 TEST(YAMLRemarks
, Contents
) {
389 "Name: NoDefinition\n"
390 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
395 " - String: ' will not be inlined into '\n"
397 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
398 " - String: ' because its definition is unavailable'\n"
401 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
402 remarks::createRemarkParser(remarks::Format::YAML
, Buf
);
403 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
404 EXPECT_TRUE(*MaybeParser
!= nullptr);
406 remarks::RemarkParser
&Parser
= **MaybeParser
;
407 Expected
<std::unique_ptr
<remarks::Remark
>> MaybeRemark
= Parser
.next();
409 errorToBool(MaybeRemark
.takeError())); // Check for parsing errors.
410 EXPECT_TRUE(*MaybeRemark
!= nullptr); // At least one remark.
412 const remarks::Remark
&Remark
= **MaybeRemark
;
413 EXPECT_EQ(Remark
.RemarkType
, remarks::Type::Missed
);
414 EXPECT_EQ(checkStr(Remark
.PassName
, 6), "inline");
415 EXPECT_EQ(checkStr(Remark
.RemarkName
, 12), "NoDefinition");
416 EXPECT_EQ(checkStr(Remark
.FunctionName
, 3), "foo");
417 EXPECT_TRUE(Remark
.Loc
);
418 const remarks::RemarkLocation
&RL
= *Remark
.Loc
;
419 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
420 EXPECT_EQ(RL
.SourceLine
, 3U);
421 EXPECT_EQ(RL
.SourceColumn
, 12U);
422 EXPECT_TRUE(Remark
.Hotness
);
423 EXPECT_EQ(*Remark
.Hotness
, 4U);
424 EXPECT_EQ(Remark
.Args
.size(), 4U);
427 for (const remarks::Argument
&Arg
: Remark
.Args
) {
430 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Callee");
431 EXPECT_EQ(checkStr(Arg
.Val
, 3), "bar");
432 EXPECT_FALSE(Arg
.Loc
);
435 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
436 EXPECT_EQ(checkStr(Arg
.Val
, 26), " will not be inlined into ");
437 EXPECT_FALSE(Arg
.Loc
);
440 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Caller");
441 EXPECT_EQ(checkStr(Arg
.Val
, 3), "foo");
442 EXPECT_TRUE(Arg
.Loc
);
443 const remarks::RemarkLocation
&RL
= *Arg
.Loc
;
444 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
445 EXPECT_EQ(RL
.SourceLine
, 2U);
446 EXPECT_EQ(RL
.SourceColumn
, 0U);
450 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
451 EXPECT_EQ(checkStr(Arg
.Val
, 38),
452 " because its definition is unavailable");
453 EXPECT_FALSE(Arg
.Loc
);
461 MaybeRemark
= Parser
.next();
462 Error E
= MaybeRemark
.takeError();
463 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
464 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
467 static inline StringRef
checkStr(LLVMRemarkStringRef Str
,
468 unsigned ExpectedLen
) {
469 const char *StrData
= LLVMRemarkStringGetData(Str
);
470 unsigned StrLen
= LLVMRemarkStringGetLen(Str
);
471 EXPECT_EQ(StrLen
, ExpectedLen
);
472 return StringRef(StrData
, StrLen
);
475 TEST(YAMLRemarks
, ContentsCAPI
) {
479 "Name: NoDefinition\n"
480 "DebugLoc: { File: file.c, Line: 3, Column: 12 }\n"
484 " - String: ' will not be inlined into '\n"
486 " DebugLoc: { File: file.c, Line: 2, Column: 0 }\n"
487 " - String: ' because its definition is unavailable'\n"
490 LLVMRemarkParserRef Parser
=
491 LLVMRemarkParserCreateYAML(Buf
.data(), Buf
.size());
492 LLVMRemarkEntryRef Remark
= LLVMRemarkParserGetNext(Parser
);
493 EXPECT_FALSE(Remark
== nullptr);
494 EXPECT_EQ(LLVMRemarkEntryGetType(Remark
), LLVMRemarkTypeMissed
);
495 EXPECT_EQ(checkStr(LLVMRemarkEntryGetPassName(Remark
), 6), "inline");
496 EXPECT_EQ(checkStr(LLVMRemarkEntryGetRemarkName(Remark
), 12), "NoDefinition");
497 EXPECT_EQ(checkStr(LLVMRemarkEntryGetFunctionName(Remark
), 3), "foo");
498 LLVMRemarkDebugLocRef DL
= LLVMRemarkEntryGetDebugLoc(Remark
);
499 EXPECT_EQ(checkStr(LLVMRemarkDebugLocGetSourceFilePath(DL
), 6), "file.c");
500 EXPECT_EQ(LLVMRemarkDebugLocGetSourceLine(DL
), 3U);
501 EXPECT_EQ(LLVMRemarkDebugLocGetSourceColumn(DL
), 12U);
502 EXPECT_EQ(LLVMRemarkEntryGetHotness(Remark
), 0U);
503 EXPECT_EQ(LLVMRemarkEntryGetNumArgs(Remark
), 4U);
506 LLVMRemarkArgRef Arg
= LLVMRemarkEntryGetFirstArg(Remark
);
510 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "Callee");
511 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 3), "bar");
512 EXPECT_EQ(LLVMRemarkArgGetDebugLoc(Arg
), nullptr);
515 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "String");
516 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 26),
517 " will not be inlined into ");
518 EXPECT_EQ(LLVMRemarkArgGetDebugLoc(Arg
), nullptr);
521 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "Caller");
522 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 3), "foo");
523 LLVMRemarkDebugLocRef DL
= LLVMRemarkArgGetDebugLoc(Arg
);
524 EXPECT_EQ(checkStr(LLVMRemarkDebugLocGetSourceFilePath(DL
), 6), "file.c");
525 EXPECT_EQ(LLVMRemarkDebugLocGetSourceLine(DL
), 2U);
526 EXPECT_EQ(LLVMRemarkDebugLocGetSourceColumn(DL
), 0U);
530 EXPECT_EQ(checkStr(LLVMRemarkArgGetKey(Arg
), 6), "String");
531 EXPECT_EQ(checkStr(LLVMRemarkArgGetValue(Arg
), 38),
532 " because its definition is unavailable");
533 EXPECT_EQ(LLVMRemarkArgGetDebugLoc(Arg
), nullptr);
539 } while ((Arg
= LLVMRemarkEntryGetNextArg(Arg
, Remark
)));
541 LLVMRemarkEntryDispose(Remark
);
543 EXPECT_EQ(LLVMRemarkParserGetNext(Parser
), nullptr);
545 EXPECT_FALSE(LLVMRemarkParserHasError(Parser
));
546 LLVMRemarkParserDispose(Parser
);
549 TEST(YAMLRemarks
, ContentsStrTab
) {
554 "DebugLoc: { File: 2, Line: 3, Column: 12 }\n"
561 " DebugLoc: { File: 2, Line: 2, Column: 0 }\n"
565 StringRef StrTabBuf
=
566 StringRef("inline\0NoDefinition\0file.c\0foo\0Callee\0bar\0String\0 "
567 "will not be inlined into \0 because its definition is "
571 remarks::ParsedStringTable
StrTab(StrTabBuf
);
572 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
573 remarks::createRemarkParser(remarks::Format::YAMLStrTab
, Buf
,
575 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
576 EXPECT_TRUE(*MaybeParser
!= nullptr);
578 remarks::RemarkParser
&Parser
= **MaybeParser
;
579 Expected
<std::unique_ptr
<remarks::Remark
>> MaybeRemark
= Parser
.next();
581 errorToBool(MaybeRemark
.takeError())); // Check for parsing errors.
582 EXPECT_TRUE(*MaybeRemark
!= nullptr); // At least one remark.
584 const remarks::Remark
&Remark
= **MaybeRemark
;
585 EXPECT_EQ(Remark
.RemarkType
, remarks::Type::Missed
);
586 EXPECT_EQ(checkStr(Remark
.PassName
, 6), "inline");
587 EXPECT_EQ(checkStr(Remark
.RemarkName
, 12), "NoDefinition");
588 EXPECT_EQ(checkStr(Remark
.FunctionName
, 3), "foo");
589 EXPECT_TRUE(Remark
.Loc
);
590 const remarks::RemarkLocation
&RL
= *Remark
.Loc
;
591 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
592 EXPECT_EQ(RL
.SourceLine
, 3U);
593 EXPECT_EQ(RL
.SourceColumn
, 12U);
594 EXPECT_TRUE(Remark
.Hotness
);
595 EXPECT_EQ(*Remark
.Hotness
, 4U);
596 EXPECT_EQ(Remark
.Args
.size(), 4U);
599 for (const remarks::Argument
&Arg
: Remark
.Args
) {
602 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Callee");
603 EXPECT_EQ(checkStr(Arg
.Val
, 3), "bar");
604 EXPECT_FALSE(Arg
.Loc
);
607 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
608 EXPECT_EQ(checkStr(Arg
.Val
, 26), " will not be inlined into ");
609 EXPECT_FALSE(Arg
.Loc
);
612 EXPECT_EQ(checkStr(Arg
.Key
, 6), "Caller");
613 EXPECT_EQ(checkStr(Arg
.Val
, 3), "foo");
614 EXPECT_TRUE(Arg
.Loc
);
615 const remarks::RemarkLocation
&RL
= *Arg
.Loc
;
616 EXPECT_EQ(checkStr(RL
.SourceFilePath
, 6), "file.c");
617 EXPECT_EQ(RL
.SourceLine
, 2U);
618 EXPECT_EQ(RL
.SourceColumn
, 0U);
622 EXPECT_EQ(checkStr(Arg
.Key
, 6), "String");
623 EXPECT_EQ(checkStr(Arg
.Val
, 38),
624 " because its definition is unavailable");
625 EXPECT_FALSE(Arg
.Loc
);
633 MaybeRemark
= Parser
.next();
634 Error E
= MaybeRemark
.takeError();
635 EXPECT_TRUE(E
.isA
<remarks::EndOfFileError
>());
636 EXPECT_TRUE(errorToBool(std::move(E
))); // Check for parsing errors.
639 TEST(YAMLRemarks
, ParsingBadStringTableIndex
) {
645 StringRef StrTabBuf
= StringRef("inline");
647 remarks::ParsedStringTable
StrTab(StrTabBuf
);
648 Expected
<std::unique_ptr
<remarks::RemarkParser
>> MaybeParser
=
649 remarks::createRemarkParser(remarks::Format::YAMLStrTab
, Buf
,
651 EXPECT_FALSE(errorToBool(MaybeParser
.takeError()));
652 EXPECT_TRUE(*MaybeParser
!= nullptr);
654 remarks::RemarkParser
&Parser
= **MaybeParser
;
655 Expected
<std::unique_ptr
<remarks::Remark
>> MaybeRemark
= Parser
.next();
656 EXPECT_FALSE(MaybeRemark
); // Expect an error here.
658 std::string ErrorStr
;
659 raw_string_ostream
Stream(ErrorStr
);
660 handleAllErrors(MaybeRemark
.takeError(),
661 [&](const ErrorInfoBase
&EIB
) { EIB
.log(Stream
); });
663 StringRef(Stream
.str())
664 .contains("String with index 50 is out of bounds (size = 1)."));
667 TEST(YAMLRemarks
, ParsingGoodMeta
) {
668 // No metadata should also work.
669 parseGoodMeta("--- !Missed\n"
671 "Name: NoDefinition\n"
675 parseGoodMeta(StringRef("REMARKS\0"
680 "Name: NoDefinition\n"
684 // Use the string table from the metadata.
685 parseGoodMeta(StringRef("REMARKS\0"
696 TEST(YAMLRemarks
, ParsingBadMeta
) {
697 parseExpectErrorMeta(StringRef("REMARKSS", 9),
698 "Expecting \\0 after magic number.", CmpType::Equal
);
700 parseExpectErrorMeta(StringRef("REMARKS\0", 8), "Expecting version number.",
703 parseExpectErrorMeta(StringRef("REMARKS\0"
704 "\x09\0\0\0\0\0\0\0",
706 "Mismatching remark version. Got 9, expected 0.",
709 parseExpectErrorMeta(StringRef("REMARKS\0"
712 "Expecting string table size.", CmpType::Equal
);
714 parseExpectErrorMeta(StringRef("REMARKS\0"
716 "\x01\0\0\0\0\0\0\0",
718 "Expecting string table.", CmpType::Equal
);
720 parseExpectErrorMeta(StringRef("REMARKS\0"
725 "'/path/'", CmpType::Contains
);
727 parseExpectErrorMeta(StringRef("REMARKS\0"
732 "'/baddir/path/'", CmpType::Contains
,
733 StringRef("/baddir/"));