Skip to content

Commit

Permalink
Do not use first created loopbacked device
Browse files Browse the repository at this point in the history
Some vaguery of the test system causes it to be disappeared from the
udev database.

Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Sep 22, 2023
1 parent 7d5dd45 commit eb5b187
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 eb5b187

Please sign in to comment.