VirtualBox

Ignore:
Timestamp:
Apr 13, 2022 9:50:00 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150959
Message:

Main/Machine+Medium+Snapshot+VirtualBox: Recursion elimination to save stack space. Caused trouble with the current settings limits already in ASAN builds, now much higher limits would be possible, but that's not urgent. Also fix the behavior of forgetting medium objects when unregistering VMs (was previously not doing what the API documentation said in the CleanupMode_UnregisterOnly case). bugref:7717

Settings.cpp: Recursion elimination and make the handling of settings reading and writing more similar.

ValidationKit/tests/api/tdTreeDepth1.py: Improve testcase. Make sure that VM unregistering does the right thing with the associated medium objects.

File:
1 edited

Legend:

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

    r93115 r94598  
    3434import os
    3535import sys
     36import random
    3637
    3738# Only the main script needs to modify the path.
     
    7374
    7475        try:
     76            oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox()
    7577            oVM = self.oTstDrv.createTestVM('test-medium', 1, None, 4)
    7678            assert oVM is not None
     
    7981            fRc = True
    8082            oSession = self.oTstDrv.openSession(oVM)
    81             for i in range(1, 301):
     83            cImages = 38 #00
     84            for i in range(1, cImages + 1):
    8285                sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'Test' + str(i) + '.vdi')
    8386                if i == 1:
     
    9396            fRc = fRc and oSession.saveSettings()
    9497            fRc = oSession.close() and fRc
    95 
    96             # unregister and re-register to test loading of settings
     98            ## @todo r=klaus: count known hard disk images, should be cImages
     99
     100            # unregister, making sure the images are closed
    97101            sSettingsFile = oVM.settingsFilePath
    98             reporter.log('unregistering VM')
    99             oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone)
    100             oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox()
     102            fDetachAll = random.choice([False, True])
     103            if fDetachAll:
     104                reporter.log('unregistering VM, DetachAll style')
     105            else:
     106                reporter.log('unregistering VM, UnregisterOnly style')
     107            self.oTstDrv.forgetTestMachine(oVM)
     108            if fDetachAll:
     109                aoHDs = oVM.unregister(vboxcon.CleanupMode_DetachAllReturnHardDisksOnly)
     110                for oHD in aoHDs:
     111                    oHD.close()
     112                aoHDs = None
     113            else:
     114                oVM.unregister(vboxcon.CleanupMode_UnregisterOnly)
     115            oVM = None
     116           
     117            # If there is no base image (expected) then there are no leftover
     118            # child images either. Can be changed later once the todos above
     119            # and below are resolved.
     120            cBaseImages = len(self.oTstDrv.oVBoxMgr.getArray(oVBox, 'hardDisks'))
     121            reporter.log('API reports %i base images' % (cBaseImages))
     122            fRc = fRc and cBaseImages == 0
     123
     124            # re-register to test loading of settings
    101125            reporter.log('opening VM %s, testing config reading' % (sSettingsFile))
    102126            oVM = oVBox.openMachine(sSettingsFile)
     127            ## @todo r=klaus: count known hard disk images, should be cImages
     128
     129            reporter.log('unregistering VM')
     130            oVM.unregister(vboxcon.CleanupMode_UnregisterOnly)
     131            oVM = None
     132
     133            cBaseImages = len(self.oTstDrv.oVBoxMgr.getArray(oVBox, 'hardDisks'))
     134            reporter.log('API reports %i base images' % (cBaseImages))
     135            fRc = fRc and cBaseImages == 0
    103136
    104137            assert fRc is True
     
    115148
    116149        try:
     150            oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox()
    117151            oVM = self.oTstDrv.createTestVM('test-snap', 1, None, 4)
    118152            assert oVM is not None
     
    126160
    127161            # take 250 snapshots (snapshot tree depth limit)
    128             for i in range(1, 251):
     162            cSnapshots = 13 #00
     163            for i in range(1, cSnapshots + 1):
    129164                fRc = fRc and oSession.takeSnapshot('Snapshot ' + str(i))
    130165            fRc = oSession.close() and fRc
    131 
    132             # unregister and re-register to test loading of settings
     166            oSession = None
     167            reporter.log('API reports %i snapshots' % (oVM.snapshotCount))
     168            fRc = fRc and oVM.snapshotCount == cSnapshots
     169
     170            assert fRc is True
     171
     172            # unregister, making sure the images are closed
    133173            sSettingsFile = oVM.settingsFilePath
    134             reporter.log('unregistering VM')
    135             oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone)
    136             oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox()
     174            fDetachAll = random.choice([False, True])
     175            if fDetachAll:
     176                reporter.log('unregistering VM, DetachAll style')
     177            else:
     178                reporter.log('unregistering VM, UnregisterOnly style')
     179            self.oTstDrv.forgetTestMachine(oVM)
     180            if fDetachAll:
     181                aoHDs = oVM.unregister(vboxcon.CleanupMode_DetachAllReturnHardDisksOnly)
     182                for oHD in aoHDs:
     183                    oHD.close()
     184                aoHDs = None
     185            else:
     186                oVM.unregister(vboxcon.CleanupMode_UnregisterOnly)
     187            oVM = None
     188
     189            # If there is no base image (expected) then there are no leftover
     190            # child images either. Can be changed later once the todos above
     191            # and below are resolved.
     192            cBaseImages = len(self.oTstDrv.oVBoxMgr.getArray(oVBox, 'hardDisks'))
     193            reporter.log('API reports %i base images' % (cBaseImages))
     194            fRc = fRc and cBaseImages == 0
     195
     196            # re-register to test loading of settings
    137197            reporter.log('opening VM %s, testing config reading' % (sSettingsFile))
    138198            oVM = oVBox.openMachine(sSettingsFile)
     199            reporter.log('API reports %i snapshots' % (oVM.snapshotCount))
     200            fRc = fRc and oVM.snapshotCount == cSnapshots
     201
     202            reporter.log('unregistering VM')
     203            oVM.unregister(vboxcon.CleanupMode_UnregisterOnly)
     204            oVM = None
     205
     206            cBaseImages = len(self.oTstDrv.oVBoxMgr.getArray(oVBox, 'hardDisks'))
     207            reporter.log('API reports %i base images' % (cBaseImages))
     208            fRc = fRc and cBaseImages == 0
    139209
    140210            assert fRc is True
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