[PATCH v3 1/3] tests: add xetpriority.test

Dmitry V. Levin ldv at altlinux.org
Wed Mar 9 23:14:59 UTC 2016


On Wed, Mar 09, 2016 at 02:07:04PM +0800, Fei Jie wrote:
> * tests/xetpriority.c: New file.
> * tests/xetpriority.test: New test.
> * tests/.gitignore: Add xetpriority.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add xetpriority.test.
> * resource.c (sys_getpriority): printf tcp->u_arg[1] in %d format.
> * resource.c (sys_setpriority): printf tcp->u_arg[1] in %d format.

The text describing resource.c changes is not descriptive.
Try something like "Print the second syscall argument using %d format".
Also, resource.c should go before tests/.

> ---
>  resource.c             |  4 ++--
>  tests/.gitignore       |  1 +
>  tests/Makefile.am      |  2 ++
>  tests/xetpriority.c    | 34 ++++++++++++++++++++++++++++++++++
>  tests/xetpriority.test | 11 +++++++++++
>  5 files changed, 50 insertions(+), 2 deletions(-)
>  create mode 100644 tests/xetpriority.c
>  create mode 100755 tests/xetpriority.test
> 
> diff --git a/resource.c b/resource.c
> index c68f045..9aacfbe 100644
> --- a/resource.c
> +++ b/resource.c
> @@ -184,7 +184,7 @@ SYS_FUNC(osf_getrusage)
>  SYS_FUNC(getpriority)
>  {
>  	printxval(priorities, tcp->u_arg[0], "PRIO_???");
> -	tprintf(", %lu", tcp->u_arg[1]);
> +	tprintf(", %d", (int) tcp->u_arg[1]);
>  
>  	return RVAL_DECODED;
>  }
> @@ -192,7 +192,7 @@ SYS_FUNC(getpriority)
>  SYS_FUNC(setpriority)
>  {
>  	printxval(priorities, tcp->u_arg[0], "PRIO_???");
> -	tprintf(", %lu, %d", tcp->u_arg[1], (int) tcp->u_arg[2]);
> +	tprintf(", %d, %d", (int) tcp->u_arg[1], (int) tcp->u_arg[2]);
>  
>  	return RVAL_DECODED;
>  }
> diff --git a/tests/.gitignore b/tests/.gitignore
> index c6a94d8..3c365e0 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -139,4 +139,5 @@ xattr
>  xet_robust_list
>  xetitimer
>  xetpgid
> +xetpriority
>  xettimeofday
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 92d3255..4c41ef0 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -187,6 +187,7 @@ check_PROGRAMS = \
>  	xet_robust_list \
>  	xetitimer \
>  	xetpgid \
> +	xetpriority \
>  	xettimeofday \
>  	# end of check_PROGRAMS
>  
> @@ -344,6 +345,7 @@ TESTS = \
>  	xet_robust_list.test \
>  	xetitimer.test \
>  	xetpgid.test \
> +	xetpriority.test \
>  	xettimeofday.test \
>  	\
>  	count.test \
> diff --git a/tests/xetpriority.c b/tests/xetpriority.c
> new file mode 100644
> index 0000000..d0fd36d
> --- /dev/null
> +++ b/tests/xetpriority.c
> @@ -0,0 +1,34 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#if defined __NR_getpriority && defined __NR_setpriority
> +
> +# 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) = %d\n",
> +	       pid, rc);

You cannot assume that this setpriority syscall will always succeed.
Just otherwise, you can easily make it fail, just run
$ nice strace -esetpriority ./xetpriority


-- 
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/20160310/5eab9543/attachment.bin>


More information about the Strace-devel mailing list