]> granicus.if.org Git - strace/commitdiff
tests: add xetpriority.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Thu, 17 Mar 2016 09:30:45 +0000 (17:30 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 17 Mar 2016 09:30:45 +0000 (09:30 +0000)
* resource.c (SYS_FUNC(getpriority), SYS_FUNC(setpriority)): Print
the second syscall argument using %d format.
* tests/xetpriority.c: New file.
* tests/xetpriority.test: New test.
* tests/.gitignore: Add xetpriority.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add xetpriority.test.

resource.c
tests/.gitignore
tests/Makefile.am
tests/xetpriority.c [new file with mode: 0644]
tests/xetpriority.test [new file with mode: 0755]

index c68f0456e51eba102b6ea7a4eaab699034075fbc..9aacfbe486b3d8a686789f03b5853e1d9c0d16df 100644 (file)
@@ -184,7 +184,7 @@ SYS_FUNC(osf_getrusage)
 SYS_FUNC(getpriority)
 {
        printxval(priorities, tcp->u_arg[0], "PRIO_???");
-       tprintf(", %lu", tcp->u_arg[1]);
+       tprintf(", %d", (int) tcp->u_arg[1]);
 
        return RVAL_DECODED;
 }
@@ -192,7 +192,7 @@ SYS_FUNC(getpriority)
 SYS_FUNC(setpriority)
 {
        printxval(priorities, tcp->u_arg[0], "PRIO_???");
-       tprintf(", %lu, %d", tcp->u_arg[1], (int) tcp->u_arg[2]);
+       tprintf(", %d, %d", (int) tcp->u_arg[1], (int) tcp->u_arg[2]);
 
        return RVAL_DECODED;
 }
index 93ffa0b01f9d2fb43657e1f1d732fbeeac75ff92..449af18250e991a988b869d471ee5dc7965c226d 100644 (file)
@@ -149,4 +149,5 @@ xattr
 xet_robust_list
 xetitimer
 xetpgid
+xetpriority
 xettimeofday
index 6590f95e70085e26c332ac34babfb1dab0f85d0a..3005382180faafd7bd1d6a9a28bb0f8852a69f5b 100644 (file)
@@ -197,6 +197,7 @@ check_PROGRAMS = \
        xet_robust_list \
        xetitimer \
        xetpgid \
+       xetpriority \
        xettimeofday \
        # end of check_PROGRAMS
 
@@ -365,6 +366,7 @@ TESTS = \
        xet_robust_list.test \
        xetitimer.test \
        xetpgid.test \
+       xetpriority.test \
        xettimeofday.test \
        \
        count.test \
diff --git a/tests/xetpriority.c b/tests/xetpriority.c
new file mode 100644 (file)
index 0000000..aefe5e9
--- /dev/null
@@ -0,0 +1,38 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_getpriority && defined __NR_setpriority
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/time.h>
+# include <sys/resource.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       const int pid = getpid();
+       int rc = syscall(__NR_getpriority, PRIO_PROCESS,
+                (unsigned long) 0xffffffff00000000 | pid);
+       printf("getpriority(PRIO_PROCESS, %d) = %d\n",
+              pid, rc);
+
+       if ((syscall(__NR_setpriority, PRIO_PROCESS,
+           (unsigned long) 0xffffffff00000000 | pid,
+           (unsigned long) 0xffffffff00000000)) == 0) {
+               printf("setpriority(PRIO_PROCESS, %d, 0) = 0\n", pid);
+       } else {
+               printf("setpriority(PRIO_PROCESS, %d, 0) = -1 %s (%m)\n",
+                      pid, errno == EPERM ? "EPERM" : "EACCES");
+       }
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_getpriority && _NR_setpriority")
+
+#endif
diff --git a/tests/xetpriority.test b/tests/xetpriority.test
new file mode 100755 (executable)
index 0000000..f9b0251
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check getpriority and setpriority syscalls decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -egetpriority,setpriority -a29 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"