Changeset 70812 in vbox for trunk/src/VBox/ValidationKit/tests/api
- Timestamp:
- Jan 30, 2018 5:46:55 PM (7 years ago)
- Location:
- trunk/src/VBox/ValidationKit/tests/api
- Files:
-
- 3 edited
- 1 copied
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/api/tdApi1.py
r70788 r70812 4 4 5 5 """ 6 VirtualBox Validation Kit - Medium and Snapshot Tree Depth Test #16 VirtualBox Validation Kit - API Test wrapper #1 combining all API sub-tests 7 7 """ 8 8 … … 42 42 43 43 # Validation Kit imports. 44 from testdriver import reporter45 44 from testdriver import vbox 46 from testdriver import vboxcon47 45 48 46 49 class td TreeDepth1(vbox.TestDriver):47 class tdApi1(vbox.TestDriver): 50 48 """ 51 Medium and Snapshot Tree Depth Test#1.49 API Test wrapper #1. 52 50 """ 53 51 54 def __init__(self ):52 def __init__(self, aoSubTestDrivers = None): 55 53 vbox.TestDriver.__init__(self) 56 54 self.asRsrcs = None 57 58 55 59 56 # … … 71 68 def actionExecute(self): 72 69 """ 73 Execute the testcase .70 Execute the testcase, i.e. all sub-tests. 74 71 """ 75 return self.testMediumTreeDepth() \ 76 and self.testSnapshotTreeDepth() 77 78 # 79 # Test execution helpers. 80 # 81 82 def testMediumTreeDepth(self): 83 """ 84 Test medium tree depth. 85 """ 86 reporter.testStart('mediumTreeDepth') 87 88 try: 89 oVM = self.createTestVM('test-medium', 1, None, 4) 90 assert oVM is not None 91 92 # create chain with 300 disk images (medium tree depth limit) 93 fRc = True 94 oSession = self.openSession(oVM) 95 for i in range(1, 301): 96 sHddPath = os.path.join(self.sScratchPath, 'Test' + str(i) + '.vdi') 97 if i is 1: 98 oHd = oSession.createBaseHd(sHddPath, cb=1024*1024) 99 else: 100 oHd = oSession.createDiffHd(oHd, sHddPath) 101 if oHd is None: 102 fRc = False 103 break 104 105 # modify the VM config, attach HDD 106 fRc = fRc and oSession.attachHd(sHddPath, sController='SATA Controller', fImmutable=False, fForceResource=False) 107 fRc = fRc and oSession.saveSettings() 108 fRc = oSession.close() and fRc 109 110 # unregister and re-register to test loading of settings 111 sSettingsFile = oVM.settingsFilePath 112 reporter.log('unregistering VM') 113 oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone) 114 oVBox = self.oVBoxMgr.getVirtualBox() 115 reporter.log('opening VM %s, testing config reading' % (sSettingsFile)) 116 oVM = oVBox.openMachine(sSettingsFile) 117 118 assert fRc is True 119 except: 120 reporter.errorXcpt() 121 122 return reporter.testDone()[1] == 0 123 124 def testSnapshotTreeDepth(self): 125 """ 126 Test snapshot tree depth. 127 """ 128 reporter.testStart('snapshotTreeDepth') 129 130 try: 131 oVM = self.createTestVM('test-snap', 1, None, 4) 132 assert oVM is not None 133 134 # modify the VM config, create and attach empty HDD 135 oSession = self.openSession(oVM) 136 sHddPath = os.path.join(self.sScratchPath, 'TestSnapEmpty.vdi') 137 fRc = True 138 fRc = fRc and oSession.createAndAttachHd(sHddPath, cb=1024*1024, sController='SATA Controller', fImmutable=False) 139 fRc = fRc and oSession.saveSettings() 140 141 # take 250 snapshots (snapshot tree depth limit) 142 for i in range(1, 251): 143 fRc = fRc and oSession.takeSnapshot('Snapshot ' + str(i)) 144 fRc = oSession.close() and fRc 145 146 # unregister and re-register to test loading of settings 147 sSettingsFile = oVM.settingsFilePath 148 reporter.log('unregistering VM') 149 oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone) 150 oVBox = self.oVBoxMgr.getVirtualBox() 151 reporter.log('opening VM %s, testing config reading' % (sSettingsFile)) 152 oVM = oVBox.openMachine(sSettingsFile) 153 154 assert fRc is True 155 except: 156 reporter.errorXcpt() 157 158 return reporter.testDone()[1] == 0 72 fRc = True 73 for oSubTstDrv in self.aoSubTstDrvs: 74 fRc &= oSubTstDrv.testIt() 75 return fRc 159 76 160 77 161 78 if __name__ == '__main__': 162 sys.exit(tdTreeDepth1().main(sys.argv)) 79 sys.path.append(os.path.dirname(os.path.abspath(__file__))) 80 oTstDrv = tdApi1() 81 from tdPython1 import SubTstDrvPython1 82 oTstDrv.addSubTestDriver(SubTstDrvPython1(oTstDrv)) 83 from tdAppliance1 import SubTstDrvAppliance1 84 oTstDrv.addSubTestDriver(SubTstDrvAppliance1(oTstDrv)) 85 from tdMoveMedium1 import SubTstDrvMoveMedium1 86 oTstDrv.addSubTestDriver(SubTstDrvMoveMedium1(oTstDrv)) 87 from tdTreeDepth1 import SubTstDrvTreeDepth1 88 oTstDrv.addSubTestDriver(SubTstDrvTreeDepth1(oTstDrv)) 89 sys.exit(oTstDrv.main(sys.argv)) 163 90 -
trunk/src/VBox/ValidationKit/tests/api/tdAppliance1.py
r70521 r70812 38 38 # Only the main script needs to modify the path. 39 39 try: __file__ 40 except: __file__ = sys.argv[0] ;41 g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) ;42 sys.path.append(g_ksValidationKitDir) ;40 except: __file__ = sys.argv[0] 41 g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 42 sys.path.append(g_ksValidationKitDir) 43 43 44 44 # Validation Kit imports. 45 from testdriver import reporter; 46 from testdriver import base; 47 from testdriver import vbox; 48 from testdriver import vboxwrappers; 49 50 51 class tdAppliance1(vbox.TestDriver): 45 from testdriver import base 46 from testdriver import reporter 47 from testdriver import vboxwrappers 48 49 50 class SubTstDrvAppliance1(base.SubTestDriverBase): 52 51 """ 53 IAppliance Test #1.52 Sub-test driver for IAppliance Test #1. 54 53 """ 55 54 56 def __init__(self): 57 vbox.TestDriver.__init__(self); 58 self.asRsrcs = None; 59 60 61 # 62 # Overridden methods. 63 # 64 65 def actionConfig(self): 66 """ 67 Import the API. 68 """ 69 if not self.importVBoxApi(): 70 return False; 71 return True; 72 73 def actionExecute(self): 74 """ 75 Execute the testcase. 76 """ 77 fRc = True; 55 def __init__(self, oTstDrv): 56 base.SubTestDriverBase.__init__(self, 'appliance', oTstDrv) 57 58 def testIt(self): 59 """ 60 Execute the sub-testcase. 61 """ 62 fRc = True 78 63 79 64 # Import a set of simple OVAs. … … 103 88 'tdAppliance1-t7-bad-instance.ova', 104 89 ): 105 reporter.testStart(sOva) ;90 reporter.testStart(sOva) 106 91 try: 107 fRc = self.testImportOva(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc ;108 fRc = self.testImportOvaAsOvf(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc ;92 fRc = self.testImportOva(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc 93 fRc = self.testImportOvaAsOvf(os.path.join(g_ksValidationKitDir, 'tests', 'api', sOva)) and fRc 109 94 except: 110 reporter.errorXcpt() ;111 fRc = False ;112 fRc = reporter.testDone() and fRc ;95 reporter.errorXcpt() 96 fRc = False 97 fRc = reporter.testDone() and fRc 113 98 114 99 ## @todo more stuff 115 return fRc ;100 return fRc 116 101 117 102 # … … 121 106 def testImportOva(self, sOva): 122 107 """ xxx """ 123 oVirtualBox = self.o VBoxMgr.getVirtualBox();108 oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 124 109 125 110 # … … 127 112 # 128 113 try: 129 oAppliance = oVirtualBox.createAppliance(); 130 except: 131 return reporter.errorXcpt('IVirtualBox::createAppliance failed'); 132 print("oAppliance=%s" % (oAppliance,)); 133 134 try: 135 oProgress = vboxwrappers.ProgressWrapper(oAppliance.read(sOva), self.oVBoxMgr, self, 'read "%s"' % (sOva,)); 136 except: 137 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOva,)); 138 oProgress.wait(); 139 if oProgress.logResult() is False: 140 return False; 141 142 try: 143 oAppliance.interpret(); 144 except: 145 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOva,)); 114 oAppliance = oVirtualBox.createAppliance() 115 except: 116 return reporter.errorXcpt('IVirtualBox::createAppliance failed') 117 118 try: 119 oProgress = vboxwrappers.ProgressWrapper(oAppliance.read(sOva), self.oTstDrv.oVBoxMgr, self.oTstDrv, 'read "%s"' % (sOva,)) 120 except: 121 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOva,)) 122 oProgress.wait() 123 if oProgress.logResult() is False: 124 return False 125 126 try: 127 oAppliance.interpret() 128 except: 129 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOva,)) 146 130 147 131 # 148 132 try: 149 133 oProgress = vboxwrappers.ProgressWrapper(oAppliance.importMachines([]), 150 self.o VBoxMgr, self, 'importMachines "%s"' % (sOva,));151 except: 152 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOva,)) ;153 oProgress.wait() ;154 if oProgress.logResult() is False: 155 return False ;134 self.oTstDrv.oVBoxMgr, self.oTstDrv, 'importMachines "%s"' % (sOva,)) 135 except: 136 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOva,)) 137 oProgress.wait() 138 if oProgress.logResult() is False: 139 return False 156 140 157 141 # … … 160 144 ## @todo do more with this OVA. Like untaring it and loading it as an OVF. Export it and import it again. 161 145 162 return True ;146 return True 163 147 164 148 def testImportOvaAsOvf(self, sOva): 165 149 """ 166 Unpac ts the OVA into a subdirectory in the scratch area and imports it as an OVF.167 """ 168 oVirtualBox = self.o VBoxMgr.getVirtualBox();169 170 sTmpDir = os.path.join(self. sScratchPath, os.path.split(sOva)[1] + '-ovf');171 sOvf = os.path.join(sTmpDir, os.path.splitext(os.path.split(sOva)[1])[0] + '.ovf') ;150 Unpacks the OVA into a subdirectory in the scratch area and imports it as an OVF. 151 """ 152 oVirtualBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 153 154 sTmpDir = os.path.join(self.oTstDrv.sScratchPath, os.path.split(sOva)[1] + '-ovf') 155 sOvf = os.path.join(sTmpDir, os.path.splitext(os.path.split(sOva)[1])[0] + '.ovf') 172 156 173 157 # … … 175 159 # 176 160 try: 177 os.mkdir(sTmpDir, 0o755) ;178 oTarFile = tarfile.open(sOva, 'r:*') ;179 oTarFile.extractall(sTmpDir) ;180 oTarFile.close() ;181 except: 182 return reporter.errorXcpt('Unpacking "%s" to "%s" for OVF style importing failed' % (sOvf, sTmpDir,)) ;161 os.mkdir(sTmpDir, 0o755) 162 oTarFile = tarfile.open(sOva, 'r:*') 163 oTarFile.extractall(sTmpDir) 164 oTarFile.close() 165 except: 166 return reporter.errorXcpt('Unpacking "%s" to "%s" for OVF style importing failed' % (sOvf, sTmpDir,)) 183 167 184 168 # … … 186 170 # 187 171 try: 188 oAppliance2 = oVirtualBox.createAppliance(); 189 except: 190 return reporter.errorXcpt('IVirtualBox::createAppliance failed (#2)'); 191 print("oAppliance2=%s" % (oAppliance2,)); 192 193 try: 194 oProgress = vboxwrappers.ProgressWrapper(oAppliance2.read(sOvf), self.oVBoxMgr, self, 'read "%s"' % (sOvf,)); 195 except: 196 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOvf,)); 197 oProgress.wait(); 198 if oProgress.logResult() is False: 199 return False; 200 201 try: 202 oAppliance2.interpret(); 203 except: 204 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOvf,)); 172 oAppliance2 = oVirtualBox.createAppliance() 173 except: 174 return reporter.errorXcpt('IVirtualBox::createAppliance failed (#2)') 175 176 try: 177 oProgress = vboxwrappers.ProgressWrapper(oAppliance2.read(sOvf), self.oTstDrv.oVBoxMgr, self.oTstDrv, 'read "%s"' % (sOvf,)) 178 except: 179 return reporter.errorXcpt('IAppliance::read("%s") failed' % (sOvf,)) 180 oProgress.wait() 181 if oProgress.logResult() is False: 182 return False 183 184 try: 185 oAppliance2.interpret() 186 except: 187 return reporter.errorXcpt('IAppliance::interpret() failed on "%s"' % (sOvf,)) 205 188 206 189 try: 207 190 oProgress = vboxwrappers.ProgressWrapper(oAppliance2.importMachines([]), 208 self.o VBoxMgr, self, 'importMachines "%s"' % (sOvf,));209 except: 210 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOvf,)) ;211 oProgress.wait() ;212 if oProgress.logResult() is False: 213 return False ;214 215 return True ;191 self.oTstDrv.oVBoxMgr, self.oTstDrv, 'importMachines "%s"' % (sOvf,)) 192 except: 193 return reporter.errorXcpt('IAppliance::importMachines failed on "%s"' % (sOvf,)) 194 oProgress.wait() 195 if oProgress.logResult() is False: 196 return False 197 198 return True 216 199 217 200 if __name__ == '__main__': 218 sys.exit(tdAppliance1().main(sys.argv)); 219 201 sys.path.append(os.path.dirname(os.path.abspath(__file__))) 202 from tdApi1 import tdApi1 203 oTstDrv = tdApi1() 204 oTstDrv.addSubTestDriver(SubTstDrvAppliance1(oTstDrv)) 205 sys.exit(oTstDrv.main(sys.argv)) 206 -
trunk/src/VBox/ValidationKit/tests/api/tdMoveMedium1.py
r70811 r70812 1 1 #!/usr/bin/env python 2 2 # -*- coding: utf-8 -*- 3 # $Id : tdMoveMedium.py3 # $Id$ 4 4 5 5 """ 6 VirtualBox Validation Kit - Medium Move Test 6 VirtualBox Validation Kit - Medium Move Test #1 7 7 """ 8 8 … … 28 28 terms and conditions of either the GPL or the CDDL or both. 29 29 """ 30 __version__ = "" 30 __version__ = "$Revision$" 31 31 32 32 33 # Standard Python imports. … … 41 42 42 43 # Validation Kit imports. 43 from common import utils44 from testdriver import base 44 45 from testdriver import reporter 45 from testdriver import vbox 46 from testdriver import vboxwrappers; 46 from testdriver import vboxwrappers 47 47 48 class tdMoveMedium(vbox.TestDriver): 48 49 class SubTstDrvMoveMedium1(base.SubTestDriverBase): 49 50 """ 50 Medium moving Test.51 Sub-test driver for Medium Move Test #1. 51 52 """ 52 53 53 # Suffix exclude list.54 # List of suffixes to append. 54 55 suffixes = [ 55 56 '.vdi', 56 ] ;57 ] 57 58 58 def __init__(self): 59 vbox.TestDriver.__init__(self) 60 self.asRsrcs = None 59 def __init__(self, oTstDrv): 60 base.SubTestDriverBase.__init__(self, 'move-medium', oTstDrv) 61 61 62 # 63 # Overridden methods. 64 # 65 66 def actionConfig(self): 62 def testIt(self): 67 63 """ 68 Import the API. 69 """ 70 if not self.importVBoxApi(): 71 return False 72 return True 73 74 def actionExecute(self): 75 """ 76 Execute the testcase. 64 Execute the sub-testcase. 77 65 """ 78 66 return self.testMediumMove() … … 81 69 # Test execution helpers. 82 70 # 71 83 72 def setLocation(self, sLocation, aListOfAttach): 84 73 for attachment in aListOfAttach: 85 74 try: 86 oMedium = attachment.medium ;75 oMedium = attachment.medium 87 76 reporter.log('Move medium ' + oMedium.name + ' to the ' + sLocation) 88 77 except: 89 reporter.errorXcpt('failed to get the medium from the IMediumAttachment "%s"' % (attachment)) ;78 reporter.errorXcpt('failed to get the medium from the IMediumAttachment "%s"' % (attachment)) 90 79 91 80 try: 92 oProgress = vboxwrappers.ProgressWrapper(oMedium.setLocation(sLocation), self.o VBoxMgr, self, 'move "%s"' % (oMedium.name,));81 oProgress = vboxwrappers.ProgressWrapper(oMedium.setLocation(sLocation), self.oTstDrv.oVBoxMgr, self.oTstDrv, 'move "%s"' % (oMedium.name,)) 93 82 except: 94 return reporter.errorXcpt('Medium::setLocation("%s") for medium "%s" failed' % (sLocation, oMedium.name,)) ;83 return reporter.errorXcpt('Medium::setLocation("%s") for medium "%s" failed' % (sLocation, oMedium.name,)) 95 84 96 oProgress.wait() ;85 oProgress.wait() 97 86 if oProgress.logResult() is False: 98 return False ;87 return False 99 88 100 89 # Test with VDI image … … 113 102 114 103 try: 115 oVM = self. createTestVM('test-medium-move', 1, None, 4)104 oVM = self.oTstDrv.createTestVM('test-medium-move', 1, None, 4) 116 105 assert oVM is not None 117 106 … … 119 108 fRc = True 120 109 c = 0 121 oSession = self.o penSession(oVM)110 oSession = self.oTstDrv.openSession(oVM) 122 111 for i in self.suffixes: 123 sHddPath = os.path.join(self. sScratchPath, 'Test' + str(c) + i)112 sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'Test' + str(c) + i) 124 113 oHd = oSession.createBaseHd(sHddPath, cb=1024*1024) 125 114 if oHd is None: … … 133 122 134 123 #create temporary subdirectory in the current working directory 135 sOrigLoc = self. sScratchPath124 sOrigLoc = self.oTstDrv.sScratchPath 136 125 sNewLoc = os.path.join(sOrigLoc, 'newLocation/') 137 126 138 os.makedirs(sNewLoc, 0o775) ;127 os.makedirs(sNewLoc, 0o775) 139 128 140 129 aListOfAttach = oVM.getMediumAttachmentsOfController(sController) … … 170 159 return reporter.testDone()[1] == 0 171 160 161 172 162 if __name__ == '__main__': 173 sys.exit(tdMoveMedium().main(sys.argv)) 163 sys.path.append(os.path.dirname(os.path.abspath(__file__))) 164 from tdApi1 import tdApi1 165 oTstDrv = tdApi1() 166 oTstDrv.addSubTestDriver(SubTstDrvMoveMedium1(oTstDrv)) 167 sys.exit(oTstDrv.main(sys.argv)) 174 168 -
trunk/src/VBox/ValidationKit/tests/api/tdPython1.py
r70660 r70812 39 39 # Only the main script needs to modify the path. 40 40 try: __file__ 41 except: __file__ = sys.argv[0] ;42 g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) ;43 sys.path.append(g_ksValidationKitDir) ;41 except: __file__ = sys.argv[0] 42 g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 43 sys.path.append(g_ksValidationKitDir) 44 44 45 45 # Validation Kit imports. 46 from testdriver import reporter; 47 from testdriver import base; 48 from testdriver import vbox; 49 50 51 class tdPython1(vbox.TestDriver): 46 from testdriver import base 47 from testdriver import reporter 48 49 50 class SubTstDrvPython1(base.SubTestDriverBase): 52 51 """ 53 Python Bindings Test #1.52 Sub-test driver for Python Bindings Test #1. 54 53 """ 55 54 56 def __init__(self): 57 vbox.TestDriver.__init__(self); 58 self.asRsrcs = None; 59 60 61 # 62 # Overridden methods. 63 # 64 65 def actionConfig(self): 66 """ 67 Import the API. 68 """ 69 if not self.importVBoxApi(): 70 return False; 71 return True; 72 73 def actionExecute(self): 74 """ 75 Execute the testcase. 55 def __init__(self, oTstDrv): 56 base.SubTestDriverBase.__init__(self, 'python-binding', oTstDrv) 57 58 def testIt(self): 59 """ 60 Execute the sub-testcase. 76 61 """ 77 62 return self.testEventQueueWaiting() \ 78 and self.testEventQueueInterrupt() ;63 and self.testEventQueueInterrupt() 79 64 80 65 # … … 85 70 """ Thread procedure for checking that waitForEvents fails when not called by the main thread. """ 86 71 try: 87 rc2 = self.o VBoxMgr.waitForEvents(0);72 rc2 = self.oTstDrv.oVBoxMgr.waitForEvents(0) 88 73 except: 89 return True ;90 reporter.error('waitForEvents() returned "%s" when called on a worker thread, expected exception.' % (rc2,)) ;91 return False ;74 return True 75 reporter.error('waitForEvents() returned "%s" when called on a worker thread, expected exception.' % (rc2,)) 76 return False 92 77 93 78 def testEventQueueWaiting(self): … … 95 80 Test event queue waiting. 96 81 """ 97 reporter.testStart('waitForEvents') ;82 reporter.testStart('waitForEvents') 98 83 99 84 # Check return values and such. 100 85 for cMsTimeout in (0, 1, 2, 3, 256, 1000, 0): 101 iLoop = 0 ;86 iLoop = 0 102 87 while True: 103 88 try: 104 rc = self.o VBoxMgr.waitForEvents(cMsTimeout);89 rc = self.oTstDrv.oVBoxMgr.waitForEvents(cMsTimeout) 105 90 except: 106 reporter.errorXcpt() ;107 break ;91 reporter.errorXcpt() 92 break 108 93 if not isinstance(rc, int): 109 reporter.error('waitForEvents returns non-integer type') ;110 break ;94 reporter.error('waitForEvents returns non-integer type') 95 break 111 96 if rc == 1: 112 break ;97 break 113 98 if rc != 0: 114 reporter.error('waitForEvents returns "%s", expected 0 or 1' % (rc,)) ;115 break ;116 iLoop += 1 ;99 reporter.error('waitForEvents returns "%s", expected 0 or 1' % (rc,)) 100 break 101 iLoop += 1 117 102 if iLoop > 10240: 118 103 reporter.error('waitForEvents returns 0 (success) %u times. ' 119 104 'Expected 1 (timeout/interrupt) after a call or two.' 120 % (iLoop,)) ;121 break ;105 % (iLoop,)) 106 break 122 107 if reporter.testErrorCount() != 0: 123 break ;108 break 124 109 125 110 # Check that we get an exception when trying to call the method from 126 111 # a different thread. 127 112 reporter.log('If running a debug build, you will see an ignored assertion now. Please ignore it.') 128 sVBoxAssertSaved = os.environ.get('VBOX_ASSERT', 'breakpoint') ;129 os.environ['VBOX_ASSERT'] = 'ignore' ;130 oThread = threading.Thread(target=self.testEventQueueWaitingThreadProc) ;131 oThread.start() ;132 oThread.join() ;133 os.environ['VBOX_ASSERT'] = sVBoxAssertSaved ;134 135 return reporter.testDone()[1] == 0 ;113 sVBoxAssertSaved = os.environ.get('VBOX_ASSERT', 'breakpoint') 114 os.environ['VBOX_ASSERT'] = 'ignore' 115 oThread = threading.Thread(target=self.testEventQueueWaitingThreadProc) 116 oThread.start() 117 oThread.join() 118 os.environ['VBOX_ASSERT'] = sVBoxAssertSaved 119 120 return reporter.testDone()[1] == 0 136 121 137 122 def interruptWaitEventsThreadProc(self): 138 123 """ Thread procedure that's used for waking up the main thread. """ 139 time.sleep(2) ;124 time.sleep(2) 140 125 try: 141 rc2 = self.o VBoxMgr.interruptWaitEvents();126 rc2 = self.oTstDrv.oVBoxMgr.interruptWaitEvents() 142 127 except: 143 reporter.errorXcpt() ;128 reporter.errorXcpt() 144 129 else: 145 130 if rc2 is True: 146 return True ;147 reporter.error('interruptWaitEvents returned "%s" when called from other thread, expected True' % (rc2,)) ;148 return False ;131 return True 132 reporter.error('interruptWaitEvents returned "%s" when called from other thread, expected True' % (rc2,)) 133 return False 149 134 150 135 def testEventQueueInterrupt(self): … … 152 137 Test interrupting an event queue wait. 153 138 """ 154 reporter.testStart('interruptWait') ;139 reporter.testStart('interruptWait') 155 140 156 141 # interrupt ourselves first and check the return value. 157 142 for i in range(0, 10): 158 143 try: 159 rc = self.o VBoxMgr.interruptWaitEvents();144 rc = self.oTstDrv.oVBoxMgr.interruptWaitEvents() 160 145 except: 161 reporter.errorXcpt() ;162 break ;146 reporter.errorXcpt() 147 break 163 148 if rc is not True: 164 reporter.error('interruptWaitEvents returned "%s" expected True' % (rc,)) ;149 reporter.error('interruptWaitEvents returned "%s" expected True' % (rc,)) 165 150 break 166 151 … … 176 161 # Try quiesce the event queue. 177 162 for _ in range(1, 100): 178 self.o VBoxMgr.waitForEvents(0);163 self.oTstDrv.oVBoxMgr.waitForEvents(0) 179 164 180 165 # Create a thread that will interrupt us in 2 seconds. 181 166 try: 182 oThread = threading.Thread(target=self.interruptWaitEventsThreadProc) ;183 oThread.setDaemon(False) ;167 oThread = threading.Thread(target=self.interruptWaitEventsThreadProc) 168 oThread.setDaemon(False) 184 169 except: 185 reporter.errorXcpt() ;186 break ;187 188 cMsTimeout = 20000 ;170 reporter.errorXcpt() 171 break 172 173 cMsTimeout = 20000 189 174 if i == 2: 190 cMsTimeout = -1 ;175 cMsTimeout = -1 191 176 elif i == 3: 192 cMsTimeout = -999999 ;177 cMsTimeout = -999999 193 178 194 179 # Do the wait. 195 oThread.start() ;196 msNow = base.timestampMilli() ;180 oThread.start() 181 msNow = base.timestampMilli() 197 182 try: 198 rc = self.o VBoxMgr.waitForEvents(cMsTimeout);183 rc = self.oTstDrv.oVBoxMgr.waitForEvents(cMsTimeout) 199 184 except: 200 reporter.errorXcpt() ;185 reporter.errorXcpt() 201 186 else: 202 msElapsed = base.timestampMilli() - msNow ;187 msElapsed = base.timestampMilli() - msNow 203 188 204 189 # Check the return code and elapsed time. 205 190 if not isinstance(rc, int): 206 reporter.error('waitForEvents returns non-integer type after %u ms, expected 1' % (msElapsed,)) ;191 reporter.error('waitForEvents returns non-integer type after %u ms, expected 1' % (msElapsed,)) 207 192 elif rc != 1: 208 reporter.error('waitForEvents returned "%s" after %u ms, expected 1' % (rc, msElapsed)) ;193 reporter.error('waitForEvents returned "%s" after %u ms, expected 1' % (rc, msElapsed)) 209 194 if msElapsed > 15000: 210 reporter.error('waitForEvents after %u ms, expected just above 2-3 seconds' % (msElapsed,)) ;195 reporter.error('waitForEvents after %u ms, expected just above 2-3 seconds' % (msElapsed,)) 211 196 elif msElapsed < 100: 212 reporter.error('waitForEvents after %u ms, expected more than 100 ms.' % (msElapsed,)) ;213 214 oThread.join() ;215 oThread = None ;197 reporter.error('waitForEvents after %u ms, expected more than 100 ms.' % (msElapsed,)) 198 199 oThread.join() 200 oThread = None 216 201 if reporter.testErrorCount() != 0: 217 break ;218 reporter.log('Iteration %u was successful...' % (i + 1,)) ;219 return reporter.testDone()[1] == 0 ;202 break 203 reporter.log('Iteration %u was successful...' % (i + 1,)) 204 return reporter.testDone()[1] == 0 220 205 221 206 222 207 if __name__ == '__main__': 223 sys.exit(tdPython1().main(sys.argv)); 224 208 sys.path.append(os.path.dirname(os.path.abspath(__file__))) 209 from tdApi1 import tdApi1 210 oTstDrv = tdApi1() 211 oTstDrv.addSubTestDriver(SubTstDrvPython1(oTstDrv)) 212 sys.exit(oTstDrv.main(sys.argv)) 213 -
trunk/src/VBox/ValidationKit/tests/api/tdTreeDepth1.py
r69111 r70812 42 42 43 43 # Validation Kit imports. 44 from testdriver import base 44 45 from testdriver import reporter 45 from testdriver import vbox46 46 from testdriver import vboxcon 47 47 48 48 49 class tdTreeDepth1(vbox.TestDriver):49 class SubTstDrvTreeDepth1(base.SubTestDriverBase): 50 50 """ 51 Medium and Snapshot Tree Depth Test #1.51 Sub-test driver for Medium and Snapshot Tree Depth Test #1. 52 52 """ 53 53 54 def __init__(self): 55 vbox.TestDriver.__init__(self) 56 self.asRsrcs = None 54 def __init__(self, oTstDrv): 55 base.SubTestDriverBase.__init__(self, 'tree-depth', oTstDrv) 57 56 58 59 # 60 # Overridden methods. 61 # 62 63 def actionConfig(self): 57 def testIt(self): 64 58 """ 65 Import the API. 66 """ 67 if not self.importVBoxApi(): 68 return False 69 return True 70 71 def actionExecute(self): 72 """ 73 Execute the testcase. 59 Execute the sub-testcase. 74 60 """ 75 61 return self.testMediumTreeDepth() \ … … 87 73 88 74 try: 89 oVM = self. createTestVM('test-medium', 1, None, 4)75 oVM = self.oTstDrv.createTestVM('test-medium', 1, None, 4) 90 76 assert oVM is not None 91 77 92 78 # create chain with 300 disk images (medium tree depth limit) 93 79 fRc = True 94 oSession = self.o penSession(oVM)80 oSession = self.oTstDrv.openSession(oVM) 95 81 for i in range(1, 301): 96 sHddPath = os.path.join(self. sScratchPath, 'Test' + str(i) + '.vdi')82 sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'Test' + str(i) + '.vdi') 97 83 if i is 1: 98 84 oHd = oSession.createBaseHd(sHddPath, cb=1024*1024) … … 112 98 reporter.log('unregistering VM') 113 99 oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone) 114 oVBox = self.o VBoxMgr.getVirtualBox()100 oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 115 101 reporter.log('opening VM %s, testing config reading' % (sSettingsFile)) 116 102 oVM = oVBox.openMachine(sSettingsFile) … … 129 115 130 116 try: 131 oVM = self. createTestVM('test-snap', 1, None, 4)117 oVM = self.oTstDrv.createTestVM('test-snap', 1, None, 4) 132 118 assert oVM is not None 133 119 134 120 # modify the VM config, create and attach empty HDD 135 oSession = self.o penSession(oVM)136 sHddPath = os.path.join(self. sScratchPath, 'TestSnapEmpty.vdi')121 oSession = self.oTstDrv.openSession(oVM) 122 sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'TestSnapEmpty.vdi') 137 123 fRc = True 138 124 fRc = fRc and oSession.createAndAttachHd(sHddPath, cb=1024*1024, sController='SATA Controller', fImmutable=False) … … 148 134 reporter.log('unregistering VM') 149 135 oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone) 150 oVBox = self.o VBoxMgr.getVirtualBox()136 oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox() 151 137 reporter.log('opening VM %s, testing config reading' % (sSettingsFile)) 152 138 oVM = oVBox.openMachine(sSettingsFile) … … 160 146 161 147 if __name__ == '__main__': 162 sys.exit(tdTreeDepth1().main(sys.argv)) 148 sys.path.append(os.path.dirname(os.path.abspath(__file__))) 149 from tdApi1 import tdApi1 150 oTstDrv = tdApi1() 151 oTstDrv.addSubTestDriver(SubTstDrvTreeDepth1(oTstDrv)) 152 sys.exit(oTstDrv.main(sys.argv)) 163 153
Note:
See TracChangeset
for help on using the changeset viewer.