aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ProfileData/MemProfTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ProfileData/MemProfTest.cpp')
-rw-r--r--llvm/unittests/ProfileData/MemProfTest.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/unittests/ProfileData/MemProfTest.cpp b/llvm/unittests/ProfileData/MemProfTest.cpp
index 3ac64dc..99f95dd 100644
--- a/llvm/unittests/ProfileData/MemProfTest.cpp
+++ b/llvm/unittests/ProfileData/MemProfTest.cpp
@@ -807,4 +807,40 @@ HeapProfileRecords:
EXPECT_THAT(Record.CallSiteIds,
ElementsAre(hashCallStack(CS3), hashCallStack(CS4)));
}
+
+template <typename T> std::string serializeInYAML(T &Val) {
+ std::string Out;
+ llvm::raw_string_ostream OS(Out);
+ llvm::yaml::Output Yout(OS);
+ Yout << Val;
+ return Out;
+}
+
+TEST(MemProf, YAMLWriterFrame) {
+ Frame F(11, 22, 33, true);
+
+ std::string Out = serializeInYAML(F);
+ EXPECT_EQ(Out, R"YAML(---
+{ Function: 11, LineOffset: 22, Column: 33, Inline: true }
+...
+)YAML");
+}
+
+TEST(MemProf, YAMLWriterMIB) {
+ MemInfoBlock MIB;
+ MIB.AllocCount = 111;
+ MIB.TotalSize = 222;
+ MIB.TotalLifetime = 333;
+ MIB.TotalLifetimeAccessDensity = 444;
+ PortableMemInfoBlock PMIB(MIB, llvm::memprof::getHotColdSchema());
+
+ std::string Out = serializeInYAML(PMIB);
+ EXPECT_EQ(Out, R"YAML(---
+AllocCount: 111
+TotalSize: 222
+TotalLifetime: 333
+TotalLifetimeAccessDensity: 444
+...
+)YAML");
+}
} // namespace