From 70d3c8232dbb62568de1dc646f7f709a72c2ce4c Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Mon, 15 Jan 2024 21:04:04 +0100 Subject: [PATCH] test: check inode dumps in the presence of read/map errors --- test/tool_main_test.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/tool_main_test.cpp b/test/tool_main_test.cpp index 0f9c7064..de8d53fa 100644 --- a/test/tool_main_test.cpp +++ b/test/tool_main_test.cpp @@ -2188,7 +2188,7 @@ TEST_P(map_file_error_test, delayed) { .max_name_len = 8, .with_errors = true}); - // t.os->setenv("DWARFS_DUMP_INODES", "inodes.dump"); + t.os->setenv("DWARFS_DUMP_INODES", "inodes.dump"); // t.iol->use_real_terminal(true); std::string args = "-i / -o test.dwarfs --no-progress --log-level=verbose"; @@ -2264,6 +2264,24 @@ TEST_P(map_file_error_test, delayed) { std::cout << folly::hexDump(it->second.data(), it->second.size()) << std::endl; } + + auto dump = t.fa->get_file("inodes.dump"); + ASSERT_TRUE(dump); + if (extra_args.find("--file-hash=none") == std::string::npos) { + EXPECT_THAT(dump.value(), ::testing::HasSubstr("(invalid)")) + << dump.value(); + } + if (extra_args.find("--order=revpath") != std::string::npos) { + EXPECT_THAT(dump.value(), ::testing::HasSubstr("similarity: none")) + << dump.value(); + } else { + EXPECT_THAT(dump.value(), ::testing::HasSubstr("similarity: nilsimsa")) + << dump.value(); + } + if (extra_args.find("--categorize") != std::string::npos) { + EXPECT_THAT(dump.value(), ::testing::HasSubstr("[incompressible]")) + << dump.value(); + } } namespace {