aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/tests/posix/rlimits.c
blob: 3565521494175e132c87f0631275d6b4f84b6f07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <sys/resource.h>
#include <stdio.h>
#include <errno.h>
#include <assert.h>
#include <string.h>

int main() {
	struct rlimit getlim, setlim;

    setlim.rlim_cur = 16;
    setlim.rlim_max = 4096;

	int ret = setrlimit(RLIMIT_NOFILE, &setlim);

    if(ret == -1) {
        fprintf(stderr, "%s\n", strerror(errno));
		assert(!ret);
	}

    assert(!getrlimit(RLIMIT_NOFILE, &getlim));

	assert(setlim.rlim_cur == getlim.rlim_cur);
	assert(setlim.rlim_max == getlim.rlim_max);

    return 0;
}