Re: [PATCH v2 11/13] KVM: selftests: Add wrapper macro to handle and assert on expected SIGBUS

Lisa Wang
2025-10-07T21:16:40Z

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@google.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>

Reviewed-by: Lisa Wang <wyihan@google.com>
Tested-by: Lisa Wang <wyihan@google.com>

> ---
> .../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...]
>
>