Changeset 99123 in vbox
- Timestamp:
- Mar 22, 2023 9:40:58 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/api/tdTreeDepth1.py
r99112 r99123 97 97 reporter.log2('parent medium = %s cDisks = %d' % (oParentMedium.location, cDisks)); 98 98 oParentMedium = oParentMedium.parent; 99 return cDisks; 100 101 def getNumOfHDsFromHardDisksArray(self): 102 """ 103 Helper routine for counting the hard disks that belong to this VM which are 104 contained in the global IVirtualBox::hardDisks[] array (which contains base media 105 only). 106 """ 107 cDisks = 0; 108 aoHDs = self.oTstDrv.oVBoxMgr.getArray(self.oTstDrv.oVBox, 'hardDisks'); 109 # Walk the IVirtualBox::hardDisks[] array for hard disks belonging to this VM. 110 # The array may contain entries from other VMs created by previous API tessts 111 # which haven't unregistered and deleted their VM's configuration. The location 112 # attribute of each disk looks similar to: 113 # /var/tmp/VBoxTestTmp/VBoxUserHome/Machines/vm 2/tdAppliance1-t2-disk1.vmdk 114 # So we compare the directory where the disk is located, i.e. the 'basefolder', 115 # with our VM's basefolder which looks similar to: 116 # /var/tmp/VBoxTestTmp/VBoxUserHome/Machines/test-medium 117 # to determine if the disk belongs to us. 118 for oHD in aoHDs: 119 sHDBaseFolder = os.path.dirname(oHD.location); 120 sVMBaseFolder = os.path.join(self.oTstDrv.oVBox.systemProperties.defaultMachineFolder, 'test-medium'); 121 reporter.log2('HDBaseFolder = %s VMBaseFolder = %s' % (sHDBaseFolder, sVMBaseFolder)); 122 if sHDBaseFolder== sVMBaseFolder: 123 cDisks = cDisks + 1; 99 124 return cDisks; 100 125 … … 209 234 oVM = None; 210 235 211 # If there is no base image (expected) then there are no leftover212 # child images either.213 c BaseImages = len(self.oTstDrv.oVBoxMgr.getArray(self.oTstDrv.oVBox, 'hardDisks'))214 reporter.log('After unregister(DetachAllReturnHardDisksOnly): API reports %d base images ' % (cBaseImages));215 if c BaseImages != 0:216 reporter.error('Got %d initial base images, expected zero (0)' % (c BaseImages));236 # If there are no base media belonging to this VM in the global IVirtualBox::hardDisks[] 237 # array (expected) then there are no leftover child images either. 238 cNumDisks = self.getNumOfHDsFromHardDisksArray(); 239 reporter.log('After unregister(DetachAllReturnHardDisksOnly): API reports %d base images (should be zero)' % (cNumDisks)); 240 if cNumDisks != 0: 241 reporter.error('Got %d initial base images, expected zero (0)' % (cNumDisks)); 217 242 218 243 # re-register to test loading of settings … … 251 276 time.sleep(3); 252 277 253 cBaseImages = len(self.oTstDrv.oVBoxMgr.getArray(self.oTstDrv.oVBox, 'hardDisks')) 254 reporter.log('After unregister(UnregisterOnly): API reports %d base images' % (cBaseImages)); 255 if cBaseImages != 0: 256 reporter.error('Got %d base images after unregistering, expected zero (0)' % (cBaseImages)); 278 # If there are no base media belonging to this VM in the global IVirtualBox::hardDisks[] 279 # array (expected) then there are no leftover child images either. 280 cNumDisks = self.getNumOfHDsFromHardDisksArray(); 281 reporter.log('After unregister(UnregisterOnly): API reports %d base images (should be zero)' % (cNumDisks)); 282 if cNumDisks != 0: 283 reporter.error('Got %d base images after unregistering, expected zero (0)' % (cNumDisks)); 257 284 258 285 return reporter.testDone()[1] == 0; … … 303 330 oVM = None; 304 331 305 # If there is no base image (expected) then there are no leftover306 # child images either.307 c BaseImages = len(self.oTstDrv.oVBoxMgr.getArray(self.oTstDrv.oVBox, 'hardDisks'))308 reporter.log('After unregister(DetachAllReturnHardDisksOnly): API reports %d base images ' % (cBaseImages));309 fRc = fRc and c BaseImages == 0310 if c BaseImages != 0:311 reporter.error('Got %d initial base images, expected zero (0)' % (c BaseImages));332 # If there are no base media belonging to this VM in the global IVirtualBox::hardDisks[] 333 # array (expected) then there are no leftover child images either. 334 cNumDisks = self.getNumOfHDsFromHardDisksArray(); 335 reporter.log('After unregister(DetachAllReturnHardDisksOnly): API reports %d base images (should be zero)' % (cNumDisks)); 336 fRc = fRc and cNumDisks == 0 337 if cNumDisks != 0: 338 reporter.error('Got %d initial base images, expected zero (0)' % (cNumDisks)); 312 339 313 340 # re-register to test loading of settings … … 345 372 time.sleep(3); 346 373 347 cBaseImages = len(self.oTstDrv.oVBoxMgr.getArray(self.oTstDrv.oVBox, 'hardDisks')) 348 reporter.log('After unregister(UnregisterOnly): API reports %d base images' % (cBaseImages)); 349 if cBaseImages != 0: 350 reporter.error('Got %d base images after unregistering, expected zero (0)' % (cBaseImages)); 374 # If there are no base media belonging to this VM in the global IVirtualBox::hardDisks[] 375 # array (expected) then there are no leftover child images either. 376 cNumDisks = self.getNumOfHDsFromHardDisksArray(); 377 reporter.log('After unregister(UnregisterOnly): API reports %d base images (should be zero)' % (cNumDisks)); 378 if cNumDisks != 0: 379 reporter.error('Got %d base images after unregistering, expected zero (0)' % (cNumDisks)); 351 380 352 381 return reporter.testDone()[1] == 0
Note:
See TracChangeset
for help on using the changeset viewer.