From 5fca0b2bc40cafe1702e7b3cd4437a42a4a0090c Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sun, 28 Apr 2024 09:05:19 +0200 Subject: [PATCH] test(perfmon): test trace output --- test/tool_main_test.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/tool_main_test.cpp b/test/tool_main_test.cpp index 41cc7cd8..5f2540ff 100644 --- a/test/tool_main_test.cpp +++ b/test/tool_main_test.cpp @@ -548,6 +548,35 @@ TEST(dwarfsextract_test, perfmon) { R"(\s+p99 latency:\s+\d+(\.\d+)?[num]?s)"}; EXPECT_TRUE(std::regex_search(errs, perfmon_re)) << errs; } + +TEST(dwarfsextract_test, perfmon_trace) { + auto t = dwarfsextract_tester::create_with_image(); + ASSERT_EQ(0, t.run({"-i", "image.dwarfs", "-f", "gnutar", "--perfmon", + "filesystem_v2,inode_reader_v2,block_cache", + "--perfmon-trace", "trace.json"})) + << t.err(); + + EXPECT_GT(t.out().size(), 1'000'000); + + auto trace_file = t.fa->get_file("trace.json"); + ASSERT_TRUE(trace_file); + EXPECT_GT(trace_file->size(), 10'000); + + auto trace = folly::parseJson(*trace_file); + EXPECT_TRUE(trace.isArray()); + + std::set const expected = {"filesystem_v2", "inode_reader_v2", + "block_cache"}; + std::set actual; + + for (auto const& obj : trace) { + EXPECT_TRUE(obj.isObject()); + EXPECT_TRUE(obj["cat"].isString()); + actual.insert(obj["cat"].getString()); + } + + EXPECT_EQ(expected, actual); +} #endif class mkdwarfs_input_list_test : public testing::TestWithParam {};