Skip to content

Commit

Permalink
Merge pull request #5677 from shirishaganta1/fix-disk
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Richter <[email protected]>
  • Loading branch information
richtja authored Jan 11, 2024
2 parents aa82dac + ba71aa4 commit dd6dd4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion avocado/utils/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@ def get_disks():
"""
json_result = process.run("lsblk --json --paths --inverse")
json_data = json.loads(json_result.stdout_text)
return [str(disk["name"]) for disk in json_data["blockdevices"]]
disks = []
for device in json_data["blockdevices"]:
disks.append(device["name"])
if "children" in device:
for child in device["children"]:
disks.append(child["name"])
return disks


def get_all_disk_paths():
Expand Down
9 changes: 8 additions & 1 deletion selftests/unit/utils/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ def test_disks(self):
with unittest.mock.patch(
"avocado.utils.disk.process.run", return_value=mock_result
):
self.assertEqual(disk.get_disks(), ["/dev/vda"])
expected_diskname = [
"/dev/vda",
"/dev/vda1",
"/dev/vda2",
"/dev/vda3",
"/dev/vda4",
]
self.assertEqual(sorted(disk.get_disks()), sorted(expected_diskname))

def test_get_filesystems(self):
expected_fs = ["dax", "bpf", "pipefs", "hugetlbfs", "devpts", "ext3"]
Expand Down

0 comments on commit dd6dd4a

Please sign in to comment.