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