From eb60ed1ea51c13d2dedcb015248647663e9f7fd6 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sat, 30 Dec 2023 14:54:48 +0100 Subject: [PATCH] test: add proper --chmod=norm test --- test/tool_main_test.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/tool_main_test.cpp b/test/tool_main_test.cpp index 2a2f10d0..1b62ae82 100644 --- a/test/tool_main_test.cpp +++ b/test/tool_main_test.cpp @@ -357,3 +357,29 @@ TEST_P(categorizer_test, end_to_end) { INSTANTIATE_TEST_SUITE_P(dwarfs, categorizer_test, ::testing::Values("error", "warn", "info", "verbose", "debug", "trace")); + +TEST(mkdwarfs_test, chmod_norm) { + std::string const image_file = "test.dwarfs"; + + std::set real, norm; + + { + mkdwarfs_tester t; + EXPECT_EQ(0, t.run({"-i", "/", "-o", image_file})); + auto fs = t.fs_from_file(image_file); + fs.walk([&](auto const& e) { real.insert(e.inode().perm_string()); }); + } + + { + mkdwarfs_tester t; + EXPECT_EQ(0, t.run({"-i", "/", "-o", image_file, "--chmod=norm"})); + auto fs = t.fs_from_file(image_file); + fs.walk([&](auto const& e) { norm.insert(e.inode().perm_string()); }); + } + + EXPECT_NE(real, norm); + + std::set expected_norm = {"r--r--r--", "r-xr-xr-x"}; + + EXPECT_EQ(expected_norm, norm); +}