Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/kernel Add new ATF test: t_trapsignal:tra...
details: https://anonhg.NetBSD.org/src/rev/b957bedb6111
branches: trunk
changeset: 319211:b957bedb6111
user: kamil <kamil%NetBSD.org@localhost>
date: Mon May 21 08:49:03 2018 +0000
description:
Add new ATF test: t_trapsignal:trap_ignore
Test ignored trap with right exit code.
This test passes.
Sponsored by <The NetBSD Foundation>
diffstat:
tests/kernel/h_segv.c | 16 ++++++++++++++--
tests/kernel/t_trapsignal.sh | 15 ++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diffs (84 lines):
diff -r a93179f5c1d3 -r b957bedb6111 tests/kernel/h_segv.c
--- a/tests/kernel/h_segv.c Mon May 21 03:56:21 2018 +0000
+++ b/tests/kernel/h_segv.c Mon May 21 08:49:03 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_segv.c,v 1.2 2017/12/08 14:40:45 christos Exp $ */
+/* $NetBSD: h_segv.c,v 1.3 2018/05/21 08:49:03 kamil Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: h_segv.c,v 1.2 2017/12/08 14:40:45 christos Exp $");
+__RCSID("$NetBSD: h_segv.c,v 1.3 2018/05/21 08:49:03 kamil Exp $");
#include <stdio.h>
#include <string.h>
@@ -45,6 +45,7 @@
#define F_RECURSE 1
#define F_HANDLE 2
#define F_MASK 4
+#define F_IGNORE 8
static struct {
const char *n;
@@ -53,6 +54,7 @@
{ "recurse", F_RECURSE },
{ "handle", F_HANDLE },
{ "mask", F_MASK },
+ { "ignore", F_IGNORE }
};
static void
@@ -112,6 +114,16 @@
err(EXIT_FAILURE, "sigprocmask");
}
+ if (flags & F_IGNORE) {
+ struct sigaction sa;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ if (sigaction(SIGSEGV, &sa, NULL) == -1)
+ err(EXIT_FAILURE, "sigaction");
+ }
+
*p = 1;
return EXIT_SUCCESS;
}
diff -r a93179f5c1d3 -r b957bedb6111 tests/kernel/t_trapsignal.sh
--- a/tests/kernel/t_trapsignal.sh Mon May 21 03:56:21 2018 +0000
+++ b/tests/kernel/t_trapsignal.sh Mon May 21 08:49:03 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_trapsignal.sh,v 1.1 2017/12/07 19:46:40 christos Exp $
+# $NetBSD: t_trapsignal.sh,v 1.2 2018/05/21 08:49:03 kamil Exp $
#
# Copyright (c) 2017 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -85,10 +85,23 @@
${HELPER} handle recurse
}
+atf_test_case trap_ignore
+trap_ignore()
+{
+ atf_set "descr" "Test ignored trap with right exit code"
+}
+
+trap_ignore_body()
+{
+ atf_check -s signal:11 -o "inline:" -e "inline:" \
+ ${HELPER} ignore
+}
+
atf_init_test_cases()
{
atf_add_test_case trap_simple
atf_add_test_case trap_handle
atf_add_test_case trap_mask
atf_add_test_case trap_handle_recurse
+ atf_add_test_case trap_ignore
}
Home |
Main Index |
Thread Index |
Old Index