test(mkdwarfs): more error tests

This commit is contained in:
Marcus Holland-Moritz 2024-01-13 15:43:20 +01:00
parent 5cf79e2208
commit 5dd8715964

View File

@ -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"));
}
}