From 85366b857563bab47bab4ba236e22efe84c851fc Mon Sep 17 00:00:00 2001 From: mulhern Date: Fri, 22 Sep 2023 12:06:43 -0400 Subject: [PATCH] prev --- tests/client-dbus/tests/udev/_loopback.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/client-dbus/tests/udev/_loopback.py b/tests/client-dbus/tests/udev/_loopback.py index f7386d176ed..b05c61f6868 100644 --- a/tests/client-dbus/tests/udev/_loopback.py +++ b/tests/client-dbus/tests/udev/_loopback.py @@ -97,11 +97,21 @@ def create_devices(self, number): Note: The first time a loop back device is known it will generate a udev "add" event, subsequent backing file changes do not, thus we will need to generate it synthetically. + + If this is the absolute first time calling losetup for this sequence, + make an extra loop device and skip the first loop device created. + :param int number: the number of devices to create :return: list of keys for the devices :rtype: list of uuid.UUID """ tokens = [] + + first_creation = self.count == 0 + + if first_creation: + number = number + 1 + for _ in range(number): backing_file = os.path.join(self.dir, f"block_device_{self.count}") self.count += 1 @@ -119,6 +129,9 @@ def create_devices(self, number): self.devices[token] = (device, backing_file) tokens.append(token) + if first_creation: + tokens = tokens[1:] + self._wait_for_udev(tokens) self.generate_synthetic_udev_events(tokens, UDEV_ADD_EVENT) return tokens