From: Fei Jie Date: Thu, 10 Mar 2016 09:12:24 +0000 (+0800) Subject: tests: add sched_xetparam.test X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea5c7b55158a9eb0c798515cc049074a7fba27bd;p=strace 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. --- diff --git a/tests/.gitignore b/tests/.gitignore index bb9db3eb..e8824633 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -98,6 +98,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 17f9c905..4b48b3f9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..d968a2c5 --- /dev/null +++ b/tests/sched_xetparam.c @@ -0,0 +1,33 @@ +#include "tests.h" +#include + +#if defined __NR_sched_getparam && defined __NR_sched_setparam + +# include +# include +# include +# include + +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 index 00000000..9627598f --- /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"