[PATCH 2/2] tests: check decoding of readahead syscall

Dmitry V. Levin ldv at altlinux.org
Thu Sep 1 09:39:14 UTC 2016


On Thu, Sep 01, 2016 at 02:43:30AM +0300, Eugene Syromyatnikov wrote:
> * tests/readahead.c: New file.
> * tests/readahead.test: New test.
> * tests/.gitignore: Add readahead.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
>   (DECODER_TESTS): Add readahead.test.
> ---
> Simple test for simple decoder.
> 
>  tests/.gitignore     |    1 +
>  tests/Makefile.am    |    2 ++
>  tests/readahead.c    |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/readahead.test |    6 +++++
>  4 files changed, 72 insertions(+)
>  create mode 100644 tests/readahead.c
>  create mode 100755 tests/readahead.test
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 5c5d092..8c41bea 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -185,6 +185,7 @@ pselect6
>  ptrace
>  pwritev
>  read-write
> +readahead
>  readdir
>  readlink
>  readlinkat
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index b879bf4..d7421fc 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -241,6 +241,7 @@ check_PROGRAMS = \
>  	ptrace \
>  	pwritev \
>  	read-write \
> +	readahead \
>  	readdir \
>  	readlink \
>  	readlinkat \
> @@ -568,6 +569,7 @@ DECODER_TESTS = \
>  	ptrace.test \
>  	pwritev.test \
>  	read-write.test \
> +	readahead.test \
>  	readdir.test \
>  	readlink.test \
>  	readlinkat.test \
> diff --git a/tests/readahead.c b/tests/readahead.c
> new file mode 100644
> index 0000000..307dbff
> --- /dev/null
> +++ b/tests/readahead.c
> @@ -0,0 +1,63 @@
> +#include "tests.h"
> +#include <asm/unistd.h>
> +
> +#ifdef __NR_readahead
> +
> +# include <fcntl.h>
> +# include <stdio.h>
> +
> +static const int fds[] = {
> +	-0x80000000,
> +	-100,
> +	-1,
> +	0,
> +	1,
> +	2,
> +	0x7fffffff,
> +};
> +
> +static const off64_t offsets[] = {
> +	-0x8000000000000000LL,
> +	-0x5060708090a0b0c0LL,
> +	-1LL,
> +	 0,
> +	 1,
> +	 0xbadfaced,
> +	 0x7fffffffffffffffLL,
> +};
> +
> +static const unsigned long counts[] = {
> +	0UL,
> +	0xdeadca75,
> +	(unsigned long)0xface1e55beeff00dULL,
> +	(unsigned long)0xffffffffffffffffULL,
> +};
> +
> +int
> +main(void)
> +{
> +	unsigned i;
> +	unsigned j;
> +	unsigned k;
> +	ssize_t rc;
> +
> +	for (i = 0; i < ARRAY_SIZE(fds); i++)
> +		for (j = 0; j < ARRAY_SIZE(offsets); j++)
> +			for (k = 0; k < ARRAY_SIZE(counts); k++) {
> +				rc = readahead(fds[i], offsets[j], counts[k]);
> +
> +				printf("readahead(%d, %lld, %lu) = "
> +					"%ld %s (%m)\n", fds[i],
> +					(long long)offsets[j], counts[k], rc,
> +					errno2name());

What if this syscall returned 0?


-- 
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/20160901/0563127a/attachment.bin>


More information about the Strace-devel mailing list