//===- unittests/Support/BitstreamRemarksParsingTest.cpp - Parsing tests --===// // // 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 // //===----------------------------------------------------------------------===// #include "llvm-c/Remarks.h" #include "llvm/Remarks/Remark.h" #include "llvm/Remarks/RemarkParser.h" #include "llvm/Remarks/RemarkSerializer.h" #include "gtest/gtest.h" usingnamespacellvm; template <size_t N> void parseGood(const char (&Buf)[N]) { … } TEST(BitstreamRemarks, ParsingGood) { … } // Mandatory common part of a remark. #define COMMON_REMARK … // Test all the types. TEST(BitstreamRemarks, ParsingTypes) { … } #undef COMMON_REMARK static inline StringRef checkStr(StringRef Str, unsigned ExpectedLen) { … } TEST(BitstreamRemarks, Contents) { … } static inline StringRef checkStr(LLVMRemarkStringRef Str, unsigned ExpectedLen) { … } TEST(BitstreamRemarks, ContentsCAPI) { … } static void parseBad(StringRef Input, const char *ErrorMsg) { … } TEST(BitstreamRemarks, ParsingEmpty) { … } TEST(BitstreamRemarks, ParsingBadMagic) { … } // Testing malformed bitstream is not easy. We would need to replace bytes in // the stream to create malformed and unknown records and blocks. There is no // textual format for bitstream that can be decoded, modified and encoded // back. // FIXME: Add tests for the following error messages: // * Error while parsing META_BLOCK: malformed record entry // (RECORD_META_CONTAINER_INFO). // * Error while parsing META_BLOCK: malformed record entry // (RECORD_META_REMARK_VERSION). // * Error while parsing META_BLOCK: malformed record entry // (RECORD_META_STRTAB). // * Error while parsing META_BLOCK: malformed record entry // (RECORD_META_EXTERNAL_FILE). // * Error while parsing META_BLOCK: unknown record entry (NUM). // * Error while parsing REMARK_BLOCK: malformed record entry // (RECORD_REMARK_HEADER). // * Error while parsing REMARK_BLOCK: malformed record entry // (RECORD_REMARK_DEBUG_LOC). // * Error while parsing REMARK_BLOCK: malformed record entry // (RECORD_REMARK_HOTNESS). // * Error while parsing REMARK_BLOCK: malformed record entry // (RECORD_REMARK_ARG_WITH_DEBUGLOC). // * Error while parsing REMARK_BLOCK: malformed record entry // (RECORD_REMARK_ARG_WITHOUT_DEBUGLOC). // * Error while parsing REMARK_BLOCK: unknown record entry (NUM). // * Error while parsing META_BLOCK: expecting [ENTER_SUBBLOCO, META_BLOCK, // ...]. // * Error while entering META_BLOCK. // * Error while parsing META_BLOCK: expecting records. // * Error while parsing META_BLOCK: unterminated block. // * Error while parsing REMARK_BLOCK: expecting [ENTER_SUBBLOCO, REMARK_BLOCK, // ...]. // * Error while entering REMARK_BLOCK. // * Error while parsing REMARK_BLOCK: expecting records. // * Error while parsing REMARK_BLOCK: unterminated block. // * Error while parsing BLOCKINFO_BLOCK: expecting [ENTER_SUBBLOCK, // BLOCKINFO_BLOCK, ...]. // * Error while parsing BLOCKINFO_BLOCK. // * Unexpected error while parsing bitstream. // * Expecting META_BLOCK after the BLOCKINFO_BLOCK. // * Error while parsing BLOCK_META: missing container version. // * Error while parsing BLOCK_META: invalid container type. // * Error while parsing BLOCK_META: missing container type. // * Error while parsing BLOCK_META: missing string table. // * Error while parsing BLOCK_META: missing remark version. // * Error while parsing BLOCK_META: missing external file path. // * Error while parsing external file's BLOCK_META: wrong container type. // * Error while parsing external file's BLOCK_META: mismatching versions: // original meta: NUM, external file meta: NUM. // * Error while parsing BLOCK_REMARK: missing string table. // * Error while parsing BLOCK_REMARK: missing remark type. // * Error while parsing BLOCK_REMARK: unknown remark type. // * Error while parsing BLOCK_REMARK: missing remark name. // * Error while parsing BLOCK_REMARK: missing remark pass. // * Error while parsing BLOCK_REMARK: missing remark function name. // * Error while parsing BLOCK_REMARK: missing key in remark argument. // * Error while parsing BLOCK_REMARK: missing value in remark argument.