[PATCH 1/4] tests: add xetrlimit.test

Dmitry V. Levin ldv at altlinux.org
Wed Mar 9 03:29:04 UTC 2016


On Tue, Mar 08, 2016 at 02:23:19PM +0800, Fei Jie wrote:
> * tests/xetrlimit.c: New file.
> * tests/xetrlimit.test: New test.
> * tests/.gitignore: Add xetrlimit.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add xetrlimit.test.
> ---
>  tests/.gitignore     |  1 +
>  tests/Makefile.am    |  2 ++
>  tests/xetrlimit.c    | 38 ++++++++++++++++++++++++++++++++++++++
>  tests/xetrlimit.test | 11 +++++++++++
>  4 files changed, 52 insertions(+)
>  create mode 100644 tests/xetrlimit.c
>  create mode 100755 tests/xetrlimit.test
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index c6a94d8..c842781 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -139,4 +139,5 @@ xattr
>  xet_robust_list
>  xetitimer
>  xetpgid
> +xetrlimit
>  xettimeofday
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 92d3255..32d7e0a 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -187,6 +187,7 @@ check_PROGRAMS = \
>  	xet_robust_list \
>  	xetitimer \
>  	xetpgid \
> +	xetrlimit \
>  	xettimeofday \
>  	# end of check_PROGRAMS
>  
> @@ -344,6 +345,7 @@ TESTS = \
>  	xet_robust_list.test \
>  	xetitimer.test \
>  	xetpgid.test \
> +	xetrlimit.test \
>  	xettimeofday.test \
>  	\
>  	count.test \
> diff --git a/tests/xetrlimit.c b/tests/xetrlimit.c
> new file mode 100644
> index 0000000..a2444d9
> --- /dev/null
> +++ b/tests/xetrlimit.c
> @@ -0,0 +1,38 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#if defined __NR_getrlimit && defined __NR_setrlimit
> +
> +# include <errno.h>
> +# include <sys/time.h>
> +# include <sys/resource.h>
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> +	struct rlimit *const rlim = tail_alloc(sizeof(struct rlimit));
> +	int rc = syscall(__NR_getrlimit, RLIMIT_NPROC, rlim);
> +	if (rc == -1)
> +		perror_msg_and_fail("getrlimit");
> +
> +	printf("getrlimit(RLIMIT_NPROC, {rlim_cur=%d, rlim_max=%d}) = %d\n",
> +	       (int) rlim->rlim_cur, (int) rlim->rlim_max, rc);

Why "int"?  What about RLIM_INFINITY?


-- 
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/20160309/a592bb9e/attachment.bin>


More information about the Strace-devel mailing list