Exemplo n.º 1
0
    def _expand_test(self, test, expandedSuite):
        if isinstance(test, test_classes.OnAllDefaultTargetsTest):
            for target in self.defaultTestTargets:
                if target.isConnected:
                    #create a copy of test for each target
                    testForOneTarget = copy.deepcopy(test)
                    testForOneTarget.set_target(target)
                    expandedSuite.addTest(testForOneTarget)

        elif isinstance(test, test_classes.MultipleConnectionsTest) or isinstance(test, test_classes.OnSelectedTargetsTest):
            if type(test).__name__ in self.config.testToTargetConfig:
                for targetInfoSet in self.config.testToTargetConfig[type(test).__name__]:
                    targetSet = [self.targets[i] for i in targetInfoSet]
                    if self._checkIfAllTargetsReady(targetSet) and self._checkIfValidConfig(test, targetSet):
                        # create a copy of test for each target set
                        testForOneTargetSet = copy.deepcopy(test)
                        for target in targetSet:
                            if isinstance(test, test_classes.MultipleConnectionsTest):
                                testForOneTargetSet.add_target(target)
                            else:
                                testForOneTargetSet.set_target(target)
                        expandedSuite.addTest(testForOneTargetSet)
                    else:
                        log.error("test '{0}' could not be added to the active tests due to missing target connection or "
                                "invalid src.".format(test.id()))
            else:
                log.warning("Missing testToTargetConfig for test {0}".format(test.id()))
        else:
            # other kinds of unit tests are executed as usual
            expandedSuite.addTest(test)
Exemplo n.º 2
0
    def _take_system_compositor_screenshot(self, screenshotName, renderer):
        log.info("Make screenshot of screen using system compositor")

        targetScreenshotPath = self.tmpDir + "/" + screenshotName
        renderer.send_ramsh_command(
            "scScreenshot \"{}\" {}".format(targetScreenshotPath,
                                            self.main_screen_id),
            response_message=
            "SystemCompositorController_Wayland_IVI::screenshot: Saved screenshot for screen"
        )

        startTime = time.time()
        while time.time() < startTime + SYSTEM_COMPOSITOR_SCREENSHOT_TIMEOUT:
            (_, _,
             retCode) = self.execute_on_target("find " + targetScreenshotPath)
            if retCode == 0:
                log.info("system_compositor_screenshot: found {}".format(
                    targetScreenshotPath))
                return True
            log.info("system_compositor_screenshot: find result {} since {}s ".
                     format(retCode,
                            time.time() - startTime))
            time.sleep(0.1)

        log.warning(
            "system_compositor_screenshot: failed to take screenshot {}".
            format(screenshotName))
        return False
Exemplo n.º 3
0
    def _connect(self):
        self.sshClient = paramiko.SSHClient()
        self.sshClient.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        log.info("connecting to "+self.name+" hostname: "+self.hostname+" user: "******"Trying to connect to {} port {} for the {} time.".format(self.hostname, self.sshPort, nrAttempts))
                self.sshClient.connect(self.hostname, port=self.sshPort, username=self.username, password=self.password,
                                       pkey=rsa_key, timeout=self.sshConnectionTimeoutPerAttempt, allow_agent=False,
                                       look_for_keys=False, banner_timeout=45)
                transport = self.sshClient.get_transport()
                transport.set_keepalive(5)

            except (socket.error, SSHException) as e:
                log.warning("Connection could not be established, maybe not ready yet: {0}".format(e))
                time.sleep(self.sshConnectionSleepPerAttempt)  # server not yet ready
            except (BadHostKeyException, AuthenticationException) as e:
                log.error("Connection error: {0}".format(e))
                break
            else:
                self.isConnected = True

        if not self.isConnected:
            log.error("Connection to {0} could not be established".format(self.name))
            return

        log.info("Connection to {0} successfully established".format(self.name))
Exemplo n.º 4
0
    def setup(self, transfer_binaries=True):
        # add platform specific dll/so search path
        if platform.system() == "Windows":
            self.defaultEnvironment = {'PATH' : os.environ.get('PATH', '') + ";" + os.path.join(self.ramsesInstallDir, 'lib')}
        elif platform.system() == "Linux":
            self.defaultEnvironment = {'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH', '') + ":" + os.path.join(self.ramsesInstallDir, 'lib')}
        else:
            log.warning("Unknown system {}: There might be shared library load errors".format(platform.system()))

        return True
Exemplo n.º 5
0
 def _take_renderer_screenshot(self, screenshotName, renderer, displayNumber):
     log.info("Make screenshot of renderer")
     ramshCommand  = "screenshot -filename \"{0}\"".format(self.tmpDir+"/"+screenshotName)
     if displayNumber:
         ramshCommand += " -displayId {}".format(displayNumber)
     #waitForRendererConfirmation cannot be used for screenshot creation as screenshots are enqeued at the renderer and taken on the next renderer loop
     result = renderer.send_ramsh_command(ramshCommand, response_message="screenshot successfully saved to file")
     if not result:
         log.warning("Screenshot confirmation not received from the renderer, check renderer application output")
         #print some debug output
         renderer.send_ramsh_command("rinfo all -v")
Exemplo n.º 6
0
 def target_specific_tear_down(self, shutdown=True):
     try:
         Target.target_specific_tear_down(self, shutdown=shutdown)
         if self.isConnected:
             if shutdown:
                 self._shutdown()
             self.sshClient.close()
     except SSHException as e:
         log.warning(
             'Paramiko exception during target_specific_tear_down: ' +
             str(e))
    def impl_test(self):
        if self.target.systemCompositorControllerSupported:
            ensureHasContentOnSurface(self.rendererLeft, self.firstSurfaceIviId)
            ensureHasContentOnSurface(self.rendererRight, self.secondSurfaceIviId)

            self.rendererLeft.showScene(25)
            self.rendererRight.showScene(26)
            ensureSystemCompositorRoundTrip(self.rendererLeft, self.firstSurfaceIviId)
            self.validateScreenshot(self.rendererLeft, "testClient_multiple_ivi_layers.png", useSystemCompositorForScreenshot=True)

        else:
            log.warning("TestMultipleIVILayers skipped as system compositor controller support is not configured for this target")
Exemplo n.º 8
0
    def impl_test(self):
        if self.target.systemCompositorControllerSupported:

            self.rendererLeft.showScene(25)
            self.rendererRight.showScene(26)
            self.validateScreenshot(self.rendererLeft,
                                    "testClient_multiple_ivi_layers.png",
                                    useSystemCompositorForScreenshot=True)

        else:
            log.warning(
                "TestMultipleIVILayers skipped as system compositor controller support is not configured for this target"
            )
Exemplo n.º 9
0
    def retrieveCurrentState(self):
        self.flush()
        (stdout, _, _) = self.callIVIControl("scene")

        scene_state = dict()
        section_name = ""
        section_id = 0
        for line in stdout:
            try:
                # check whether the line starts with a whitespace or not
                # if it does not start with a whitespace we have a new
                # section ("screen", "layer", etc.)
                if not re.match(r'\s', line):
                    line_tokens = line.strip().split()
                    if len(line_tokens) != 2:
                        log.warning(
                            "Unexpected line while parsing output from ivi-control: "
                            + line)
                        log.warning(
                            "Expect issues (and errors) while running the test(s)"
                        )
                        section_name = ""
                        section_id = 0
                        continue

                    section_name, section_id = line_tokens

                    if section_name not in scene_state:
                        scene_state[section_name] = dict()

                    scene_state[section_name][section_id] = dict()

                # otherwise we are inside a section, so we add the info
                # to the section's dictionary
                else:
                    assert (section_name != "" and section_id != 0)
                    section_dict = scene_state[section_name][section_id]
                    object_parameter = [x.strip() for x in line.split(":")]
                    section_dict[object_parameter[0]] = object_parameter[1]
            except Exception:
                log.warning("ivi: Failed while processing line: " + line)
                log.warning("Full stdout of command:")
                for line in stdout:
                    log.warning(line)
                raise
        return scene_state
Exemplo n.º 10
0
def ramses_process_check(target):
    ramsesProcesses = target.get_process_list("ramses")
    if len(ramsesProcesses) > 0:
        log.warning(
            "RAMSES processes running before test startup on target {}. Process list: {}"
            .format(target.name, ramsesProcesses))
Exemplo n.º 11
0
    def wait_for_msg(self, watch_id, msg, timeout=None):
        """
        Blocks until msg found or timeout
        :return: True if msg found during watch, False otherwise
        """

        # don't wait if no watch_id
        if watch_id is None:
            log.error("Cannot wait! No watch_id given!")
            return False

        # don't wait if watch not active
        if not self.is_active(watch_id):
            log.error(
                "Cannot wait! Reader has no active watch with given id: {}!".
                format(watch_id))
            return False

        timer = None
        if timeout:
            timer = threading.Timer(timeout, self.remove_watch, [watch_id])
            timer.start()
            if msg is None:
                log.warning("Msg not given! Will block until timeout")
                timer.join()
                return False
        elif msg:
            log.warning(
                "Timeout not given! Will block until message received.\n"
                "(Note: if msg not found, will block forever.)")
        else:
            # don't wait if not timer and no msg given
            log.error("Cannot wait! Nor timeout or msg given.")
            return False

        # check data in buffer that is available until now
        nextLinePos = self.buffer.get_length()
        for i in range(self.watchStartPositions[watch_id], nextLinePos):
            if not self.is_active(watch_id):
                log.warning(
                    "Timeout ({} seconds) waiting for msg:\'{}\' in reader: {}."
                    .format(str(timeout), msg, self.name))
                return False
            line = self.buffer.get_line(i)
            if re.search(msg, line):
                self.remove_watch(watch_id)
                if timer:
                    timer.cancel()
                return True

        # wait for new data
        while self.is_active(watch_id):
            bufferSize = self.buffer.get_length()
            if nextLinePos >= bufferSize:
                time.sleep(0.1)
            else:
                line = self.buffer.get_line(nextLinePos)
                if re.search(msg, line):
                    self.remove_watch(watch_id)
                    if timer:
                        timer.cancel()
                    return True
                else:
                    nextLinePos += 1
        log.warning("Timeout ({} seconds) waiting for msg:\'{}\'".format(
            str(timeout), msg))
        return False
    def hasFileReadingErrors(self, traceOutput):
        openFileSeekPositions = {}
        openFileNames = {}
        openedFileCounter = {}
        error = False

        openRegEx = re.compile('fopen\("(.+.ramres)".*, "rb"\) = (0x[\w]+)')
        seekRegEx = re.compile('fseek\((0x[\w]+), ([\w]+),')
        closeRegEx = re.compile('fclose\((0x[\w]+)\)')

        for line in traceOutput:

            fileOpenMatch = openRegEx.search(line)
            if fileOpenMatch:
                fileName = fileOpenMatch.groups()[0]
                fileHandle = fileOpenMatch.groups()[1]

                assert (fileHandle not in openFileSeekPositions)
                openFileSeekPositions[fileHandle] = []
                openFileNames[fileHandle] = fileName

                if fileName not in openedFileCounter:
                    openedFileCounter[fileName] = 1
                else:
                    openedFileCounter[fileName] += 1

                continue

            fileSeekMatch = seekRegEx.search(line)
            if fileSeekMatch:
                fileHandle = fileSeekMatch.groups()[0]

                if fileHandle in openFileSeekPositions:
                    seekPostion = int(fileSeekMatch.groups()[1],
                                      0)  # positions may also occur in hex
                    openFileSeekPositions[fileHandle].append(seekPostion)

                continue

            fileCloseMatch = closeRegEx.search(line)
            if fileCloseMatch:
                fileHandle = fileCloseMatch.groups()[0]

                if fileHandle in openFileSeekPositions:
                    if not self.checkForIncreasingSeekOrder(
                            openFileSeekPositions[fileHandle]):
                        error |= True
                        log.error(
                            "no increasing seek/read actions in file {}: {}".
                            format(openFileNames[fileHandle],
                                   openFileSeekPositions[fileHandle]))
                    del openFileNames[fileHandle]
                    del openFileSeekPositions[fileHandle]

        if len(openedFileCounter) == 0:
            error |= True
            log.warning(
                "no ramses resource file (*.ramres) was opened during the test. Please check your test application."
            )
        else:
            for fileName, openCount in openedFileCounter.iteritems():
                if openCount > 1:
                    error |= True
                    log.error(
                        "file {} was opened/closed {} times (only once is allowed)"
                        .format(fileName, openCount))
                else:
                    log.info("file {} was opened only once".format(fileName))

        return error