From 5dd871596418c0f8e17c631133f6de623aba36dc Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sat, 13 Jan 2024 15:43:20 +0100 Subject: [PATCH] test(mkdwarfs): more error tests --- test/tool_main_test.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/tool_main_test.cpp b/test/tool_main_test.cpp index 50a69e4c..49d6df41 100644 --- a/test/tool_main_test.cpp +++ b/test/tool_main_test.cpp @@ -1154,6 +1154,23 @@ TEST(mkdwarfs_test, recompress) { EXPECT_TRUE(fs.find("/random")); } + { + auto t = tester(image); + EXPECT_EQ(1, t.run({"-i", image_file, "-o", "-", "--recompress", + "--recompress-categories=pcmaudio/metadata,SoMeThInG"})) + << t.err(); + EXPECT_THAT(t.err(), ::testing::HasSubstr( + "no category 'SoMeThInG' in input filesystem")); + } + + { + auto t = tester(image); + EXPECT_EQ(1, t.run({"-i", image_file, "-o", "-", "--recompress", "-C", + "SoMeThInG::null"})) + << t.err(); + EXPECT_THAT(t.err(), ::testing::HasSubstr("unknown category: 'SoMeThInG'")); + } + { auto corrupt_image = image; corrupt_image[64] ^= 0x01; // flip a bit right after the header @@ -1900,3 +1917,22 @@ TEST(mkdwarfs_test, low_memory_limit) { EXPECT_THAT(t.err(), ::testing::HasSubstr("low memory limit")); } } + +TEST(mkdwarfs_test, recoverable_errors) { + { + mkdwarfs_tester t; + t.os->set_access_fail("/somedir/ipsum.py"); + EXPECT_EQ(1, t.run("-i / -o - -l4")) << t.err(); + EXPECT_THAT(t.err(), + ::testing::HasSubstr("filesystem created with 1 error")); + } + + { + mkdwarfs_tester t; + t.os->set_access_fail("/somedir/ipsum.py"); + t.os->set_access_fail("/baz.pl"); + EXPECT_EQ(1, t.run("-i / -o - -l4")) << t.err(); + EXPECT_THAT(t.err(), + ::testing::HasSubstr("filesystem created with 2 errors")); + } +}