Add testcase that ensure that stack hard limit is never smaller than

soft limit.
This commit is contained in:
njoly 2016-07-13 09:53:16 +00:00
parent 84b8b47bee
commit 9c5f636bf3

View File

@ -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_BODY(setrlimit_perm, tc)
}
}
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_TCS(tp)
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();
}