All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v1 02/10] syscalls/ioctl:add common c file for loop ioctl
Date: Fri, 3 Apr 2020 14:16:03 +0200	[thread overview]
Message-ID: <20200403121603.GD26355@yuki.lan> (raw)
In-Reply-To: <1585839990-19923-3-git-send-email-xuyang2018.jy@cn.fujitsu.com>

Hi!
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/ioctl/Makefile      |  3 +
>  .../syscalls/ioctl/ioctl_loop_support.c       | 74 +++++++++++++++++++
>  .../syscalls/ioctl/ioctl_loop_support.h       | 14 ++++
>  3 files changed, 91 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/ioctl/ioctl_loop_support.c
>  create mode 100644 testcases/kernel/syscalls/ioctl/ioctl_loop_support.h
> 
> diff --git a/testcases/kernel/syscalls/ioctl/Makefile b/testcases/kernel/syscalls/ioctl/Makefile
> index c2ff6c8e7..05a75d1b4 100644
> --- a/testcases/kernel/syscalls/ioctl/Makefile
> +++ b/testcases/kernel/syscalls/ioctl/Makefile
> @@ -7,6 +7,9 @@ include $(top_srcdir)/include/mk/testcases.mk
>  
>  INSTALL_TARGETS		+= test_ioctl
>  
> +MAKE_TARGETS            := $(patsubst $(abs_srcdir)/%.c,%,$(wildcard $(abs_srcdir)/ioctl_loop[0-9]*.c))
> +$(MAKE_TARGETS): %: ioctl_loop_support.o

I guess that we should use anything else than MAKE_TARGETS because
changing that variable will disable rest of the ioctl tests from build
right?

As this only expresses dependency on the object file we should use any
variable name that is not used by the test library itself.

>  ifeq ($(ANDROID),1)
>  FILTER_OUT_MAKE_TARGETS	+= ioctl02
>  endif
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop_support.c b/testcases/kernel/syscalls/ioctl/ioctl_loop_support.c
> new file mode 100644
> index 000000000..4099bd364
> --- /dev/null
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop_support.c
> @@ -0,0 +1,74 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved.
> + * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> + */
> +#define TST_NO_DEFAULT_MAIN
> +#include "ioctl_loop_support.h"
> +#include "tst_test.h"
> +
> +void check_sys_value(char *path, int setvalue)
> +{
> +	int getvalue;
> +
> +	SAFE_FILE_SCANF(path, "%d", &getvalue);
> +	if (setvalue == getvalue)
> +		tst_res(TPASS, "%s value is %d", path, setvalue);
> +	else
> +		tst_res(TFAIL, "%s value expected %d got %d", path, setvalue, getvalue);
> +}
> +
> +void check_sys_string(char *path, char *setmessage)
> +{
> +	char getmessage[1024];
> +
> +	SAFE_FILE_SCANF(path, "%s", getmessage);
> +	if (strcmp(setmessage, getmessage))
> +		tst_res(TFAIL, "%s expected %s got %s", path, setmessage, getmessage);
> +	else
> +		tst_res(TPASS, "%s string is %s", path, getmessage);
> +}
> +
> +void safe_set_status(int dev_fd, struct loop_info loopinfo)
> +{
> +	int sleep_us = 4096;
> +	int ret = 0;
> +
> +	/*
> +	 * It may have dirty page, so loop dirver may get EAGAIN error
> +	 * when we use different offset or sizelimit.
> +	 */
> +	ret = ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo);
> +	while (ret != 0 && errno == EAGAIN && sleep_us < 100000) {
> +		ret = ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo);
> +		usleep(sleep_us);
> +		sleep_us *= 2;
> +	}

TBROK here if we failed to set the status?

Also we should use the TST_RETRY_FUNC() instead because that one uses
the timeout multiplier environment variable.

> +}
> +
> +void safe_set_status64(int dev_fd, struct loop_info64 loopinfo)
> +{
> +	int sleep_us = 4096;
> +	int ret = 0;
> +
> +	/*
> +	 * It may have dirty page, so loop dirver may get EAGAIN error
> +	 * when we use different offset or sizelimit.
> +	 */
> +	ret = ioctl(dev_fd, LOOP_SET_STATUS64, &loopinfo);
> +	while (ret != 0 && errno == EAGAIN && sleep_us < 100000) {
> +		ret = ioctl(dev_fd, LOOP_SET_STATUS64, &loopinfo);
> +		usleep(sleep_us);
> +		sleep_us *= 2;
> +	}

Here as well.

> +}
> +
> +void check_support_cmd(int dev_fd, int ioctl_flag, int value, char *message)
> +{
> +	int ret = 0;
> +
> +	ret = ioctl(dev_fd, ioctl_flag, value);
> +	if (ret && errno == EINVAL)
> +		tst_brk(TCONF, "Current environment doesn't support this flag(%s)",
> +				message);
> +}
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop_support.h b/testcases/kernel/syscalls/ioctl/ioctl_loop_support.h
> new file mode 100644
> index 000000000..44445af8a
> --- /dev/null
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_loop_support.h
> @@ -0,0 +1,14 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 FUJITSU LIMITED. All rights reserved.
> + * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> + */
> +#ifndef IOCTL_LOOP_H
> +#define IOCTL_lOOP_H
> +#include <linux/loop.h>
> +void check_sys_value(char *path, int setvalue);
> +void check_sys_string(char *path, char *setmessage);
> +void safe_set_status(int dev_fd, struct loop_info loopinfo);
> +void safe_set_status64(int dev_fd, struct loop_info64 loopinfo);
> +void check_support_cmd(int dev_fd, int ioctl_flag, int value, char *message);
> +#endif
> -- 
> 2.23.0
> 
> 
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-04-03 12:16 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-02 15:06 [LTP] [PATCH v1 00/10] add loop ioctl test Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 01/10] lapi: Add a configure check and fallback for loop ioctl and flag Yang Xu
2020-04-03 11:44   ` Cyril Hrubis
2020-04-06  6:01     ` Yang Xu
2020-04-09  8:47   ` Martin Doucha
2020-04-09 10:09     ` Cyril Hrubis
2020-04-09 10:14     ` Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 02/10] syscalls/ioctl:add common c file for loop ioctl Yang Xu
2020-04-03 12:16   ` Cyril Hrubis [this message]
2020-04-09  2:42     ` Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 03/10] syscalls/ioctl_loop01: Add LO_FLAGS_AUTOCLEAR and LO_FLAGS_PARTSCAN test Yang Xu
2020-04-03 11:55   ` Cyril Hrubis
2020-04-06  6:27     ` Yang Xu
2020-04-09  6:10       ` Yang Xu
2020-04-09  7:55         ` Cyril Hrubis
2020-04-09 10:44           ` [LTP] [PATCH v2 01/10] lapi/loop.h: Add fallback for loop ioctl and flag Yang Xu
2020-04-09 10:44             ` [LTP] [PATCH v2 02/10] syscalls/ioctl:add common c file for loop ioctl Yang Xu
2020-04-17 15:10               ` Cyril Hrubis
2020-04-20  2:23                 ` Yang Xu
2020-04-20  6:08                   ` Yang Xu
2020-04-20 13:01                     ` Cyril Hrubis
2020-04-21  6:19                       ` Yang Xu
2020-04-21  8:55                         ` Cyril Hrubis
2020-04-21 10:35                           ` Yang Xu
2020-04-21 12:12                             ` Cyril Hrubis
2020-04-22  3:12                               ` Yang Xu
2020-04-20 12:55                   ` Cyril Hrubis
2020-04-09 10:44             ` [LTP] [PATCH v2 03/10] syscalls/ioctl_loop01: Add LO_FLAGS_AUTOCLEAR and LO_FLAGS_PARTSCAN test Yang Xu
2020-04-09 10:44             ` [LTP] [PATCH v2 04/10] syscalls/ioctl_loop02: Add LO_FLAGS_READ_ONLY and LOOP_CHANGE_FD test Yang Xu
2020-04-09 10:44             ` [LTP] [PATCH v2 05/10] syscalls/ioctl_loop03: Add LOOP_CHANGE_FD test with WR mode Yang Xu
2020-04-17 15:12               ` Cyril Hrubis
2020-04-09 10:44             ` [LTP] [PATCH v2 06/10] syscalls/ioctl_loop04: Add LOOP_SET_CAPACITY ioctl test Yang Xu
2020-04-09 10:44             ` [LTP] [PATCH v2 07/10] syscalls/ioctl_loop05: Add LOOP_SET_DIRECT_IO " Yang Xu
2020-04-09 10:44             ` [LTP] [PATCH v2 08/10] syscalls/ioctl_loop06: Add LOOP_SET_BLOCK_SIZE error test Yang Xu
2020-04-22 13:57               ` Cyril Hrubis
2020-04-09 10:44             ` [LTP] [PATCH v2 09/10] syscalls/ioctl_loop07: Add dio with logic block size " Yang Xu
2020-04-22 13:58               ` Cyril Hrubis
2020-04-23  6:06                 ` Yang Xu
2020-04-23 10:12                   ` Yang Xu
2020-04-24  4:43                     ` Yang Xu
2020-04-09 10:44             ` [LTP] [PATCH v2 10/10] syscalls/ioctl_loop08: Add LOOP_SET/GET_STATUS64 sizelimit field test Yang Xu
2020-04-28 15:44               ` Cyril Hrubis
2020-04-09 10:44             ` [LTP] [PATCH v2 00/10] add loop ioctl test Yang Xu
2020-04-09 10:50             ` [LTP] [PATCH v2 01/10] lapi/loop.h: Add fallback for loop ioctl and flag Yang Xu
2020-04-17 15:11             ` Cyril Hrubis
2020-04-27  1:24   ` [LTP] [PATCH v1 03/10] syscalls/ioctl_loop01: Add LO_FLAGS_AUTOCLEAR and LO_FLAGS_PARTSCAN test Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 04/10] syscalls/ioctl_loop02: Add LO_FLAGS_READ_ONLY and LOOP_CHANGE_FD test Yang Xu
2020-04-03 13:34   ` Cyril Hrubis
2020-04-06  7:24     ` Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 05/10] syscalls/ioctl_loop03: Add LOOP_CHANGE_FD test with WR mode Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 06/10] syscalls/ioctl_loop04: Add LOOP_SET_CAPACITY ioctl test Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 07/10] syscalls/ioctl_loop05: Add LOOP_SET_DIRECT_IO " Yang Xu
2020-04-03 16:44   ` Cyril Hrubis
2020-04-06  7:53     ` Yang Xu
2020-04-06  8:30       ` Cyril Hrubis
2020-04-02 15:06 ` [LTP] [PATCH v1 08/10] syscalls/ioctl_loop06: Add LOOP_SET_BLOCK_SIZE error test Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 09/10] syscalls/ioctl_loop07: Add dio with logic block size " Yang Xu
2020-04-02 15:06 ` [LTP] [PATCH v1 10/10] syscalls/ioctl_loop08: Add LOOP_SET/GET_STATUS64 sizelimit field test Yang Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200403121603.GD26355@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.