[PATCH v4 1/2] tests: add xetpriority.test
Dmitry V. Levin
ldv at altlinux.org
Fri Mar 11 01:32:14 UTC 2016
On Thu, Mar 10, 2016 at 10:41:30AM +0800, Fei Jie wrote:
[...]
> --- /dev/null
> +++ b/tests/xetpriority.c
> @@ -0,0 +1,51 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#if defined __NR_getpriority && defined __NR_setpriority
> +
> +# include <errno.h>
> +# include <stdio.h>
> +# include <sys/time.h>
> +# include <sys/resource.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> + const int pid = getpid();
> + int rc = syscall(__NR_getpriority, PRIO_PROCESS,
> + (unsigned long) 0xffffffff00000000 | pid);
> + printf("getpriority(PRIO_PROCESS, %d) = %d\n",
> + pid, rc);
> +
> + rc = syscall(__NR_setpriority, PRIO_PROCESS,
> + (unsigned long) 0xffffffff00000000 | pid,
> + (unsigned long) 0xffffffff00000000);
> +
> + printf("setpriority(PRIO_PROCESS, %d, 0) = ", pid);
> + if (rc == 0) {
> + printf("%d\n", rc);
> + } else {
> + const char *errno_text;
> + switch (errno) {
> + case EACCES:
> + errno_text = "EACCES";
> + break;
> + case ENOSYS:
> + errno_text = "ENOSYS";
> + break;
> + default:
> + errno_text = "EPERM";
> + }
That's another extreme. I don't believe this setpriority call could fail
with any error besides EACCES or EPERM. Please either prove me wrong or
simplify this code to errno == EPERM ? "EPERM" : "EACCES".
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160311/809b5284/attachment.bin>
More information about the Strace-devel
mailing list