Example #1
0
    def runBenchmark(self,benchmark,stdout):
        config = self.getConfiguration()
        testCase = TestCase(config,stdout)
        testCase.prepare(benchmark)

        self.scanFedSizes(benchmark,testCase)
        testCase.destroy()
Example #2
0
class RestartableRunner:
    """class for running a single configuration without writing out
    any results. Can be asked to restart stop and restart the EVB."""

    def __init__(self, testRunner):
        # @param testRunner is used to get the requested
        #        EVB configuration. It should inherit
        #        from class TestRunner and have a method
        #        getConfiguration()

        self.testRunner = testRunner

        # flag whether EVB should be restarted
        # after it was stopped or not
        self.stopFlag = False

        # flag for 'evb was started'
        self.evbStarted = threading.Event()
        self.evbStopped = threading.Event()
        self.evbStopped.set()

        # queues for communication with
        # callback which is called after
        # the startup of the EVB
        from Queue import Queue

        # used to signal that the EVB should be stopped
        self.stopQueue = Queue()

        # acknowledgement events that EVB was stopped
        self.stopAckQueue = Queue()

        # callback which is called after a TestCaseObject was created
        self.beforeScanStartCallback = None

        self.testCase = None



    def run(self, stdout):

        logging.info("RestartableRunner.run() called")

        self.testRunner.startLaunchers()

        # TODO: check if all launchers are responding (with timeout)
        # instead of waiting for a fixed amount of time
        time.sleep(5)

        configData = self.testRunner.getAllConfigurations()[0]
        config = configData['config']
        testName = configData['name']

        try:
            while not self.stopFlag:
                try:
                    self.testCase = TestCase(config, stdout, afterStartupCallback=self.afterStartupCallback)
                    self.testCase.prepare(testName)

                    fragSize = self.testRunner.getFedSizes()
                    assert len(fragSize) == 1

                    fragSize = fragSize[0]
                    fragSizeRMS = int(fragSize * self.testRunner.args['rms'])

                    # this should only terminate when the user terminates the optimization
                    self.testCase.runScan(fragSize, fragSizeRMS, self.testRunner.args)

                    # evb was stopped
                    self.evbStarted.clear()
                    self.evbStopped.set()

                    self.testCase.destroy()
                    self.testCase = None

                except BadConfig:
                    self.stopFlag = True
                    sys.exit(1)
        finally:
            self.testRunner.stopLaunchers()



    def checkApplicationsEnabled(self):
        # @return true if all applications are in 'Enabled' state
        # note that this gives only meaningful results
        # while run() is running

        if not self.testCase is None:
            try:
                self.testCase.checkState('Enabled')
                return True
            except (StateException, FailedState), ex:
                # some are not in Enabled state
                return False

        return None