[LTP] [PATCH 1/2] ioctl09: wait for udevd complete the uevent handling

Cyril Hrubis chrubis@suse.cz
Wed Apr 20 14:05:41 CEST 2022


Hi!
> This is quite necessary to wait for uevent handing settled before
> checking the partition is taken effect.
> 
>   `udevadm monitor` listening from another terminal:
> 
>   KERNEL[447.077683] change   /devices/virtual/block/loop0 (block)
>   KERNEL[447.077939] add      /devices/virtual/block/loop0/loop0p1 (block)
>   KERNEL[447.077999] add      /devices/virtual/block/loop0/loop0p2 (block)
>   UDEV  [447.081138] change   /devices/virtual/block/loop0 (block)
>   UDEV  [447.083490] add      /devices/virtual/block/loop0/loop0p1 (block)
>   UDEV  [447.086898] add      /devices/virtual/block/loop0/loop0p2 (block)
> 
> Which helps to get rid of such boring failures:
> 
>   ioctl09.c:44: TPASS: access /sys/block/loop0/loop0p1 succeeds
>   ioctl09.c:52: TPASS: access /dev/loop0p1 succeeds
>   ioctl09.c:47: TFAIL: access /sys/block/loop0/loop0p2 fails
>   ioctl09.c:55: TFAIL: access /dev/loop0p2 fails
> 
> I manually confirmed those failures disappeared from a reproducible system
> even with running 10000 times.
> 
> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  testcases/kernel/syscalls/ioctl/ioctl09.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl09.c b/testcases/kernel/syscalls/ioctl/ioctl09.c
> index 9728ecb9c..533a4a5d0 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl09.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl09.c
> @@ -58,6 +58,10 @@ static void check_partition(int part_num, bool value)
>  
>  static void verify_ioctl(void)
>  {
> +	char cmd[BUFSIZ];
> +
> +	sprintf(cmd, "udevadm settle --exit-if-exists=%s", dev_path);
> +
>  	const char *const cmd_parted_old[] = {"parted", "-s", "test.img",
>  					      "mklabel", "msdos", "mkpart",
>  					      "primary", "ext4", "1M", "10M",
> @@ -75,11 +79,13 @@ static void verify_ioctl(void)
>  
>  	loopinfo.lo_flags =  LO_FLAGS_PARTSCAN;
>  	SAFE_IOCTL(dev_fd, LOOP_SET_STATUS, &loopinfo);
> +	tst_system(cmd);
>  	check_partition(1, true);
>  	check_partition(2, false);
>  
>  	change_partition(cmd_parted_new);
>  	TST_RETRY_FUNC(ioctl(dev_fd, BLKRRPART, 0), TST_RETVAL_EQ0);
> +	tst_system(cmd);
>  	check_partition(1, true);
>  	check_partition(2, true);

We allready use TST_RETRY_FN_EXP_BACKOFF() in there with 30 second
timeout isn't that enough? And if it isn't wouldn't simply increasing
the timeout to a minute or two fix the issue?

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list