summaryrefslogtreecommitdiff
path: root/tests/sched_xetparam.c
diff options
context:
space:
mode:
authorFei Jie <feij.fnst@cn.fujitsu.com>2016-03-10 17:12:24 +0800
committerDmitry V. Levin <ldv@altlinux.org>2016-03-10 09:12:24 +0000
commitea5c7b55158a9eb0c798515cc049074a7fba27bd (patch)
treec4528549e53bcae35a192dec8cc3d5b9ecb1cbc4 /tests/sched_xetparam.c
parent1eed594f30ee7030cb1c224267f4fdb5f34bf773 (diff)
downloadstrace-ea5c7b55158a9eb0c798515cc049074a7fba27bd.tar.gz
tests: add sched_xetparam.test
* 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.
Diffstat (limited to 'tests/sched_xetparam.c')
-rw-r--r--tests/sched_xetparam.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/sched_xetparam.c b/tests/sched_xetparam.c
new file mode 100644
index 000000000..d968a2c5c
--- /dev/null
+++ b/tests/sched_xetparam.c
@@ -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