diff options
Diffstat (limited to 'llvm/unittests/ProfileData/MemProfTest.cpp')
-rw-r--r-- | llvm/unittests/ProfileData/MemProfTest.cpp | 60 |
1 files changed, 5 insertions, 55 deletions
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp index dc79317..38dc863 100644 --- a/llvm/unittests/ProfileData/MemProfTest.cpp +++ b/llvm/unittests/ProfileData/MemProfTest.cpp @@ -89,8 +89,8 @@ const DILineInfoSpecifier specifier() { DILineInfoSpecifier::FunctionNameKind::LinkageName); } -MATCHER_P4(FrameContains, FunctionName, LineOffset, Column, Inline, "") { - const uint64_t ExpectedHash = llvm::Function::getGUID(FunctionName); +MATCHER_P4(FrameContains, Function, LineOffset, Column, Inline, "") { + const std::string ExpectedHash = std::to_string(llvm::MD5Hash(Function)); if (arg.Function != ExpectedHash) { *result_listener << "Hash mismatch"; return false; @@ -103,22 +103,6 @@ MATCHER_P4(FrameContains, FunctionName, LineOffset, Column, Inline, "") { return false; } -MATCHER_P(EqualsRecord, Want, "") { - if (arg == Want) - return true; - - std::string Explanation; - llvm::raw_string_ostream OS(Explanation); - OS << "\n Want: \n"; - Want.print(OS); - OS << "\n Got: \n"; - arg.print(OS); - OS.flush(); - - *result_listener << Explanation; - return false; -} - MemProfSchema getFullSchema() { MemProfSchema Schema; #define MIBEntryDef(NameTag, Name, Type) Schema.push_back(Meta::Name); @@ -195,43 +179,9 @@ TEST(MemProf, PortableWrapper) { // Here we compare directly with the actual counts instead of MemInfoBlock // members. Since the MemInfoBlock struct is packed and the EXPECT_EQ macros // take a reference to the params, this results in unaligned accesses. - EXPECT_EQ(1UL, ReadBlock.getAllocCount()); - EXPECT_EQ(7ULL, ReadBlock.getTotalAccessCount()); - EXPECT_EQ(3UL, ReadBlock.getAllocCpuId()); + EXPECT_EQ(1, ReadBlock.getAllocCount()); + EXPECT_EQ(7, ReadBlock.getTotalAccessCount()); + EXPECT_EQ(3, ReadBlock.getAllocCpuId()); } -TEST(MemProf, RecordSerializationRoundTrip) { - const MemProfSchema Schema = getFullSchema(); - - llvm::SmallVector<MemProfRecord, 3> Records; - MemProfRecord MR; - - MemInfoBlock Info(/*size=*/16, /*access_count=*/7, /*alloc_timestamp=*/1000, - /*dealloc_timestamp=*/2000, /*alloc_cpu=*/3, - /*dealloc_cpu=*/4); - - MR.Info = PortableMemInfoBlock(Info); - MR.CallStack.push_back({0x123, 1, 2, false}); - MR.CallStack.push_back({0x345, 3, 4, false}); - Records.push_back(MR); - - MR.clear(); - MR.Info = PortableMemInfoBlock(Info); - MR.CallStack.push_back({0x567, 5, 6, false}); - MR.CallStack.push_back({0x789, 7, 8, false}); - Records.push_back(MR); - - std::string Buffer; - llvm::raw_string_ostream OS(Buffer); - serializeRecords(Records, Schema, OS); - OS.flush(); - - const llvm::SmallVector<MemProfRecord, 4> GotRecords = deserializeRecords( - Schema, reinterpret_cast<const unsigned char *>(Buffer.data())); - - ASSERT_TRUE(!GotRecords.empty()); - EXPECT_EQ(GotRecords.size(), Records.size()); - EXPECT_THAT(GotRecords[0], EqualsRecord(Records[0])); - EXPECT_THAT(GotRecords[1], EqualsRecord(Records[1])); -} } // namespace |