Changeset 87216 in vbox for trunk/src/VBox/ValidationKit/tests/autostart
- Timestamp:
- Jan 11, 2021 4:03:56 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142171
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py
r87116 r87216 27 27 """ 28 28 __version__ = "$Id$" 29 29 30 # Standard Python imports. 30 31 import os; 31 32 import sys; 32 33 import re; 34 33 35 # Only the main script needs to modify the path. 34 36 try: __file__ … … 36 38 g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))); 37 39 sys.path.append(g_ksValidationKitDir); 40 38 41 # Validation Kit imports. 39 42 from testdriver import reporter; … … 43 46 from testdriver import vboxtestvms; 44 47 from testdriver import vboxwrappers; 48 45 49 class VBoxManageStdOutWrapper(object): 46 50 """ Parser for VBoxManage list runningvms """ 51 47 52 def __init__(self): 48 53 self.sVmRunning = ''; 54 49 55 def __del__(self): 50 56 self.close(); 57 51 58 def close(self): 52 59 """file.close""" 53 60 return; 61 54 62 def read(self, cb): 55 63 """file.read""" 56 64 _ = cb; 57 65 return ""; 66 58 67 def write(self, sText): 59 68 """VBoxManage stdout write""" … … 77 86 reporter.log('Logging: ' + self.sVmRunning); 78 87 return None; 88 79 89 class tdAutostartOs(vboxtestvms.BaseTestVm): 80 90 """ … … 97 107 self.asVirtModesSup = ['hwvirt-np',]; 98 108 self.asParavirtModesSup = ['default',]; 109 99 110 @property 100 111 def asTestBuildDirs(self): 101 112 return self._asTestBuildDirs; 113 102 114 @asTestBuildDirs.setter 103 115 def asTestBuildDirs(self, value): … … 106 118 if not self.sTestBuild: 107 119 raise base.GenError("VirtualBox install package not found"); 120 108 121 def _findFile(self, sRegExp, asTestBuildDirs): 109 122 """ … … 128 141 reporter.error('Failed to find a file matching "%s" in %s.' % (sRegExp, ','.join(asTestBuildDirs))); 129 142 return None; 143 130 144 def _createAutostartCfg(self, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 131 145 """ … … 138 152 sVBoxCfg = sVBoxCfg + sUserDeny + ' = {\n allow = false\n }\n'; 139 153 return sVBoxCfg; 154 140 155 def _waitAdditionsIsRunning(self, oGuest, fWaitTrayControl): 141 156 """ … … 160 175 cAttempt += 1; 161 176 return fRc; 177 162 178 def createSession(self, oSession, sName, sUser, sPassword, cMsTimeout = 10 * 1000, fIsError = True): 163 179 """ … … 195 211 return (False, None); 196 212 return (True, oGuestSession); 213 197 214 def closeSession(self, oGuestSession, fIsError = True): 198 215 """ … … 213 230 return False; 214 231 return True; 232 215 233 def guestProcessExecute(self, oGuestSession, sTestName, cMsTimeout, sExecName, asArgs = (), 216 234 fGetStdOut = True, fIsError = True): … … 342 360 reporter.log2('Process (PID %d) has exit code: %d; status: %d ' % (iPid, iExitCode, uExitStatus)); 343 361 return (fRc, uExitStatus, iExitCode, aBuf); 362 344 363 def uploadString(self, oGuestSession, sSrcString, sDst): 345 364 """ … … 362 381 fRc = reporter.errorXcpt('Upload string failed. Could not close the file %s' % sDst); 363 382 return fRc; 383 364 384 def uploadFile(self, oGuestSession, sSrc, sDst): 365 385 """ … … 386 406 fRc = reporter.error('No progress object returned'); 387 407 return fRc; 408 388 409 def downloadFile(self, oGuestSession, sSrc, sDst, fIgnoreErrors = False): 389 410 """ … … 417 438 fRc = False; 418 439 return fRc; 440 419 441 def downloadFiles(self, oGuestSession, asFiles, fIgnoreErrors = False): 420 442 """ … … 445 467 reporter.log('warning: file "%s" was not downloaded, ignoring.' % (sGstFile,)); 446 468 return True; 469 447 470 def _checkVmIsReady(self, oGuestSession): 448 471 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process', … … 451 474 False, False); 452 475 return fRc; 476 453 477 def waitVmIsReady(self, oSession, fWaitTrayControl): 454 478 """ … … 477 501 cAttempt += 1; 478 502 return (fRc, oGuestSession); 503 479 504 def _rebootVM(self, oGuestSession): 480 505 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM', … … 485 510 reporter.error('Calling the reboot utility failed'); 486 511 return fRc; 512 487 513 def rebootVMAndCheckReady(self, oSession, oGuestSession): 488 514 """ … … 499 525 reporter.testDone(); 500 526 return (fRc, oGuestSession); 527 501 528 def _powerDownVM(self, oGuestSession): 502 529 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM', … … 507 534 reporter.error('Calling the poweroff utility failed'); 508 535 return fRc; 536 509 537 def powerDownVM(self, oGuestSession): 510 538 """ … … 522 550 reporter.testDone(); 523 551 return fRc; 552 524 553 def installAdditions(self, oSession, oGuestSession, oVM): 525 554 """ … … 531 560 reporter.error('Not implemented'); 532 561 return False; 562 533 563 def installVirtualBox(self, oGuestSession): 534 564 """ … … 538 568 reporter.error('Not implemented'); 539 569 return False; 570 540 571 def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 541 572 """ … … 548 579 reporter.error('Not implemented'); 549 580 return False; 581 550 582 def createUser(self, oGuestSession, sUser): 551 583 """ … … 556 588 reporter.error('Not implemented'); 557 589 return False; 590 558 591 def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName): 559 592 """ … … 568 601 reporter.error('Not implemented'); 569 602 return False; 603 570 604 def getResourceSet(self): 571 605 asRet = []; … … 573 607 asRet.append(self.sHdd); 574 608 return asRet; 609 575 610 def _createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage): 576 611 """ … … 585 620 sHddControllerType = "SATA Controller", fPae = self.fPae, \ 586 621 cCpus = self.cCpus, sDvdImage = self.sGuestAdditionsIso); 622 587 623 def _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage): 588 624 _ = eNic0AttachType; … … 606 642 fRc = False; 607 643 return oVM if fRc else None; 644 608 645 def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None): 609 646 # … … 617 654 return (False, None); 618 655 return (True, oVM); 656 619 657 class tdAutostartOsLinux(tdAutostartOs): 620 658 """ … … 628 666 self.sVBoxInstaller = '^VirtualBox-.*\\.run$'; 629 667 return; 668 630 669 def installAdditions(self, oSession, oGuestSession, oVM): 631 670 """ … … 703 742 reporter.testDone(); 704 743 return (fRc, oGuestSession); 744 705 745 def installVirtualBox(self, oGuestSession): 706 746 """ … … 734 774 reporter.testDone(); 735 775 return fRc; 776 736 777 def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 737 778 """ … … 792 833 reporter.testDone(); 793 834 return fRc; 835 794 836 def createUser(self, oGuestSession, sUser): 795 837 """ … … 805 847 reporter.testDone(); 806 848 return fRc; 849 807 850 # pylint: enable=too-many-arguments 808 851 def createTestVM(self, oSession, oGuestSession, sUser, sVmName): … … 839 882 reporter.testDone(); 840 883 return fRc; 884 841 885 def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName): 842 886 """ … … 861 905 reporter.testDone(); 862 906 return fRc; 907 863 908 class tdAutostartOsDarwin(tdAutostartOs): 864 909 """ … … 871 916 cCpus, fPae, sGuestAdditionsIso); 872 917 raise base.GenError('Testing the autostart functionality for Darwin is not implemented'); 918 873 919 class tdAutostartOsSolaris(tdAutostartOs): 874 920 """ … … 881 927 cCpus, fPae, sGuestAdditionsIso); 882 928 raise base.GenError('Testing the autostart functionality for Solaris is not implemented'); 929 883 930 class tdAutostartOsWin(tdAutostartOs): 884 931 """ … … 892 939 self.sVBoxInstaller = '^VirtualBox-.*\\.(exe|msi)$'; 893 940 return; 941 894 942 def _checkVmIsReady(self, oGuestSession): 895 943 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Start a guest process', … … 898 946 False, False); 899 947 return fRc; 948 900 949 def _rebootVM(self, oGuestSession): 901 950 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Reboot the VM', … … 907 956 reporter.error('Calling the shutdown utility failed'); 908 957 return fRc; 958 909 959 def _powerDownVM(self, oGuestSession): 910 960 (fRc, _, _, _) = self.guestProcessExecute(oGuestSession, 'Power down the VM', … … 916 966 reporter.error('Calling the shutdown utility failed'); 917 967 return fRc; 968 918 969 def installAdditions(self, oSession, oGuestSession, oVM): 919 970 """ … … 1005 1056 reporter.testDone(); 1006 1057 return (fRc and fGaRc, oGuestSession); 1058 1007 1059 def installVirtualBox(self, oGuestSession): 1008 1060 """ … … 1051 1103 reporter.testDone(); 1052 1104 return fRc; 1105 1053 1106 def configureAutostart(self, oGuestSession, sDefaultPolicy = 'allow', asUserAllow = (), asUserDeny = ()): 1054 1107 """ … … 1074 1127 reporter.testDone(); 1075 1128 return fRc; 1129 1076 1130 def createTestVM(self, oSession, oGuestSession, sUser, sVmName): 1077 1131 """ … … 1120 1174 reporter.testDone(); 1121 1175 return fRc; 1176 1122 1177 def checkForRunningVM(self, oSession, oGuestSession, sUser, sVmName): 1123 1178 """ … … 1148 1203 reporter.testDone(); 1149 1204 return fRc; 1205 1150 1206 def createUser(self, oGuestSession, sUser): 1151 1207 """ … … 1219 1275 reporter.testDone(); 1220 1276 return fRc; 1277 1221 1278 class tdAutostart(vbox.TestDriver): # pylint: disable=too-many-instance-attributes 1222 1279 """ … … 1250 1307 # pylint: enable=line-too-long 1251 1308 self.oTestVmSet = oSet; 1309 1252 1310 # 1253 1311 # Overridden methods. 1254 1312 # 1313 1255 1314 def showUsage(self): 1256 1315 rc = vbox.TestDriver.showUsage(self); … … 1262 1321 reporter.log(' option is not specified. At least, one directory should be pointed.'); 1263 1322 return rc; 1323 1264 1324 def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements 1265 1325 if asArgs[iArg] == '--test-build-dirs': … … 1272 1332 return vbox.TestDriver.parseOption(self, asArgs, iArg); 1273 1333 return iArg + 1; 1334 1274 1335 def completeOptions(self): 1275 1336 # Remove skipped VMs from the test list. … … 1280 1341 except: pass; 1281 1342 return vbox.TestDriver.completeOptions(self); 1343 1282 1344 def actionConfig(self): 1283 1345 if not self.importVBoxApi(): # So we can use the constant below. 1284 1346 return False; 1285 1347 return self.oTestVmSet.actionConfig(self); 1348 1286 1349 def actionExecute(self): 1287 1350 """ … … 1289 1352 """ 1290 1353 return self.oTestVmSet.actionExecute(self, self.testAutostartOneVfg) 1354 1291 1355 # 1292 1356 # Test execution helpers. … … 1352 1416 fRc = False; 1353 1417 return fRc; 1418 1354 1419 if __name__ == '__main__': 1355 1420 sys.exit(tdAutostart().main(sys.argv));
Note:
See TracChangeset
for help on using the changeset viewer.