VirtualBox

Ignore:
Timestamp:
Feb 1, 2018 1:27:34 PM (7 years ago)
Author:
vboxsync
Message:

ValidationKit: improve API testcase for moving media (now tests all hard disk format backends, not just VDI), make pylint happy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/api/tdMoveMedium1.py

    r70816 r70849  
    4444from testdriver import base
    4545from testdriver import reporter
     46from testdriver import vboxcon
    4647from testdriver import vboxwrappers
    4748
     
    5152    Sub-test driver for Medium Move Test #1.
    5253    """
    53 
    54     # List of suffixes to append.
    55     suffixes = [
    56         '.vdi',
    57     ]
    5854
    5955    def __init__(self, oTstDrv):
     
    7975
    8076            try:
    81                 oProgress = vboxwrappers.ProgressWrapper(oMedium.setLocation(sLocation), self.oTstDrv.oVBoxMgr, self.oTstDrv, 'move "%s"' % (oMedium.name,))
     77                oProgress = vboxwrappers.ProgressWrapper(oMedium.setLocation(sLocation), self.oTstDrv.oVBoxMgr, self.oTstDrv,
     78                                                         'move "%s"' % (oMedium.name,))
    8279            except:
    8380                return reporter.errorXcpt('Medium::setLocation("%s") for medium "%s" failed' % (sLocation, oMedium.name,))
     
    105102            assert oVM is not None
    106103
    107             # create virtual disk image vdi
     104            # create disk images
    108105            fRc = True
    109106            c = 0
    110107            oSession = self.oTstDrv.openSession(oVM)
    111             for i in self.suffixes:
    112                 sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'Test' + str(c) + i)
    113                 oHd = oSession.createBaseHd(sHddPath, cb=1024*1024)
     108            aoDskFmts = self.oTstDrv.oVBoxMgr.getArray(self.oTstDrv.oVBox.systemProperties, 'mediumFormats')
     109            for oDskFmt in aoDskFmts:
     110                aoDskFmtCaps = self.oTstDrv.oVBoxMgr.getArray(oDskFmt, 'capabilities')
     111                if vboxcon.MediumFormatCapabilities_File not in aoDskFmtCaps \
     112                    or vboxcon.MediumFormatCapabilities_CreateDynamic not in aoDskFmtCaps:
     113                    continue
     114                (asExts, aTypes) = oDskFmt.describeFileExtensions()
     115                for i in range(0, len(asExts)):
     116                    if aTypes[i] is vboxcon.DeviceType_HardDisk:
     117                        sExt = '.' + asExts[i]
     118                        break
     119                if sExt is None:
     120                    fRc = False
     121                    break
     122                sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'Test' + str(c) + sExt)
     123                oHd = oSession.createBaseHd(sHddPath, sFmt=oDskFmt.id, cb=1024*1024)
    114124                if oHd is None:
    115125                    fRc = False
     
    118128                # attach HDD, IDE controller exists by default, but we use SATA just in case
    119129                sController='SATA Controller'
    120                 fRc = fRc and oSession.attachHd(sHddPath, sController, iPort = c, iDevice = 0, fImmutable=False, fForceResource=False)
    121                 fRc = fRc and oSession.saveSettings()
     130                fRc = fRc and oSession.attachHd(sHddPath, sController, iPort = c, fImmutable=False, fForceResource=False)
     131                if fRc:
     132                    c += 1
     133
     134            fRc = fRc and oSession.saveSettings()
    122135
    123136            #create temporary subdirectory in the current working directory
     
    125138            sNewLoc = os.path.join(sOrigLoc, 'newLocation/')
    126139
    127             os.makedirs(sNewLoc, 0o775)
     140            os.mkdir(sNewLoc, 0o775)
    128141
    129142            aListOfAttach = oVM.getMediumAttachmentsOfController(sController)
     
    137150
    138151            #case 3. Path with file name
    139             sLocation = sNewLoc + 'newName.vdi'
     152            sLocation = sNewLoc + 'newName'
    140153            self.setLocation(sLocation, aListOfAttach)
    141154
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette