VirtualBox

Changeset 98564 in vbox for trunk/src/VBox/ValidationKit


Ignore:
Timestamp:
Feb 14, 2023 3:10:54 PM (2 years ago)
Author:
vboxsync
Message:

ValKit/tdUnitTest1.py: More cleanups and some attempts at making sense of the code in regard to remote-exec and remote-copy. Seems remote-copy isn't working and probably should just be removed. Replaced the _envSet stuff with a local dictionary which is then converted/applied according to the execution method. bugref:10195

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/unittests/tdUnitTest1.py

    r98563 r98564  
    374374        #   "remote-copy": Copies unit tests from host to the remote, then executing it.
    375375        #   "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.
    376379        self.sMode      = 'local';
    377380
     
    384387        # also acts the source for copying over the testcases to a remote target.
    385388        self.sUnitTestsPathSrc = None;
    386 
    387         ## Remote environment changes.
    388         self.dRemoteEnvChg = {};
    389389
    390390        # The destination directory our unit tests live when being
     
    536536        reporter.log('      Specifies the test execution mode:');
    537537        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!)');
    539539        reporter.log('      remote-exec: On remote (guest) directly (needs unit test source).');
    540540        reporter.log('  --only-whitelist');
     
    965965        return fRc;
    966966
    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 
    974967    def _executeTestCase(self, oTestVm, sName, sFilePathAbs, sTestCaseSubDir, oDevNull): # pylint: disable=too-many-locals,too-many-statements
    975968        """
     
    984977
    985978        #
    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 ^^.
    991988        fHardened       = sName in self.kasHardened and self.sUnitTestsPathSrc != self.sVBoxInstallRoot;
    992         fCopyToRemote   = self.isRemoteMode();
    993         fCopyDeps       = self.isRemoteMode();
    994989        asFilesToRemove = []; # Stuff to clean up.
    995990        asDirsToRemove  = []; # Ditto.
    996991
    997         if fHardened or fCopyToRemote:
    998             if fCopyToRemote:
     992        if fHardened or self.isRemoteMode():
     993            if self.isRemoteMode():
    999994                sDstDir = os.path.join(self.sUnitTestsPathDst, sTestCaseSubDir);
    1000995            else:
     
    10071002            # If the testcase source does not exist for whatever reason, just mark it as skipped
    10081003            # 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.
    10131008
    10141009            sDst = os.path.join(sDstDir, os.path.basename(sFilePathAbs));
     
    10221017
    10231018            # Copy required dependencies to destination.
    1024             if fCopyDeps:
     1019            if self.isRemoteMode():
    10251020                for sLib in self.kdTestCaseDepsLibs:
    10261021                    for sSuff in [ '.dll', '.so', '.dylib' ]:
     
    10531048
    10541049        #
    1055         # Set up arguments and environment.
     1050        # Set up arguments.
    10561051        #
    10571052        asArgs = [sFilePathAbs,]
     
    10591054            asArgs.extend(self.kdArguments[sName]);
    10601055
    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);
    10691077
    10701078        #
     
    10851093
    10861094        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
    10891098                fRc = self.txsRunTest(self.oTxsSession, sName, cMsTimeout = 30 * 60 * 1000, sExecName = asArgs[0],
    10901099                                      asArgs = asArgs, asAddEnv = asRemoteEnvChg, fCheckSessionStatus = True);
     
    11001109                        iRc = -1; ## @todo
    11011110            else:
     1111                for sKey in dEnvChanges:
     1112                    os.environ[sKey] = dEnvChanges[sKey];
     1113
    11021114                oChild = None;
    11031115                try:
     
    11291141
    11301142        #
    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):
    11341146            reporter.addSubXmlFile(sXmlFile);
    11351147            if fHardened:
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