Changeset 97487 in vbox for trunk/src/VBox/ValidationKit/tests/unittests
- Timestamp:
- Nov 9, 2022 8:39:53 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/unittests/tdUnitTest1.py
r97291 r97487 368 368 self.sVBoxInstallRoot = None; 369 369 370 # Testing mode being used:370 ## Testing mode being used: 371 371 # "local": Execute unit tests locally (same host, default). 372 372 # "remote-copy": Copies unit tests from host to the remote, then executing it. 373 373 # "remote-exec": Executes unit tests right on the remote from a given source. 374 self.sMode = 'local';374 self.sMode = 'local'; 375 375 376 376 self.cSkipped = 0; … … 428 428 # Do some sanity checking first. 429 429 # 430 if self.sMode == 'remote-exec' \ 431 and not self.sUnitTestsPathSrc: # There is no way we can figure this out automatically. 430 if self.sMode == 'remote-exec' and not self.sUnitTestsPathSrc: # There is no way we can figure this out automatically. 432 431 reporter.error('Unit tests source must be specified explicitly for selected mode!'); 433 432 return False; … … 549 548 if iArg >= len(asArgs): 550 549 raise base.InvalidOption('Option "%s" needs a value' % (asArgs[iArg - 1])); 551 if asArgs[iArg] == 'local' \ 552 or asArgs[iArg] == 'remote-copy' \ 553 or asArgs[iArg] == 'remote-exec': 550 if asArgs[iArg] in ('local', 'remote-copy', 'remote-exec',): 554 551 self.sMode = asArgs[iArg]; 555 552 else: … … 588 585 589 586 # Do the configuring. 590 if self. sMode.startswith('remote'):587 if self.isRemoteMode(): 591 588 if self.sNicAttachment == 'nat': eNic0AttachType = vboxcon.NetworkAttachmentType_NAT; 592 589 elif self.sNicAttachment == 'bridged': eNic0AttachType = vboxcon.NetworkAttachmentType_Bridged; … … 601 598 # 602 599 ## @todo Get rid of this as soon as we create test VMs in a descriptive (automated) manner. 603 return self.oTestVmSet.actionConfig(self, eNic0AttachType = eNic0AttachType, \600 return self.oTestVmSet.actionConfig(self, eNic0AttachType = eNic0AttachType, 604 601 sDvdImage = self.sVBoxValidationKitIso); 605 602 … … 619 616 reporter.log2('Unit test destination path is "%s"\n' % self.sUnitTestsPathDst); 620 617 621 if self. sMode.startswith('remote'): # Run on a test VM (guest).618 if self.isRemoteMode(): # Run on a test VM (guest). 622 619 if self.fpApiVer < 7.0: ## @todo Needs Validation Kit .ISO tweaking (including the unit tests) first. 623 620 reporter.log('Remote unit tests for non-trunk builds skipped.'); … … 634 631 635 632 # 633 # Misc. 634 # 635 def isRemoteMode(self): 636 """ Predicate method for checking if in any remote mode. """ 637 return self.sMode.startswith('remote'); 638 639 # 636 640 # Test execution helpers. 637 641 # … … 643 647 644 648 # Determine executable suffix based on selected execution mode. 645 if self. sMode.startswith('remote'): # Run on a test VM (guest).649 if self.isRemoteMode(): # Run on a test VM (guest). 646 650 if oTestVm.isWindows(): 647 651 self.sExeSuff = '.exe'; … … 662 666 reporter.log('*********************************************************'); 663 667 reporter.log('*********************************************************'); 664 reporter.log(' Target: %s' % (oTestVm.sVmName if oTestVm else 'local' ));665 reporter.log(' Mode: %s' % (self.sMode ));666 reporter.log('Unit tests source: %s %s' % (self.sUnitTestsPathSrc, \667 '(on remote)' if self.sMode == 'remote-exec' else ''));668 reporter.log('VBox install root: %s %s' % (self.sVBoxInstallRoot, \669 '(on remote)' if self.sMode == 'remote-exec' else ''));668 reporter.log(' Target: %s' % (oTestVm.sVmName if oTestVm else 'local',)); 669 reporter.log(' Mode: %s' % (self.sMode,)); 670 reporter.log('Unit tests source: %s %s' 671 % (self.sUnitTestsPathSrc, '(on remote)' if self.sMode == 'remote-exec' else '',)); 672 reporter.log('VBox install root: %s %s' 673 % (self.sVBoxInstallRoot, '(on remote)' if self.sMode == 'remote-exec' else '',)); 670 674 reporter.log('*********************************************************'); 671 reporter.log('*** PASSED: %d' % self.cPassed);672 reporter.log('*** FAILED: %d' % self.cFailed);673 reporter.log('*** SKIPPED: %d' % self.cSkipped);674 reporter.log('*** TOTAL: %d' % (self.cPassed + self.cFailed + self.cSkipped ));675 reporter.log('*** PASSED: %d' % (self.cPassed,)); 676 reporter.log('*** FAILED: %d' % (self.cFailed,)); 677 reporter.log('*** SKIPPED: %d' % (self.cSkipped,)); 678 reporter.log('*** TOTAL: %d' % (self.cPassed + self.cFailed + self.cSkipped,)); 675 679 676 680 return fRc; … … 687 691 if not self.fDryRun: 688 692 # Try waiting for a bit longer (5 minutes) until the CD is available to avoid running into timeouts. 689 self.oSession, self.oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, \690 fCdWait = not self.fDryRun, \693 self.oSession, self.oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, 694 fCdWait = not self.fDryRun, 691 695 cMsCdWait = 5 * 60 * 1000); 692 696 if self.oSession is None: … … 801 805 """ 802 806 reporter.log2('Executing [sudo]: %s' % (asArgs, )); 803 if self. sMode.startswith('remote'):807 if self.isRemoteMode(): 804 808 iRc = -1; ## @todo Not used remotely yet. 805 809 else: … … 820 824 No-op if no TxS involved. 821 825 """ 822 if reporter.getVerbosity() < cVerbosity \ 823 or self.oTxsSession is None: 826 if reporter.getVerbosity() < cVerbosity or self.oTxsSession is None: 824 827 return; 825 828 sStringExp = self.oTxsSession.syncExpandString(sString); … … 836 839 return True; 837 840 fRc = False; 838 if self. sMode.startswith('remote'):841 if self.isRemoteMode(): 839 842 self._logExpandString(sPath); 840 843 fRc = self.oTxsSession.syncIsDir(sPath, fIgnoreErrors = True); … … 853 856 return True; 854 857 fRc = True; 855 if self. sMode.startswith('remote'):858 if self.isRemoteMode(): 856 859 fRc = self.oTxsSession.syncMkDirPath(sPath, fMode = 0o755); 857 860 else: … … 872 875 return True; 873 876 fRc = True; 874 if self. sMode.startswith('remote'):877 if self.isRemoteMode(): 875 878 self._logExpandString(sSrc); 876 879 self._logExpandString(sDst); … … 903 906 return True; 904 907 fRc = True; 905 if self. sMode.startswith('remote'):908 if self.isRemoteMode(): 906 909 if self.oTxsSession.syncIsFile(sPath): 907 910 fRc = self.oTxsSession.syncRmFile(sPath, fIgnoreErrors = True); … … 924 927 return True; 925 928 fRc = True; 926 if self. sMode.startswith('remote'):929 if self.isRemoteMode(): 927 930 if self.oTxsSession.syncIsDir(sPath): 928 931 fRc = self.oTxsSession.syncRmDir(sPath, fIgnoreErrors = True); … … 938 941 939 942 def _envSet(self, sName, sValue): 940 if self. sMode.startswith('remote'):943 if self.isRemoteMode(): 941 944 # For remote execution we cache the environment block and pass it 942 945 # right when the process execution happens. … … 959 962 # root, i.e. via sudo. 960 963 # 961 fHardened = False;962 fCopyToRemote = False;963 fCopyDeps = False;964 fHardened = sName in self.kasHardened and self.sUnitTestsPathSrc != self.sVBoxInstallRoot; 965 fCopyToRemote = self.isRemoteMode(); 966 fCopyDeps = self.isRemoteMode(); 964 967 asFilesToRemove = []; # Stuff to clean up. 965 968 asDirsToRemove = []; # Ditto. 966 969 967 if sName in self.kasHardened \ 968 and self.sUnitTestsPathSrc != self.sVBoxInstallRoot: 969 fHardened = True; 970 971 if self.sMode.startswith('remote'): 972 fCopyToRemote = True; 973 fCopyDeps = True; 974 975 if fHardened \ 976 or fCopyToRemote: 970 if fHardened or fCopyToRemote: 977 971 if fCopyToRemote: 978 972 sDstDir = os.path.join(self.sUnitTestsPathDst, sTestCaseSubDir); … … 994 988 fModeExe = 0; 995 989 fModeDeps = 0; 996 if not oTestVm \ 997 or (oTestVm and not oTestVm.isWindows()): ## @todo NT4 does not like the chmod. Investigate this! 990 if not oTestVm or (oTestVm and not oTestVm.isWindows()): ## @todo NT4 does not like the chmod. Investigate this! 998 991 fModeExe = 0o755; 999 992 fModeDeps = 0o644; … … 1066 1059 if not self.fDryRun: 1067 1060 if fCopyToRemote: 1068 fRc = self.txsRunTest(self.oTxsSession, sName, cMsTimeout = 30 * 60 * 1000, sExecName = asArgs[0], \1061 fRc = self.txsRunTest(self.oTxsSession, sName, cMsTimeout = 30 * 60 * 1000, sExecName = asArgs[0], 1069 1062 asArgs = asArgs, asAddEnv = self.asEnv, fCheckSessionStatus = True); 1070 1063 if fRc: … … 1168 1161 # 1169 1162 if not self.fOnlyWhiteList: 1170 if self.sMode == 'local' \ 1171 or self.sMode == 'remote-copy': 1163 if self.sMode in ('local', 'remote-copy'): 1172 1164 asFiles = sorted(os.listdir(os.path.join(self.sUnitTestsPathSrc, sTestCaseSubDir))); 1173 1165 else: # 'remote-exec' … … 1190 1182 sName = sTestCaseSubDir + '/' + sName; 1191 1183 1192 reporter.log2('sTestCasePattern=%s, sBaseName=%s, sName=%s, sSuffix=%s, sFileName=%s' \1184 reporter.log2('sTestCasePattern=%s, sBaseName=%s, sName=%s, sSuffix=%s, sFileName=%s' 1193 1185 % (sTestCasePattern, sBaseName, sName, sSuffix, sFilename,)); 1194 1186 1195 1187 # Process white list first, if set. 1196 if self.fOnlyWhiteList \ 1197 and not self._isExcluded(sName, self.kdTestCasesWhiteList): 1188 if self.fOnlyWhiteList and not self._isExcluded(sName, self.kdTestCasesWhiteList): 1198 1189 # (No testStart/Done or accounting here!) 1199 1190 reporter.log('%s: SKIPPED (not in white list)' % (sName,)); … … 1201 1192 1202 1193 # Basic exclusion. 1203 if not re.match(sTestCasePattern, sBaseName) \ 1204 or sSuffix in self.kasSuffixBlackList: 1194 if not re.match(sTestCasePattern, sBaseName) or sSuffix in self.kasSuffixBlackList: 1205 1195 reporter.log2('"%s" is not a test case.' % (sName,)); 1206 1196 continue;
Note:
See TracChangeset
for help on using the changeset viewer.