Re: [PATCH v4 14/19] selftests/liveupdate: Test which tmpfs files can be preserved

From: David Matlack

Date: Mon Nov 23 2026 - 13:26:52 EST


On Fri Nov 20, 2026 at 6:29 AM PST, Pratyush Yadav wrote:
> On Wed, Nov 11 2026, David Matlack wrote:
[...]
>> +TEST_F(preserve_tmpfs, frozen_size)
>
> Nit: This test isn't really for "frozen size", it makes sure a preserved
> file behaves as we expect it to. So perhaps call it "preserved_ops" and
> update the comment?

Will do.

>> + EXPECT_EQ(ftruncate(fd, page_size), -1);
>> + EXPECT_EQ(errno, EPERM);
>> + EXPECT_EQ(ftruncate(fd, 4 * page_size), -1);
>> + EXPECT_EQ(errno, EPERM);
>> + EXPECT_EQ(fallocate(fd, 0, 0, 4 * page_size), -1);
>> + EXPECT_EQ(errno, EPERM);
>> + EXPECT_EQ(fallocate(fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0,
>> + page_size), -1);
>> + EXPECT_EQ(errno, EPERM);
>> + EXPECT_EQ(pwrite(fd, "x", 1, 2 * page_size), -1);
>> + EXPECT_EQ(errno, EPERM);
>
> Nit: Is there any point in matching the exact error code? Wouldn't
> checking for a failed syscall be enough?

The documentation that patch 11 adds to shmem_luo.c says these fail
with -EPERM, so I'd like the test to check that. But you have a point
for the other tests in this patch: the documentation only states the
permission rules for preserving a file, not the error codes, so in v5
those tests will just check that preserving fails.