[PATCH 3/4] tests: add sched_xetparam.test

Fei Jie feij.fnst at cn.fujitsu.com
Tue Mar 8 06:23:21 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 3093adb..dd8d6f9 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -93,6 +93,7 @@ rt_tgsigqueueinfo
 sched_get_priority_mxx
 sched_xetaffinity
 sched_xetattr
+sched_xetparam
 scm_rights
 seccomp
 select
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9cbdfc8..3939c1d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -141,6 +141,7 @@ check_PROGRAMS = \
 	sched_get_priority_mxx \
 	sched_xetaffinity \
 	sched_xetattr \
+	sched_xetparam \
 	scm_rights \
 	seccomp \
 	select \
@@ -303,6 +304,7 @@ TESTS = \
 	sched_get_priority_mxx.test \
 	sched_xetaffinity.test \
 	sched_xetattr.test \
+	sched_xetparam.test \
 	scm_rights-fd.test \
 	seccomp.test \
 	select.test \
diff --git a/tests/sched_xetparam.c b/tests/sched_xetparam.c
new file mode 100644
index 0000000..092c662
--- /dev/null
+++ b/tests/sched_xetparam.c
@@ -0,0 +1,37 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_sched_getparam && defined __NR_sched_setparam
+
+# include <sched.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+	struct sched_param *const param = tail_alloc(sizeof(struct sched_param));
+	param->sched_priority = 0;
+	int rc = syscall(__NR_sched_setparam, 0, param);
+	if (rc == -1)
+		perror_msg_and_fail("sched_setparam");
+
+	printf("sched_setparam(0, [%d]) = %d\n",
+	       param->sched_priority, rc);
+
+	rc = syscall(__NR_sched_getparam, 0, param);
+	if (rc == -1)
+		perror_msg_and_fail("sched_getparam");
+
+	printf("sched_getparam(0, [%d]) = %d\n",
+	       param->sched_priority, rc);
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_sched_getparam && __NR_sched_setparam")
+
+#endif
diff --git a/tests/sched_xetparam.test b/tests/sched_xetparam.test
new file mode 100755
index 0000000..9627598
--- /dev/null
+++ b/tests/sched_xetparam.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check sched_getparam and sched_setparam syscalls decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -esched_getparam,sched_setparam -a23 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
-- 
1.8.3.1







More information about the Strace-devel mailing list