[PATCH 4/4] tests: add sched_xetscheduler.test
Fei Jie
feij.fnst at cn.fujitsu.com
Tue Mar 8 06:23:22 UTC 2016
* tests/sched_xetscheduler.c: New file.
* tests/sched_xetscheduler.test: New test.
* tests/.gitignore: Add sched_xetscheduler.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(TESTS): Add sched_xetscheduler.test.
---
tests/.gitignore | 1 +
tests/Makefile.am | 2 ++
tests/sched_xetscheduler.c | 37 +++++++++++++++++++++++++++++++++++++
tests/sched_xetscheduler.test | 11 +++++++++++
4 files changed, 51 insertions(+)
create mode 100644 tests/sched_xetscheduler.c
create mode 100755 tests/sched_xetscheduler.test
diff --git a/tests/.gitignore b/tests/.gitignore
index dd8d6f9..3935d53 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -94,6 +94,7 @@ sched_get_priority_mxx
sched_xetaffinity
sched_xetattr
sched_xetparam
+sched_xetscheduler
scm_rights
seccomp
select
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3939c1d..fcd7363 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -142,6 +142,7 @@ check_PROGRAMS = \
sched_xetaffinity \
sched_xetattr \
sched_xetparam \
+ sched_xetscheduler \
scm_rights \
seccomp \
select \
@@ -305,6 +306,7 @@ TESTS = \
sched_xetaffinity.test \
sched_xetattr.test \
sched_xetparam.test \
+ sched_xetscheduler.test \
scm_rights-fd.test \
seccomp.test \
select.test \
diff --git a/tests/sched_xetscheduler.c b/tests/sched_xetscheduler.c
new file mode 100644
index 0000000..abaacd6
--- /dev/null
+++ b/tests/sched_xetscheduler.c
@@ -0,0 +1,37 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_sched_getscheduler && defined __NR_sched_setscheduler
+
+# 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 = 99;
+ int rc = syscall(__NR_sched_setscheduler, 0, SCHED_FIFO, param);
+ if (rc == -1)
+ perror_msg_and_fail("sched_setscheduler");
+
+ printf("sched_setscheduler(0, SCHED_FIFO, [%d]) = %d\n",
+ param->sched_priority, rc);
+
+ rc = syscall(__NR_sched_getscheduler, 0);
+ if (rc == 1) {
+ printf("sched_getscheduler(0) = %d (SCHED_FIFO)\n", rc);
+ } else {
+ perror_msg_and_fail("sched_getscheduler");
+ }
+
+ puts("+++ exited with 0 +++");
+ return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_sched_getscheduler && __NR_sched_setscheduler")
+
+#endif
diff --git a/tests/sched_xetscheduler.test b/tests/sched_xetscheduler.test
new file mode 100755
index 0000000..15d6d73
--- /dev/null
+++ b/tests/sched_xetscheduler.test
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# Check sched_getscheduler and sched_setscheduler syscalls decoding.
+
+. "${srcdir=.}/init.sh"
+
+run_prog > /dev/null
+OUT="$LOG.out"
+run_strace -esched_getscheduler,sched_setscheduler -a22 $args > "$OUT"
+match_diff "$LOG" "$OUT"
+rm -f "$OUT"
--
1.8.3.1
More information about the Strace-devel
mailing list