Skip to content

Commit

Permalink
tests: Use sfdisk instead of parted to create partitions in tests
Browse files Browse the repository at this point in the history
Fixes: #1355
  • Loading branch information
vojtechtrefny committed Feb 26, 2025
1 parent 7830d04 commit 76d5520
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions misc/udisks-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
- python3-monotonic
- cryptsetup
- vdo
- parted
- util-linux
when: ansible_distribution == 'Fedora'

####### CentOS
Expand Down Expand Up @@ -107,5 +107,5 @@
- python3-systemd
- cryptsetup
- vdo
- parted
- util-linux
when: ansible_distribution == 'CentOS'
4 changes: 2 additions & 2 deletions src/tests/dbus-tests/test_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ def test_40_create_read_only(self):
@udiskstestcase.tag_test(udiskstestcase.TestTags.UNSTABLE)
def test_50_create_no_part_scan(self):
# create a partition on the file (future loop device)
ret, out = self.run_command("parted %s mklabel msdos" % self.LOOP_DEVICE_FILENAME)
ret, out = self.run_command("echo -e 'label:dos' | sfdisk %s" % self.LOOP_DEVICE_FILENAME)
self.assertEqual(ret, 0)
ret, out = self.run_command("parted %s mkpart primary ext2 1 10" % self.LOOP_DEVICE_FILENAME)
ret, out = self.run_command("echo -e 'size=+, type=L\n' | sfdisk %s" % self.LOOP_DEVICE_FILENAME)
self.assertEqual(ret, 0)

opts = dbus.Dictionary({"no-part-scan": dbus.Boolean(True)}, signature=dbus.Signature('sv'))
Expand Down
15 changes: 6 additions & 9 deletions src/tests/integration-test
Original file line number Diff line number Diff line change
Expand Up @@ -1185,16 +1185,13 @@ class Fstab(UDisksTestCase):
cls.orig_fstab = '/etc/fstab.udiskstest'
shutil.copy2('/etc/fstab', cls.orig_fstab)

# create one partition
subprocess.check_call(
['parted', '-s', cls.device, 'mklabel', 'gpt'], stdout=subprocess.PIPE)
subprocess.check_call(
['parted', '-s', cls.device, 'mkpart', 'primary', '0', '64'],
stdout=subprocess.PIPE)
cls.p1label = 'udtestp1'
subprocess.check_call(
['parted', '-s', cls.device, 'name', '1', cls.p1label],
stdout=subprocess.PIPE)

# create one partition
subprocess.check_call("echo -e 'label:gpt' | sfdisk %s" % cls.device,
stdout=subprocess.PIPE, shell=True)
subprocess.check_call("echo -e 'size=60M, type=L, name=%s\n' | sfdisk %s" % (cls.p1label, cls.device),
stdout=subprocess.PIPE, shell=True)
cls.sync()
blkid = subprocess.check_output(
['blkid', '-oudev', '-p', cls.devname(1)], universal_newlines=True).splitlines()
Expand Down

0 comments on commit 76d5520

Please sign in to comment.