[PATCH v2 1/3] tests: add xetpriority.test

Fei Jie feij.fnst at cn.fujitsu.com
Mon Mar 7 03:32:01 UTC 2016


* tests/xetpriority.c: New file.
* tests/xetpriority.test: New test.
* tests/.gitignore: Add xetpriority.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add xetpriority.test.
* linux/dummy.h: (sys_getpriority, sys_setpriority): Change to printargs_d.
---
 linux/dummy.h          |  2 ++
 tests/.gitignore       |  1 +
 tests/Makefile.am      |  2 ++
 tests/xetpriority.c    | 34 ++++++++++++++++++++++++++++++++++
 tests/xetpriority.test | 11 +++++++++++
 5 files changed, 50 insertions(+)
 create mode 100644 tests/xetpriority.c
 create mode 100755 tests/xetpriority.test

diff --git a/linux/dummy.h b/linux/dummy.h
index 984b290..5f392eb 100644
--- a/linux/dummy.h
+++ b/linux/dummy.h
@@ -123,9 +123,11 @@
 
 /* printargs_d does the right thing */
 #define	sys_getpgid		printargs_d
+#define	sys_getpriority		printargs_d
 #define	sys_getsid		printargs_d
 #define	sys_nice		printargs_d
 #define	sys_setpgid		printargs_d
+#define	sys_setpriority		printargs_d
 #define	sys_setpgrp		printargs_d
 #define	sys_timer_delete	printargs_d
 #define	sys_timer_getoverrun	printargs_d
diff --git a/tests/.gitignore b/tests/.gitignore
index 31b643c..e0e83f1 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -138,4 +138,5 @@ xattr
 xet_robust_list
 xetitimer
 xetpgid
+xetpriority
 xettimeofday
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6ce2def..2d704ef 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -186,6 +186,7 @@ check_PROGRAMS = \
 	xet_robust_list \
 	xetitimer \
 	xetpgid \
+	xetpriority \
 	xettimeofday \
 	# end of check_PROGRAMS
 
@@ -342,6 +343,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
index 0000000..9fdcf3f
--- /dev/null
+++ b/tests/xetpriority.c
@@ -0,0 +1,34 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_getpriority && defined __NR_setpriority
+
+# 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(%d, %d) = %d\n",
+	       PRIO_PROCESS, pid, rc);
+
+	rc = syscall(__NR_setpriority, PRIO_PROCESS,
+	     (unsigned long) 0xffffffff00000000 | pid,
+	     (unsigned long) 0xffffffff00000000);
+	printf("setpriority(%d, %d, 0) = %d\n",
+	       PRIO_PROCESS, pid, rc);
+
+	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
index 0000000..06b9b50
--- /dev/null
+++ b/tests/xetpriority.test
@@ -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 -a18 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list