Changeset 98564 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Feb 14, 2023 3:10:54 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/unittests/tdUnitTest1.py
r98563 r98564 374 374 # "remote-copy": Copies unit tests from host to the remote, then executing it. 375 375 # "remote-exec": Executes unit tests right on the remote from a given source. 376 ## @todo r=bird: 'remote-exec' and 'remote-copy' are confusing. We're presumably executing the test remotely in both 377 ## cases, the different being that in the latter case we copy from the valkit iso rather than uploading the test files. 378 ## That's hardly clear from the names or the explanation. 376 379 self.sMode = 'local'; 377 380 … … 384 387 # also acts the source for copying over the testcases to a remote target. 385 388 self.sUnitTestsPathSrc = None; 386 387 ## Remote environment changes.388 self.dRemoteEnvChg = {};389 389 390 390 # The destination directory our unit tests live when being … … 536 536 reporter.log(' Specifies the test execution mode:'); 537 537 reporter.log(' local: Locally on the same machine.'); 538 reporter.log(' remote-copy: On remote (guest) by copying them from the local source. ');538 reporter.log(' remote-copy: On remote (guest) by copying them from the local source. (BORKED!)'); 539 539 reporter.log(' remote-exec: On remote (guest) directly (needs unit test source).'); 540 540 reporter.log(' --only-whitelist'); … … 965 965 return fRc; 966 966 967 def _envSet(self, sName, sValue):968 if self.isRemoteMode():969 self.dRemoteEnvChg[sName] = sValue;970 else:971 os.environ[sName] = sValue;972 return True;973 974 967 def _executeTestCase(self, oTestVm, sName, sFilePathAbs, sTestCaseSubDir, oDevNull): # pylint: disable=too-many-locals,too-many-statements 975 968 """ … … 984 977 985 978 # 986 # If hardening is enabled, some test cases and their dependencies 987 # needs to be copied to and execute from the source 988 # directory in order to work. They also have to be executed as 989 # root, i.e. via sudo. 990 # 979 # If hardening is enabled, some test cases and their dependencies needs 980 # to be copied to and execute from the source directory in order to 981 # work. They also have to be executed as root, i.e. via sudo. 982 # 983 # When executing test remotely we must also copy stuff over to the 984 # remote location. Currently there is no diferent between remote-copy 985 # and remote-exec here, which it would be nice if Andy could explain... 986 # 987 ## @todo r=bird: Please explain + fix ^^. 991 988 fHardened = sName in self.kasHardened and self.sUnitTestsPathSrc != self.sVBoxInstallRoot; 992 fCopyToRemote = self.isRemoteMode();993 fCopyDeps = self.isRemoteMode();994 989 asFilesToRemove = []; # Stuff to clean up. 995 990 asDirsToRemove = []; # Ditto. 996 991 997 if fHardened or fCopyToRemote:998 if fCopyToRemote:992 if fHardened or self.isRemoteMode(): 993 if self.isRemoteMode(): 999 994 sDstDir = os.path.join(self.sUnitTestsPathDst, sTestCaseSubDir); 1000 995 else: … … 1007 1002 # If the testcase source does not exist for whatever reason, just mark it as skipped 1008 1003 # instead of reporting an error. 1009 if not self._wrapPathExists(sSrc): 1010 self.cSkipped += 1; 1011 fSkipped = True; 1012 return fSkipped; 1004 if not self._wrapPathExists(sSrc): ## @todo r=bird: This doesn't add up for me with the two remote modes. 1005 self.cSkipped += 1; ## It seems to presuppose that we're in remote-exec mode as _wrapPathExists 1006 fSkipped = True; ## does not differentiate between the two remote modes and will always check 1007 return fSkipped; ## the path on the remote side. 1013 1008 1014 1009 sDst = os.path.join(sDstDir, os.path.basename(sFilePathAbs)); … … 1022 1017 1023 1018 # Copy required dependencies to destination. 1024 if fCopyDeps:1019 if self.isRemoteMode(): 1025 1020 for sLib in self.kdTestCaseDepsLibs: 1026 1021 for sSuff in [ '.dll', '.so', '.dylib' ]: … … 1053 1048 1054 1049 # 1055 # Set up arguments and environment.1050 # Set up arguments. 1056 1051 # 1057 1052 asArgs = [sFilePathAbs,] … … 1059 1054 asArgs.extend(self.kdArguments[sName]); 1060 1055 1061 sXmlFile = os.path.join(self.sUnitTestsPathDst, 'result.xml'); 1062 1063 self._envSet('IPRT_TEST_OMIT_TOP_TEST', '1'); 1064 self._envSet('IPRT_TEST_FILE', sXmlFile); ## @todo skip for remote. Makes _no_ sense. 1065 1066 if self._wrapPathExists(sXmlFile): 1067 try: os.unlink(sXmlFile); 1068 except: self._wrapDeleteFile(sXmlFile); 1056 # 1057 # Set up the environment. 1058 # 1059 # - We set IPRT_TEST_OMIT_TOP_TEST to avoid the unnecessary top-test 1060 # entry when running the inner tests, as it'll just add an unnecessary 1061 # result nesting. 1062 # 1063 # - IPRT_TEST_FILE is set to a result.xml file when running locally. 1064 # This is not necessary when executing via TxS as it sets IPRT_TEST_PIPE, 1065 # which overrides IPRT_TEST_FILE, to collect the XML output. 1066 # 1067 dEnvChanges = { 1068 'IPRT_TEST_OMIT_TOP_TEST': '1', 1069 }; 1070 1071 sXmlFile = os.path.join(self.sUnitTestsPathDst, 'result.xml') if not self.isRemoteMode() else None; 1072 if sXmlFile: 1073 dEnvChanges['IPRT_TEST_FILE'] = sXmlFile; 1074 if self._wrapPathExists(sXmlFile): 1075 try: os.unlink(sXmlFile); 1076 except: self._wrapDeleteFile(sXmlFile); 1069 1077 1070 1078 # … … 1085 1093 1086 1094 if not self.fDryRun: 1087 if fCopyToRemote: 1088 asRemoteEnvChg = ['%s=%s' % (sKey, self.dRemoteEnvChg[sKey]) for sKey in self.dRemoteEnvChg]; 1095 if self.isRemoteMode(): 1096 asRemoteEnvChg = ['%s=%s' % (sKey, dEnvChanges[sKey]) for sKey in dEnvChanges]; 1097 1089 1098 fRc = self.txsRunTest(self.oTxsSession, sName, cMsTimeout = 30 * 60 * 1000, sExecName = asArgs[0], 1090 1099 asArgs = asArgs, asAddEnv = asRemoteEnvChg, fCheckSessionStatus = True); … … 1100 1109 iRc = -1; ## @todo 1101 1110 else: 1111 for sKey in dEnvChanges: 1112 os.environ[sKey] = dEnvChanges[sKey]; 1113 1102 1114 oChild = None; 1103 1115 try: … … 1129 1141 1130 1142 # 1131 # Report .1132 # 1133 if os.path.exists(sXmlFile):1143 # Report (sXmlFile is None when in remote mode). 1144 # 1145 if sXmlFile and os.path.exists(sXmlFile): 1134 1146 reporter.addSubXmlFile(sXmlFile); 1135 1147 if fHardened:
Note:
See TracChangeset
for help on using the changeset viewer.