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

Injection of a memory error with madvise() 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]>
Tested-by: Li Wang <[email protected]>
Reviewed-by: Li Wang <[email protected]>
Tested-by: Luiz Capitulino <[email protected]>
Signed-off-by: Mike Rapoport (Microsoft) <[email protected]>
---
 tools/testing/selftests/mm/hugetlb-read-hwpoison.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/mm/hugetlb-read-hwpoison.c 
b/tools/testing/selftests/mm/hugetlb-read-hwpoison.c
index 46230462ad48..ad3198b444ce 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,10 @@ static int create_hugetlbfs_file(struct statfs *file_stat)
        return -1;
 }
 
+static void sigbus_handler(int sig)
+{
+}
+
 int main(void)
 {
        int fd;
@@ -273,6 +278,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