Skip to content

Commit

Permalink
prev
Browse files Browse the repository at this point in the history
  • Loading branch information
mulkieran committed Sep 22, 2023
1 parent cd319f3 commit 85366b8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/client-dbus/tests/udev/_loopback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 85366b8

Please sign in to comment.