[PATCH v5] tests: add xetpriority.test

Dmitry V. Levin ldv at altlinux.org
Wed Mar 16 18:01:38 UTC 2016


On Tue, Mar 15, 2016 at 04:37:19PM +0800, Fei Jie wrote:
> * resource.c (SYS_FUNC(getpriority)): Print the second syscall
> argument using %d format.
> * resource.c (SYS_FUNC(setpriority)): Print the second syscall
> argument using %d format.

This could and should be merged into a single "line", e.g.

* resource.c (SYS_FUNC(getpriority), SYS_FUNC(setpriority)): Print
the second syscall argument using %d format.

> +++ b/tests/xetpriority.c
> @@ -0,0 +1,41 @@
> +#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 {
> +		printf("%d %s (%m)\n",
> +		       rc, errno == EPERM ? "EPERM" : "EACCES");
> +	}

Theoretically, printf can clobber errno, so let's do it
without a common printf statement.


-- 
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/20160316/97e3002f/attachment.bin>


More information about the Strace-devel mailing list