Пример #1
0
    def testRunUnitTestsSet(self, sTestCasePattern, sTestCaseSubDir):
        """
        Run subset of the unit tests set.
        """

        # Open /dev/null for use as stdin further down.
        try:
            oDevNull = open(os.path.devnull, 'w+');
        except:
            oDevNull = None;

        # Determin the host OS specific exclusion lists.
        dTestCasesBuggyForHostOs = self.kdTestCasesBuggyPerOs.get(utils.getHostOs(), []);
        dTestCasesBuggyForHostOs.update(self.kdTestCasesBuggyPerOs.get(utils.getHostOsDotArch(), []));

        #
        # Process the file list and run everything looking like a testcase.
        #
        for sFilename in sorted(os.listdir(os.path.join(self.sUnitTestsPathBase, sTestCaseSubDir))):
            # Separate base and suffix and morph the base into something we
            # can use for reporting and array lookups.
            sName, sSuffix = os.path.splitext(sFilename);
            if sTestCaseSubDir != '.':
                sName = sTestCaseSubDir + '/' + sName;

            # Basic exclusion.
            if   not re.match(sTestCasePattern, sFilename) \
              or sSuffix in self.kasSuffixBlackList:
                reporter.log('"%s" is not a test case.' % (sFilename,))
                continue

            # Check if the testcase is black listed or buggy before executing it.
            if self._isExcluded(sName, self.kdTestCasesBlackList):
                # (No testStart/Done or accounting here!)
                reporter.log('%s: SKIPPED (blacklisted)' % (sName,));

            elif self._isExcluded(sName, self.kdTestCasesBuggy):
                reporter.testStart(sName);
                reporter.log('%s: Skipping, buggy in general.' % (sName,));
                reporter.testDone(fSkipped = True);
                self.cSkipped += 1;

            elif self._isExcluded(sName, dTestCasesBuggyForHostOs):
                reporter.testStart(sName);
                reporter.log('%s: Skipping, buggy on %s.' % (sName, utils.getHostOs(),));
                reporter.testDone(fSkipped = True);
                self.cSkipped += 1;

            else:
                sFullPath = os.path.normpath(os.path.join(self.sUnitTestsPathBase, os.path.join(sTestCaseSubDir, sFilename)));
                reporter.testStart(sName);
                try:
                    fSkipped = self._executeTestCase(sName, sFullPath, sTestCaseSubDir, oDevNull);
                except:
                    reporter.errorXcpt('!*!');
                    self.cFailed += 1;
                    fSkipped = False;
                reporter.testDone(fSkipped);
Пример #2
0
    def testRunUnitTestsSet(self, sTestCasePattern, sTestCaseSubDir):
        """
        Run subset of the unit tests set.
        """

        # Open /dev/null for use as stdin further down.
        try:
            oDevNull = open(os.path.devnull, 'w+');
        except:
            oDevNull = None;

        # Determin the host OS specific exclusion lists.
        dTestCasesBuggyForHostOs = self.kdTestCasesBuggyPerOs.get(utils.getHostOs(), []);
        dTestCasesBuggyForHostOs.update(self.kdTestCasesBuggyPerOs.get(utils.getHostOsDotArch(), []));

        #
        # Process the file list and run everything looking like a testcase.
        #
        for sFilename in sorted(os.listdir(os.path.join(self.sUnitTestsPathBase, sTestCaseSubDir))):
            # Separate base and suffix and morph the base into something we
            # can use for reporting and array lookups.
            sName, sSuffix = os.path.splitext(sFilename);
            if sTestCaseSubDir != '.':
                sName = sTestCaseSubDir + '/' + sName;

            # Basic exclusion.
            if   not re.match(sTestCasePattern, sFilename) \
              or sSuffix in self.kasSuffixBlackList:
                reporter.log('"%s" is not a test case.' % (sFilename,))
                continue

            # Check if the testcase is black listed or buggy before executing it.
            if self._isExcluded(sName, self.kdTestCasesBlackList):
                # (No testStart/Done or accounting here!)
                reporter.log('%s: SKIPPED (blacklisted)' % (sName,));

            elif self._isExcluded(sName, self.kdTestCasesBuggy):
                reporter.testStart(sName);
                reporter.log('%s: Skipping, buggy in general.' % (sName,));
                reporter.testDone(fSkipped = True);
                self.cSkipped += 1;

            elif self._isExcluded(sName, dTestCasesBuggyForHostOs):
                reporter.testStart(sName);
                reporter.log('%s: Skipping, buggy on %s.' % (sName, utils.getHostOs(),));
                reporter.testDone(fSkipped = True);
                self.cSkipped += 1;

            else:
                sFullPath = os.path.normpath(os.path.join(self.sUnitTestsPathBase, os.path.join(sTestCaseSubDir, sFilename)));
                reporter.testStart(sName);
                try:
                    fSkipped = self._executeTestCase(sName, sFullPath, sTestCaseSubDir, oDevNull);
                except:
                    reporter.errorXcpt('!*!');
                    self.cFailed += 1;
                    fSkipped = False;
                reporter.testDone(fSkipped);
    def _getHelperOutput(self, sCmd):
        """
        Invokes TestBoxHelper to obtain information hard to access from python.
        """
        if self._sTestBoxHelper is None:
            if not utils.isRunningFromCheckout():
                # See VBoxTestBoxScript.zip for layout.
                self._sTestBoxHelper = os.path.join(g_ksValidationKitDir, utils.getHostOs(), utils.getHostArch(), \
                                                    'TestBoxHelper');
            else: # Only for in-tree testing, so don't bother be too accurate right now.
                sType = os.environ.get('KBUILD_TYPE', os.environ.get('BUILD_TYPE', 'debug'));
                self._sTestBoxHelper = os.path.join(g_ksValidationKitDir, os.pardir, os.pardir, os.pardir, 'out', \
                                                    utils.getHostOsDotArch(), sType, 'testboxscript', \
                                                    utils.getHostOs(), utils.getHostArch(), \
                                                    'TestBoxHelper');
            if utils.getHostOs() in ['win', 'os2']:
                self._sTestBoxHelper += '.exe';

        return utils.processOutputChecked([self._sTestBoxHelper, sCmd]).strip();
Пример #4
0
    def _getHelperOutput(self, sCmd):
        """
        Invokes TestBoxHelper to obtain information hard to access from python.
        """
        if self._sTestBoxHelper is None:
            if not utils.isRunningFromCheckout():
                # See VBoxTestBoxScript.zip for layout.
                self._sTestBoxHelper = os.path.join(g_ksValidationKitDir, utils.getHostOs(), utils.getHostArch(), \
                                                    'TestBoxHelper');
            else: # Only for in-tree testing, so don't bother be too accurate right now.
                sType = os.environ.get('KBUILD_TYPE', os.environ.get('BUILD_TYPE', 'debug'));
                self._sTestBoxHelper = os.path.join(g_ksValidationKitDir, os.pardir, os.pardir, os.pardir, 'out', \
                                                    utils.getHostOsDotArch(), sType, 'testboxscript', \
                                                    utils.getHostOs(), utils.getHostArch(), \
                                                    'TestBoxHelper');
            if utils.getHostOs() in ['win', 'os2']:
                self._sTestBoxHelper += '.exe';

        return utils.processOutputChecked([self._sTestBoxHelper, sCmd]).strip();
Пример #5
0
    def _detectPaths(self):
        """
        Internal worker for actionVerify and actionExecute that detects paths.

        This sets sVBoxInstallRoot and sUnitTestsPathBase and returns True/False.
        """

        #
        # We need a VBox install (/ build) to test.
        #
        if False is True:
            if not self.importVBoxApi():
                reporter.error('Unabled to import the VBox Python API.')
                return False
        else:
            self._detectBuild()
            if self.oBuild is None:
                reporter.error('Unabled to detect the VBox build.')
                return False

        #
        # Where are the files installed?
        # Solaris requires special handling because of it's multi arch subdirs.
        #
        self.sVBoxInstallRoot = self.oBuild.sInstallPath
        if not self.oBuild.isDevBuild() and utils.getHostOs() == 'solaris':
            sArchDir = utils.getHostArch()
            if sArchDir == 'x86': sArchDir = 'i386'
            self.sVBoxInstallRoot = os.path.join(self.sVBoxInstallRoot,
                                                 sArchDir)

        # Add the installation root to the PATH on windows so we can get DLLs from it.
        if utils.getHostOs() == 'win':
            sPathName = 'PATH'
            if not sPathName in os.environ:
                sPathName = 'Path'
            sPath = os.environ.get(sPathName, '.')
            if sPath and sPath[-1] != ';':
                sPath += ';'
            os.environ[sPathName] = sPath + self.sVBoxInstallRoot + ';'

        #
        # The unittests are generally not installed, so look for them.
        #
        sBinOrDist = 'dist' if utils.getHostOs() in [
            'darwin',
        ] else 'bin'
        asCandidates = [
            self.oBuild.sInstallPath,
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(),
                         self.oBuild.sType, sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(),
                         'release', sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'debug',
                         sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'strict',
                         sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'dbgopt',
                         sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(),
                         'profile', sBinOrDist),
            os.path.join(self.sScratchPath,
                         sBinOrDist + '.' + utils.getHostArch()),
            os.path.join(self.sScratchPath, sBinOrDist, utils.getHostArch()),
            os.path.join(self.sScratchPath, sBinOrDist),
        ]
        if utils.getHostOs() == 'darwin':
            for i in range(1, len(asCandidates)):
                asCandidates[i] = os.path.join(asCandidates[i],
                                               'VirtualBox.app', 'Contents',
                                               'MacOS')

        for sCandidat in asCandidates:
            if os.path.exists(
                    os.path.join(sCandidat, 'testcase',
                                 'tstVMStructSize' + self.sExeSuff)):
                self.sUnitTestsPathBase = sCandidat
                return True

        reporter.error('Unable to find unit test dir. Candidates: %s' %
                       (asCandidates, ))
        return False
    def _detectPaths(self):
        """
        Internal worker for actionVerify and actionExecute that detects paths.

        This sets sVBoxInstallRoot and sUnitTestsPathBase and returns True/False.
        """

        #
        # We need a VBox install (/ build) to test.
        #
        if False is True:
            if not self.importVBoxApi():
                reporter.error('Unabled to import the VBox Python API.')
                return False
        else:
            self._detectBuild();
            if self.oBuild is None:
                reporter.error('Unabled to detect the VBox build.');
                return False;

        #
        # Where are the files installed?
        # Solaris requires special handling because of it's multi arch subdirs.
        #
        self.sVBoxInstallRoot = self.oBuild.sInstallPath
        if not self.oBuild.isDevBuild() and utils.getHostOs() == 'solaris':
            sArchDir = utils.getHostArch();
            if sArchDir == 'x86': sArchDir = 'i386';
            self.sVBoxInstallRoot = os.path.join(self.sVBoxInstallRoot, sArchDir);

        # Add the installation root to the PATH on windows so we can get DLLs from it.
        if utils.getHostOs() == 'win':
            sPathName = 'PATH';
            if not sPathName in os.environ:
                sPathName = 'Path';
            sPath = os.environ.get(sPathName, '.');
            if sPath and sPath[-1] != ';':
                sPath += ';';
            os.environ[sPathName] = sPath + self.sVBoxInstallRoot + ';';

        #
        # The unittests are generally not installed, so look for them.
        #
        sBinOrDist = 'dist' if utils.getHostOs() in [ 'darwin', ] else 'bin';
        asCandidates = [
            self.oBuild.sInstallPath,
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), self.oBuild.sType, sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'release', sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'debug',   sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'strict',  sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'dbgopt',  sBinOrDist),
            os.path.join(self.sScratchPath, utils.getHostOsDotArch(), 'profile', sBinOrDist),
            os.path.join(self.sScratchPath, sBinOrDist + '.' + utils.getHostArch()),
            os.path.join(self.sScratchPath, sBinOrDist, utils.getHostArch()),
            os.path.join(self.sScratchPath, sBinOrDist),
        ];
        if utils.getHostOs() == 'darwin':
            for i in range(1, len(asCandidates)):
                asCandidates[i] = os.path.join(asCandidates[i], 'VirtualBox.app', 'Contents', 'MacOS');

        for sCandidat in asCandidates:
            if os.path.exists(os.path.join(sCandidat, 'testcase', 'tstVMStructSize' + self.sExeSuff)):
                self.sUnitTestsPathBase = sCandidat;
                return True;

        reporter.error('Unable to find unit test dir. Candidates: %s' % (asCandidates,))
        return False;