Skip to content

Commit

Permalink
add tests for ds-dentify's geom
Browse files Browse the repository at this point in the history
  • Loading branch information
igalic committed Oct 24, 2020
1 parent 1f4b358 commit 56e522b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unittests/test_ds_identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
UNAME_PPC64EL = ("Linux diamond 4.4.0-83-generic #106-Ubuntu SMP "
"Mon Jun 26 17:53:54 UTC 2017 "
"ppc64le ppc64le ppc64le GNU/Linux")
UNAME_FREEBSD = ("FreeBSD fbsd12-1 12.1-RELEASE-p10 "
"FreeBSD 12.1-RELEASE-p10 GENERIC amd64")

BLKID_EFI_ROOT = """
DEVNAME=/dev/sda1
Expand Down Expand Up @@ -80,6 +82,7 @@
MOCK_VIRT_IS_VM_OTHER = {'name': 'detect_virt', 'RET': 'vm-other', 'ret': 0}
MOCK_VIRT_IS_XEN = {'name': 'detect_virt', 'RET': 'xen', 'ret': 0}
MOCK_UNAME_IS_PPC64 = {'name': 'uname', 'out': UNAME_PPC64EL, 'ret': 0}
MOCK_UNAME_IS_FREEBSD = {'name': 'uname', 'out': UNAME_FREEBSD, 'ret': 0}

shell_true = 0
shell_false = 1
Expand Down Expand Up @@ -725,6 +728,17 @@ def blkid_out(disks=None):
return '\n'.join(lines)


def geom_out(disks=None):
"""Convert a list of disk dictionaries into geom content."""
if disks is None:
disks = []
lines = []
for disk in disks:
lines.append("%s/%s N/A %s" % (
disk["TYPE"], disk["LABEL"], disk["DEVNAME"]))
lines.append("")
return '\n'.join(lines)

def _print_run_output(rc, out, err, cfg, files):
"""A helper to print return of TestDsIdentify.
Expand Down Expand Up @@ -807,6 +821,19 @@ def _print_run_output(rc, out, err, cfg, files):
'dev/vdb': 'pretend iso content for cidata\n',
}
},
'NoCloud-fbsd': {
'ds': 'NoCloud',
'mocks': [
MOCK_VIRT_IS_KVM,
MOCK_UNAME_IS_FREEBSD,
{'name': 'geom', 'ret': 0,
'out': geom_out(
[{'DEVNAME': 'vtbd2', 'TYPE': 'iso9660', 'LABEL': 'cidata'}])},
],
'files': {
'/dev/vtdb2': 'pretend iso content for cidata\n',
}
},
'NoCloudUpper': {
'ds': 'NoCloud',
'mocks': [
Expand Down

0 comments on commit 56e522b

Please sign in to comment.