Re: [PATCH v2 11/13] KVM: selftests: Add wrapper macro to handle and assert on expected SIGBUS
From: Lisa Wang
Date: Tue Oct 07 2025 - 17:16:40 EST
Fri, Oct 03, 2025 at 04:26:04PM -0700, Sean Christopherson wrote:
> Extract the guest_memfd test's SIGBUS handling functionality into a common
> TEST_EXPECT_SIGBUS() macro in anticipation of adding more SIGBUS testcases.
> Eating a SIGBUS isn't terrible difficult, but it requires a non-trivial
> amount of boilerplate code, and using a macro allows selftests to print
> out the exact action that failed to generate a SIGBUS without the developer
> needing to remember to add a useful error message.
>
> Explicitly mark the SIGBUS handler as "used", as gcc-14 at least likes to
> discard the function before linking.
>
> Suggested-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
Reviewed-by: Lisa Wang <wyihan@xxxxxxxxxx>
Tested-by: Lisa Wang <wyihan@xxxxxxxxxx>
> ---
> .../testing/selftests/kvm/guest_memfd_test.c | 18 +-----------------
> .../testing/selftests/kvm/include/test_util.h | 19 +++++++++++++++++++
> tools/testing/selftests/kvm/lib/test_util.c | 7 +++++++
> 3 files changed, 27 insertions(+), 17 deletions(-)
>
>
> [...snip...]
>
>