* tests/xetrlimit.c: New file.
* tests/xetrlimit.test: New test.
* tests/.gitignore: Add xetrlimit.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add xetrlimit.test.
---
 tests/.gitignore     |  1 +
 tests/Makefile.am    |  2 ++
 tests/xetrlimit.c    | 36 ++++++++++++++++++++++++++++++++++++
 tests/xetrlimit.test | 11 +++++++++++
 4 files changed, 50 insertions(+)
 create mode 100644 tests/xetrlimit.c
 create mode 100755 tests/xetrlimit.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 4b9595d..830e104 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -140,4 +140,5 @@ xattr
 xet_robust_list
 xetitimer
 xetpgid
+xetrlimit
 xettimeofday
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 21d07cd..2cad5d9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -188,6 +188,7 @@ check_PROGRAMS = \
        xet_robust_list \
        xetitimer \
        xetpgid \
+       xetrlimit \
        xettimeofday \
        # end of check_PROGRAMS
 
@@ -346,6 +347,7 @@ TESTS = \
        xet_robust_list.test \
        xetitimer.test \
        xetpgid.test \
+       xetrlimit.test \
        xettimeofday.test \
        \
        count.test \
diff --git a/tests/xetrlimit.c b/tests/xetrlimit.c
new file mode 100644
index 0000000..ef7aa2e
--- /dev/null
+++ b/tests/xetrlimit.c
@@ -0,0 +1,36 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_getrlimit && defined __NR_setrlimit
+
+# include <errno.h>
+# include <sys/time.h>
+# include <sys/resource.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       struct rlimit *const rlim = tail_alloc(sizeof(struct rlimit));
+       int rc = syscall(__NR_getrlimit, RLIMIT_RTPRIO, rlim);
+
+       printf("getrlimit(RLIMIT_RTPRIO, {rlim_cur=%d, rlim_max=%d}) = %d\n",
+              (int) rlim->rlim_cur, (int) rlim->rlim_max, rc);
+
+       rlim->rlim_cur = rlim->rlim_max + 1;
+       rc = syscall(__NR_setrlimit, RLIMIT_RTPRIO, rlim);
+       printf("setrlimit(RLIMIT_RTPRIO, {rlim_cur=%d, rlim_max=%d})"
+              " = %d %s (%m)\n",
+              (int) rlim->rlim_cur, (int) rlim->rlim_max, rc,
+              errno == EPERM ? "EPERM" : "EINVAL");
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_getrlimit && __NR_setrlimit")
+
+#endif
diff --git a/tests/xetrlimit.test b/tests/xetrlimit.test
new file mode 100755
index 0000000..e1ea51b
--- /dev/null
+++ b/tests/xetrlimit.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check getrlimit and setrlimit syscalls decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -egetrlimit,setrlimit $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1




------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785111&iu=/4140
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to