]> granicus.if.org Git - strace/commitdiff
tests: add sched_xetparam.test
authorFei Jie <feij.fnst@cn.fujitsu.com>
Thu, 10 Mar 2016 09:12:24 +0000 (17:12 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 10 Mar 2016 09:12:24 +0000 (09:12 +0000)
* 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
tests/Makefile.am
tests/sched_xetparam.c [new file with mode: 0644]
tests/sched_xetparam.test [new file with mode: 0755]

index bb9db3ebfaaace91e9d23658bbccb21166bfca4f..e8824633293cae52acca659a94f5edd7423128fe 100644 (file)
@@ -98,6 +98,7 @@ rt_tgsigqueueinfo
 sched_get_priority_mxx
 sched_xetaffinity
 sched_xetattr
+sched_xetparam
 scm_rights
 seccomp
 select
index 17f9c905a1715d83e95973055c452f4d73b9ae43..4b48b3f919852f7fabc5d7fd5399c6661c7e96ef 100644 (file)
@@ -146,6 +146,7 @@ check_PROGRAMS = \
        sched_get_priority_mxx \
        sched_xetaffinity \
        sched_xetattr \
+       sched_xetparam \
        scm_rights \
        seccomp \
        select \
@@ -312,6 +313,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 (file)
index 0000000..d968a2c
--- /dev/null
@@ -0,0 +1,33 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_sched_getparam && defined __NR_sched_setparam
+
+# include <errno.h>
+# include <sched.h>
+# include <stdio.h>
+# include <unistd.h>
+
+int
+main(void)
+{
+       struct sched_param *const param = tail_alloc(sizeof(struct sched_param));
+       int rc = syscall(__NR_sched_getparam, 0, param);
+       printf("sched_getparam(0, [%d]) = %d\n",
+              param->sched_priority, rc);
+
+       param->sched_priority = -1;
+       rc = syscall(__NR_sched_setparam, 0, param);
+       printf("sched_setparam(0, [%d]) = %d %s (%m)\n",
+              param->sched_priority, rc,
+              errno == EPERM ? "EPERM" : "EINVAL");
+
+       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 (executable)
index 0000000..9627598
--- /dev/null
@@ -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"