Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/sys Add testcase that ensure that stack hard ...
details: https://anonhg.NetBSD.org/src/rev/90a6ddf6c0d8
branches: trunk
changeset: 346442:90a6ddf6c0d8
user: njoly <njoly%NetBSD.org@localhost>
date: Wed Jul 13 09:53:16 2016 +0000
description:
Add testcase that ensure that stack hard limit is never smaller than
soft limit.
diffstat:
tests/lib/libc/sys/t_setrlimit.c | 24 ++++++++++++++++++++++--
1 files changed, 22 insertions(+), 2 deletions(-)
diffs (52 lines):
diff -r 49087c006f6d -r 90a6ddf6c0d8 tests/lib/libc/sys/t_setrlimit.c
--- a/tests/lib/libc/sys/t_setrlimit.c Wed Jul 13 09:52:00 2016 +0000
+++ b/tests/lib/libc/sys/t_setrlimit.c Wed Jul 13 09:53:16 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setrlimit.c,v 1.4 2012/06/12 23:56:19 christos Exp $ */
+/* $NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_setrlimit.c,v 1.4 2012/06/12 23:56:19 christos Exp $");
+__RCSID("$NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $");
#include <sys/resource.h>
#include <sys/mman.h>
@@ -504,6 +504,25 @@
}
}
+ATF_TC(setrlimit_stack);
+ATF_TC_HEAD(setrlimit_stack, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_STACK");
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+
+ATF_TC_BODY(setrlimit_stack, tc)
+{
+ struct rlimit res;
+
+ /* Ensure soft limit is not bigger than hard limit */
+ res.rlim_cur = res.rlim_max = 4192256;
+ ATF_REQUIRE(setrlimit(RLIMIT_STACK, &res) == 0);
+ ATF_REQUIRE(getrlimit(RLIMIT_STACK, &res) == 0);
+ ATF_CHECK(res.rlim_cur <= res.rlim_max);
+
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -517,6 +536,7 @@
ATF_TP_ADD_TC(tp, setrlimit_nproc);
ATF_TP_ADD_TC(tp, setrlimit_perm);
ATF_TP_ADD_TC(tp, setrlimit_nthr);
+ ATF_TP_ADD_TC(tp, setrlimit_stack);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index