Skip to content

Commit

Permalink
test: Allow specification of size unit with add_loopback_disk
Browse files Browse the repository at this point in the history
  • Loading branch information
mvollmer committed May 28, 2024
1 parent 5d603a0 commit be7f9c2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/common/storagelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ def add_loopback_disk(self, size=50, name=None):
# HACK: https://bugzilla.redhat.com/show_bug.cgi?id=1969408
# It would be nicer to remove $F immediately after the call to
# losetup, but that will break some versions of lvm2.
size_string = size if isinstance(size, str) else str(size) + "MB"
backf = self.machine.execute("mktemp /var/tmp/loop.XXXX").strip()
dev = self.machine.execute(f"truncate --size={size}MB {backf}; "
dev = self.machine.execute(f"truncate --size={size_string} {backf}; "
f"losetup -P --show {name if name else '--find'} {backf}").strip()
# If this device had partions in its last incarnation on this
# machine, they might come back for unknown reasons, in a
Expand Down

0 comments on commit be7f9c2

Please sign in to comment.