1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) Wipro Technologies, 2002. All Rights Reserved.
4*49cdfc7eSAndroid Build Coastguard Worker * Author: Suresh Babu V. <[email protected]>
5*49cdfc7eSAndroid Build Coastguard Worker */
6*49cdfc7eSAndroid Build Coastguard Worker
7*49cdfc7eSAndroid Build Coastguard Worker /*\
8*49cdfc7eSAndroid Build Coastguard Worker * [Description]
9*49cdfc7eSAndroid Build Coastguard Worker *
10*49cdfc7eSAndroid Build Coastguard Worker * Verify that getrlimit(2) call will be successful for all possible resource
11*49cdfc7eSAndroid Build Coastguard Worker * types.
12*49cdfc7eSAndroid Build Coastguard Worker */
13*49cdfc7eSAndroid Build Coastguard Worker
14*49cdfc7eSAndroid Build Coastguard Worker #include <sys/resource.h>
15*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
16*49cdfc7eSAndroid Build Coastguard Worker
17*49cdfc7eSAndroid Build Coastguard Worker static struct tcase {
18*49cdfc7eSAndroid Build Coastguard Worker int res;
19*49cdfc7eSAndroid Build Coastguard Worker char *res_str;
20*49cdfc7eSAndroid Build Coastguard Worker } tcases[] = {
21*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_CPU, "RLIMIT_CPU"},
22*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_FSIZE, "RLIMIT_FSIZE"},
23*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_DATA, "RLIMIT_DATA"},
24*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_STACK, "RLIMIT_STACK"},
25*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_CORE, "RLIMIT_CORE"},
26*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_RSS, "RLIMIT_RSS"},
27*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_NPROC, "RLIMIT_NPROC"},
28*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_NOFILE, "RLIMIT_NOFILE"},
29*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK"},
30*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_AS, "RLIMIT_AS"},
31*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_LOCKS, "RLIMIT_LOCKS"},
32*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_MSGQUEUE, "RLIMIT_MSGQUEUE"},
33*49cdfc7eSAndroid Build Coastguard Worker #ifdef RLIMIT_NICE
34*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_NICE, "RLIMIT_NICE"},
35*49cdfc7eSAndroid Build Coastguard Worker #endif
36*49cdfc7eSAndroid Build Coastguard Worker #ifdef RLIMIT_RTPRIO
37*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_RTPRIO, "RLIMIT_RTPRIO"},
38*49cdfc7eSAndroid Build Coastguard Worker #endif
39*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_SIGPENDING, "RLIMIT_SIGPENDING"},
40*49cdfc7eSAndroid Build Coastguard Worker #ifdef RLIMIT_RTTIME
41*49cdfc7eSAndroid Build Coastguard Worker {RLIMIT_RTTIME, "RLIMIT_RTTIME"},
42*49cdfc7eSAndroid Build Coastguard Worker #endif
43*49cdfc7eSAndroid Build Coastguard Worker };
44*49cdfc7eSAndroid Build Coastguard Worker
verify_getrlimit(unsigned int i)45*49cdfc7eSAndroid Build Coastguard Worker static void verify_getrlimit(unsigned int i)
46*49cdfc7eSAndroid Build Coastguard Worker {
47*49cdfc7eSAndroid Build Coastguard Worker struct rlimit rlim;
48*49cdfc7eSAndroid Build Coastguard Worker struct tcase *tc = &tcases[i];
49*49cdfc7eSAndroid Build Coastguard Worker
50*49cdfc7eSAndroid Build Coastguard Worker TST_EXP_PASS(getrlimit(tc->res, &rlim),
51*49cdfc7eSAndroid Build Coastguard Worker "getrlimit() test for %s",
52*49cdfc7eSAndroid Build Coastguard Worker tc->res_str);
53*49cdfc7eSAndroid Build Coastguard Worker }
54*49cdfc7eSAndroid Build Coastguard Worker
55*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
56*49cdfc7eSAndroid Build Coastguard Worker .tcnt = ARRAY_SIZE(tcases),
57*49cdfc7eSAndroid Build Coastguard Worker .test = verify_getrlimit,
58*49cdfc7eSAndroid Build Coastguard Worker };
59