1 /* Copyright (C) 2005-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
21 #include <sys/resource.h>
31 /* The following 7 limits are part of POSIX and must exist. */
32 { "RLIMIT_CORE", RLIMIT_CORE
, true },
33 { "RLIMIT_CPU", RLIMIT_CPU
, true },
34 { "RLIMIT_DATA", RLIMIT_DATA
, true },
35 { "RLIMIT_FSIZE", RLIMIT_FSIZE
, true },
36 { "RLIMIT_NOFILE", RLIMIT_NOFILE
, true },
37 { "RLIMIT_STACK", RLIMIT_STACK
, true },
38 { "RLIMIT_AS", RLIMIT_AS
, true },
39 /* The following are traditional Unix limits which are also
41 { "RLIMIT_RSS", RLIMIT_RSS
, true },
42 { "RLIMIT_NPROC", RLIMIT_NPROC
, true },
43 /* The following are extensions. */
45 { "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK
, false },
48 { "RLIMIT_LOCKS", RLIMIT_LOCKS
, false },
50 #ifdef RLIMIT_SIGPENDING
51 { "RLIMIT_SIGPENDING", RLIMIT_SIGPENDING
, false },
53 #ifdef RLIMIT_MSGQUEUE
54 { "RLIMIT_MSGQUEUE", RLIMIT_MSGQUEUE
, false },
57 { "RLIMIT_NICE", RLIMIT_NICE
, false },
60 { "RLIMIT_RTPRIO", RLIMIT_RTPRIO
, false },
63 #define ntests (sizeof (tests) / sizeof (tests[0]))
71 for (int i
= 0; i
< ntests
; ++i
)
76 int res
= getrlimit (tests
[i
].resource
, &r
);
81 if (tests
[i
].required
)
83 printf ("limit %s expectedly not available for getrlimit\n",
91 printf ("getrlimit for %s returned unexpected error: %m\n",
99 res
= getrlimit64 (tests
[i
].resource
, &r64
);
104 if (tests
[i
].required
)
106 printf ("limit %s expectedly not available for getrlimit64"
107 "\n", tests
[i
].name
);
114 printf ("getrlimit64 for %s returned unexpected error: %m\n",
122 printf ("limit %s OK\n", tests
[i
].name
);
128 #define TEST_FUNCTION do_test ()
129 #include "../test-skeleton.c"