Пример #1
0
 def _runTask(self, test, device, result):
     '''
     Runs a related test case task within the context.
     '''
     idx = 0
     try:
         if self.task.parent:
             idx = len(self.task.parent.caseSetUps)
             for setUp in self.task.parent.caseSetUps:
                 setUp(test, device)
                 idx -= 1
         for step, stepResult in zip(self.task.test,
                                     self.task.result.children):
             result.startTest(stepResult, device)
             execResult = stepResult.device(device)
             try:
                 try:
                     step.run(test, device)
                 except testexec.TestFailThisError, err:
                     execResult.errors.append(testexec.errorInfo(err))
                     execResult.status = err.status
                 except KeyboardInterrupt, err:
                     execResult.errors.append(testexec.errorInfo(err))
                     execResult.status = testexec.STATUS_NOT_COMPLETED
                     raise testexec.TestAbortError("Keyboard interrupt")
                 except Exception, err:
                     execResult.errors.append(testexec.errorInfo(err))
                     execResult.status = getattr(err, "status",
                                                 testexec.STATUS_ERROR)
                     raise
Пример #2
0
 def _runTask(self, test, device, result):
     '''
     Runs a related test case task within the context.
     '''
     idx = 0
     try:
         if self.task.parent:
             idx = len(self.task.parent.caseSetUps)
             for setUp in self.task.parent.caseSetUps:
                 setUp(test, device)
                 idx -= 1
         for step, stepResult in zip(self.task.test,
                                     self.task.result.children):
             result.startTest(stepResult, device)
             execResult = stepResult.device(device)
             try:
                 try:
                     step.run(test, device)
                 except testexec.TestFailThisError, err:
                     execResult.errors.append(testexec.errorInfo(err))
                     execResult.status = err.status
                 except KeyboardInterrupt, err:
                     execResult.errors.append(testexec.errorInfo(err))
                     execResult.status = testexec.STATUS_NOT_COMPLETED
                     raise testexec.TestAbortError("Keyboard interrupt")
                 except Exception, err:
                     execResult.errors.append(testexec.errorInfo(err))
                     execResult.status = getattr(err, "status",
                                                 testexec.STATUS_ERROR)
                     raise
Пример #3
0
    def stopTest(self, result, device):
        '''
        Sends the stop test result through all enabled channels.

        :param result: A test result to pass through channels
        :type result: TestResultBase
        :param device: A related device execution result
        :type device: DeviceExecResult
        '''
        self._mutex.acquire()
        try:
            execResult = result.device(device)
            dt = datetime.now() - execResult.date
            execResult.time = (dt.days*24*3600 + dt.seconds
                               + dt.microseconds/10.0**6)
            # Core dumps channel
            if self._coreDumps.isEnabled() and execResult.cores is not None:
                try:
                    self._coreDumps.stopTest(execResult, device)
                except Exception, err:
                    execResult.cores = []
                    if isinstance(err, testexec.TestAbortError):
                        execResult.errors.append(testexec.errorInfo(err))
                        execResult.status = err.status
                        raise
                    log.exception(err)
                    self._coreDumps.setEnabled(False)
            else:
Пример #4
0
    def startTest(self, result, device):
        '''
        Sends the start test result through all enabled channels.

        :param result: A test result to pass through channels
        :type result: TestResultBase
        :param device: A related device execution result
        :type device: DeviceExecResult
        '''
        self._mutex.acquire()
        try:
            execResult = result.device(device)
            execResult.status = testexec.STATUS_NOT_COMPLETED
            execResult.date = datetime.now()
            # Result channels
            for channel in self.get():
                if channel.isEnabled():
                    try:
                        channel.startTest(result, execResult)
                    except Exception, err:
                        log.exception(err)
                        channel.setEnabled(False)
            # Core dumps channel
            if self._coreDumps.isEnabled():
                try:
                    self._coreDumps.startTest(execResult, device)
                except Exception, err:
                    if isinstance(err, testexec.TestAbortError):
                        execResult.errors.append(testexec.errorInfo(err))
                        raise
                    log.exception(err)
                    self._coreDumps.setEnabled(False)
Пример #5
0
 def run(self, test, device, result):
     '''
     Runs the task context.
     '''
     result.startTest(self.task.result, device)
     execResult = self.task.result.device(device)
     try:
         try:
             self._runTask(test, device, result)
         except testexec.TestAbortError, err:
             execResult.errors.append(testexec.errorInfo(err))
             execResult.status = err.status
             raise
         except testexec.TestAssertError, err:
             execResult.errors.append(testexec.errorInfo(err))
             execResult.status = err.status
Пример #6
0
 def run(self, test, device, result):
     '''
     Runs the task context.
     '''
     result.startTest(self.task.result, device)
     execResult = self.task.result.device(device)
     try:
         try:
             self._runTask(test, device, result)
         except testexec.TestAbortError, err:
             execResult.errors.append(testexec.errorInfo(err))
             execResult.status = err.status
             raise
         except testexec.TestAssertError, err:
             execResult.errors.append(testexec.errorInfo(err))
             execResult.status = err.status
Пример #7
0
class TaskContext:
    '''
    A base class of task contexts.
    '''
    child = None

    def __init__(self, task):
        self.task = task

    def _runTask(self, test, device, result):
        '''
        Runs the related test task within the context.
        '''
        pass

    def run(self, test, device, result):
        '''
        Runs the task context.
        '''
        result.startTest(self.task.result, device)
        execResult = self.task.result.device(device)
        try:
            try:
                self._runTask(test, device, result)
            except testexec.TestAbortError, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = err.status
                raise
            except testexec.TestAssertError, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = err.status
            except KeyboardInterrupt, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = testexec.STATUS_NOT_COMPLETED
                raise testexec.TestAbortError("Keyboard interrupt")
Пример #8
0
        try:
            try:
                self._runTask(test, device, result)
            except testexec.TestAbortError, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = err.status
                raise
            except testexec.TestAssertError, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = err.status
            except KeyboardInterrupt, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = testexec.STATUS_NOT_COMPLETED
                raise testexec.TestAbortError("Keyboard interrupt")
            except Exception, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = testexec.STATUS_ERROR
                # FIXME
                # Shouldn't some exception be passed higher?
            else:
                execResult.status = testexec.STATUS_PASSED
        finally:
            result.stopTest(self.task.result, device)


class CaseContext(TaskContext):
    '''
    A class of test case contexts.
    '''
    def _runTask(self, test, device, result):
        '''
Пример #9
0
        try:
            try:
                self._runTask(test, device, result)
            except testexec.TestAbortError, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = err.status
                raise
            except testexec.TestAssertError, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = err.status
            except KeyboardInterrupt, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = testexec.STATUS_NOT_COMPLETED
                raise testexec.TestAbortError("Keyboard interrupt")
            except Exception, err:
                execResult.errors.append(testexec.errorInfo(err))
                execResult.status = testexec.STATUS_ERROR
                # FIXME
                # Shouldn't some exception be passed higher?
            else:
                execResult.status = testexec.STATUS_PASSED
        finally:
            result.stopTest(self.task.result, device)


class CaseContext(TaskContext):
    '''
    A class of test case contexts.
    '''
    def _runTask(self, test, device, result):
        '''