From: "Mike Rapoport (Microsoft)" <[email protected]>

Access of poisoned memory causes SIGBUS, which terminates the
hugetlb-read-hwpoison test prematurely.

Add a dummy SIGBUS handler to allow the test to continue regardless of
SIGBUS.

Tested-by: Sarthak Sharma <[email protected]>
Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
---
 tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c 
b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
index 46230462ad48..6bbf15f78061 100644
--- a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
+++ b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
@@ -10,6 +10,7 @@
 #include <sys/statfs.h>
 #include <errno.h>
 #include <stdbool.h>
+#include <signal.h>
 
 #include "kselftest.h"
 
@@ -261,6 +262,11 @@ static int create_hugetlbfs_file(struct statfs *file_stat)
        return -1;
 }
 
+static void sigbus_handler(int sig)
+{
+       printf(PREFIX "received SIGBUS\n");
+}
+
 int main(void)
 {
        int fd;
@@ -273,6 +279,7 @@ int main(void)
        };
        size_t i;
 
+       signal(SIGBUS, sigbus_handler);
        for (i = 0; i < ARRAY_SIZE(wr_chunk_sizes); ++i) {
                printf("Write/read chunk size=0x%lx\n",
                       wr_chunk_sizes[i]);
-- 
2.53.0


Reply via email to