All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] ioctl09: wait for udevd complete the uevent handling
@ 2022-04-20 11:47 Li Wang
  2022-04-20 11:47 ` [LTP] [PATCH 2/2] mkswap01: wait for the triggered events to complete Li Wang
  2022-04-20 12:05 ` [LTP] [PATCH 1/2] ioctl09: wait for udevd complete the uevent handling Cyril Hrubis
  0 siblings, 2 replies; 11+ messages in thread
From: Li Wang @ 2022-04-20 11:47 UTC (permalink / raw)
  To: ltp

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);
 
-- 
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2022-04-21  7:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 11:47 [LTP] [PATCH 1/2] ioctl09: wait for udevd complete the uevent handling Li Wang
2022-04-20 11:47 ` [LTP] [PATCH 2/2] mkswap01: wait for the triggered events to complete Li Wang
2022-04-20 12:07   ` Cyril Hrubis
2022-04-20 20:56   ` Petr Vorel
2022-04-21  2:18     ` Li Wang
2022-04-21  6:44       ` Li Wang
2022-04-21  7:47         ` Petr Vorel
2022-04-20 12:05 ` [LTP] [PATCH 1/2] ioctl09: wait for udevd complete the uevent handling Cyril Hrubis
2022-04-20 12:31   ` Li Wang
2022-04-20 12:52     ` Cyril Hrubis
2022-04-21  6:36       ` Li Wang

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.