Commit 60066f2d authored by Pavel Emelyanov's avatar Pavel Emelyanov

zdtm: Test that rlimits are c/r-ed

Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 748be831
...@@ -66,6 +66,7 @@ static/fifo-ghost ...@@ -66,6 +66,7 @@ static/fifo-ghost
static/fifo static/fifo
static/fifo_wronly static/fifo_wronly
static/zombie00 static/zombie00
static/rlimits00
transition/fork transition/fork
static/pty00 static/pty00
static/pty01 static/pty01
......
...@@ -68,6 +68,7 @@ TST_NOFILE = \ ...@@ -68,6 +68,7 @@ TST_NOFILE = \
inotify00 \ inotify00 \
uptime_grow \ uptime_grow \
session00 \ session00 \
rlimits00 \
pty00 \ pty00 \
pty01 \ pty01 \
pty02 \ pty02 \
......
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include "zdtmtst.h"
const char *test_doc = "Check that rlimits are saved";
const char *test_author = "Pavel Emelianov <xemul@parallels.com>";
int main(int argc, char **argv)
{
int r, changed = 0;
struct rlimit rlims[RLIM_NLIMITS], trlim;
test_init(argc, argv);
for (r = 0; r < RLIM_NLIMITS; r++) {
if (getrlimit(r, &rlims[r])) {
err("Can't get rlimit");
goto out;
}
if (rlims[r].rlim_cur > 1 &&
rlims[r].rlim_cur != RLIM_INFINITY) {
rlims[r].rlim_cur--;
if (setrlimit(r, &rlims[r])) {
err("Can't set rlimit");
goto out;
}
changed = 1;
}
}
if (!changed) {
err("Can't change any rlimir");
goto out;
}
test_daemon();
test_waitsig();
for (r = 0; r < RLIM_NLIMITS; r++) {
if (getrlimit(r, &trlim)) {
fail("Can't get rlimit after rst");
goto out;
}
if (rlims[r].rlim_cur != trlim.rlim_cur) {
fail("Cur changed");
goto out;
}
if (rlims[r].rlim_max != trlim.rlim_max) {
fail("Max changed");
goto out;
}
}
pass();
out:
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment