On 6/2/26 23:55, Lisa Wang wrote: > Add a shmem memory failure selftest to test the shmem memory failure is > correct after modifying shmem return value. > > Specifically, test the expected behavior under various scenarios > combining page dirtiness (dirty vs clean) and failure types (hard vs > soft): > + Dirty + Hard: Trigger a SIGBUS on injection, and trigger another > SIGBUS when reading the page again. > + Dirty + Soft: No SIGBUS is triggered, and the original value can be > read successfully. > + Clean + Hard: No SIGBUS is triggered on injection, but trigger a > SIGBUS when trying to read the page again. > + Clean + Soft: No SIGBUS is triggered, and the page can be read > successfully. > > Signed-off-by: Lisa Wang <[email protected]> > --- > tools/testing/selftests/mm/memory-failure.c | 111 > +++++++++++++++++++++++++++- > 1 file changed, 108 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/mm/memory-failure.c > b/tools/testing/selftests/mm/memory-failure.c > index 3d9e0b9ffb41..43949b3b3565 100644 > --- a/tools/testing/selftests/mm/memory-failure.c > +++ b/tools/testing/selftests/mm/memory-failure.c > @@ -30,9 +30,14 @@ enum result_type { > MADV_HARD_ANON, > MADV_HARD_CLEAN_PAGECACHE, > MADV_HARD_DIRTY_PAGECACHE, > + MADV_HARD_CLEAN_SHMEM, > + MADV_HARD_DIRTY_SHMEM, > MADV_SOFT_ANON, > MADV_SOFT_CLEAN_PAGECACHE, > MADV_SOFT_DIRTY_PAGECACHE, > + MADV_SOFT_CLEAN_SHMEM, > + MADV_SOFT_DIRTY_SHMEM, > + READ_ERROR, > }; > > static jmp_buf signal_jmp_buf; > @@ -165,17 +170,21 @@ static void check(struct __test_metadata *_metadata, > FIXTURE_DATA(memory_failure > case MADV_HARD_CLEAN_PAGECACHE: > case MADV_SOFT_CLEAN_PAGECACHE: > case MADV_SOFT_DIRTY_PAGECACHE: > - /* It is not expected to receive a SIGBUS signal. */ > - ASSERT_EQ(setjmp, 0); > - > + case MADV_SOFT_DIRTY_SHMEM: > /* The page content should remain unchanged. */ > ASSERT_TRUE(check_memory(vaddr, self->page_size));
You should likely use "fallthrough;" ... unless you are missing a break; here. -- Cheers, David

