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 test attach_self in t_ptrace
details: https://anonhg.NetBSD.org/src/rev/1b18daada592
branches: trunk
changeset: 348803:1b18daada592
user: kamil <kamil%NetBSD.org@localhost>
date: Tue Nov 08 11:21:41 2016 +0000
description:
Add new test attach_self in t_ptrace
Assert that a debugger cannot attach to self (as it's nonsense).
NetBSD returs here EINVAL.
Clean up unused header includes.
Sponsored by <The NetBSD Foundation>.
diffstat:
tests/kernel/t_ptrace.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diffs (54 lines):
diff -r 44930a25a0fc -r 1b18daada592 tests/kernel/t_ptrace.c
--- a/tests/kernel/t_ptrace.c Tue Nov 08 10:37:39 2016 +0000
+++ b/tests/kernel/t_ptrace.c Tue Nov 08 11:21:41 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace.c,v 1.13 2016/11/07 21:09:03 kamil Exp $ */
+/* $NetBSD: t_ptrace.c,v 1.14 2016/11/08 11:21:41 kamil Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,19 +27,14 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace.c,v 1.13 2016/11/07 21:09:03 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace.c,v 1.14 2016/11/08 11:21:41 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
#include <sys/ptrace.h>
-#include <sys/sysctl.h>
#include <sys/wait.h>
#include <err.h>
#include <errno.h>
-#include <signal.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
#include <unistd.h>
#include <atf-c.h>
@@ -97,10 +92,23 @@
ATF_REQUIRE_ERRNO(EPERM, ptrace(PT_ATTACH, 1, NULL, 0) == -1);
}
+ATF_TC(attach_self);
+ATF_TC_HEAD(attach_self, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Assert that a debugger cannot attach to self (as it's nonsense)");
+}
+
+ATF_TC_BODY(attach_self, tc)
+{
+ ATF_REQUIRE_ERRNO(EINVAL, ptrace(PT_ATTACH, getpid(), NULL, 0) == -1);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, attach_pid0);
ATF_TP_ADD_TC(tp, attach_pid1);
+ ATF_TP_ADD_TC(tp, attach_self);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index