[PATCH v7] tests/fcntl.c: add test for print_f_owner_ex

Dmitry V. Levin ldv at altlinux.org
Sat Apr 28 20:40:51 UTC 2018


On Tue, Apr 17, 2018 at 09:09:48PM +0800, Zhibin Li wrote:
> *tests/fcntl.c include <stdarg.h>

* tests/fcntl.c: Include <stdarg.h>.

> (test_f_owner_ex_type_pid, test_f_owner_ex_umove)
> (test_f_owner_ex): New functions.

(test_f_owner_ex_type_pid, test_f_owner_ex_umove, test_f_owner_ex): New
functions.

> (main): Use test_f_owner_ex.
> ---
>  tests/fcntl.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 65 insertions(+)
> 
> diff --git a/tests/fcntl.c b/tests/fcntl.c
> index 4f62ca2a..2270ee57 100644
> --- a/tests/fcntl.c
> +++ b/tests/fcntl.c
> @@ -28,6 +28,7 @@
>  
>  #include "tests.h"
>  #include <asm/unistd.h>
> +#include <stdarg.h>
>  
>  #ifdef __NR_fcntl
>  
> @@ -69,12 +70,76 @@ test_flock64(void)
>  #endif
>  }
>  
> +static long
> +test_f_owner_ex_type_pid(const int cmd, const char *const cmd_name, ...)
> +{
> +	va_list ap;
> +	va_start(ap, cmd_name);
> +
> +	long rc;
> +	const char *type_name;
> +
> +	TAIL_ALLOC_OBJECT_CONST_PTR(struct f_owner_ex, fo);
> +
> +	if ((type_name = va_arg(ap, char *)) != NULL) {
> +		fo->type = va_arg(ap, int);
> +		fo->pid = va_arg(ap, int);
> +
> +		rc = invoke_test_syscall(cmd, fo);
> +		printf("%s(0, %s, {type=%s, pid=%d}) = %s\n",
> +		       TEST_SYSCALL_STR, cmd_name, type_name, fo->pid, sprintrc(rc));
> +		va_end(ap);
> +		return rc;
> +	}
> +
> +	rc = invoke_test_syscall(cmd, (void *) (uintptr_t) fo + 1);
> +	printf("%s(0, %s, %p) = %s\n",
> +	       TEST_SYSCALL_STR, cmd_name, (void *) (uintptr_t) fo + 1, sprintrc(rc));
> +	va_end(ap);
> +	return rc;
> +}

This is way more complicated than necessary.

We can test invalid address decoding every time we test regular decoding,
this would make everything short and simple, and this stdarg stuff
won't be needed at all.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20180428/e14681cd/attachment.bin>


More information about the Strace-devel mailing list