class GstWebRTCTestsManager(TestsManager):
    scenarios_manager = ScenarioManager()
    name = "webrtc"

    def __init__(self):
        super(GstWebRTCTestsManager, self).__init__()
        self.loading_testsuite = self.name
        self._scenarios = []

    def add_scenarios(self, scenarios):
        if isinstance(scenarios, list):
            self._scenarios.extend(scenarios)
        else:
            self._scenarios.append(scenarios)

        self._scenarios = list(set(self._scenarios))

    def set_scenarios(self, scenarios):
        self._scenarios = []
        self.add_scenarios(scenarios)

    def get_scenarios(self):
        return self._scenarios

    def populate_testsuite(self):
        self.add_scenarios (DEFAULT_SCENARIOS)
        self.set_default_blacklist(DEFAULT_BLACKLIST)

    def list_tests(self):
        if self.tests:
            return self.tests

        scenarios = [(scenario_name, self.scenarios_manager.get_scenario(scenario_name))
                     for scenario_name in self.get_scenarios()]

        for browser in DEFAULT_BROWSERS:
            for name, scenario in scenarios:
                if not scenario:
                    self.warning("Could not find scenario %s" % name)
                    continue
                if not SCENARIO_OVERRIDES_SUPPORTED[name]:
                    # no override choices supported
                    classname = browser + '.' + name
                    print ("adding", classname)
                    self.add_test(GstWebRTCTest(classname, self, scenario, browser))
                else:
                    for overrides in itertools.product(*[OVERRIDE_CHOICES[c] for c in SCENARIO_OVERRIDES_SUPPORTED[name]]):
                        oname = '.'.join (overrides)
                        opaths = [SCENARIO_OVERRIDES[p] for p in overrides]
                        classname = browser + '.' + oname + '.' + name
                        print ("adding", classname)
                        self.add_test(GstWebRTCTest(classname, self, scenario, browser, opaths))

        return self.tests
Exemple #2
0
class GESTestsManager(TestsManager):
    name = "ges"

    _scenarios = ScenarioManager()

    def __init__(self):
        super(GESTestsManager, self).__init__()

    def init(self):
        try:
            if "--set-scenario=" in subprocess.check_output(
                [GES_LAUNCH_COMMAND, "--help"]).decode():

                return True
            else:
                self.warning(
                    "Can not use ges-launch, it seems not to be compiled against"
                    " gst-validate")
        except subprocess.CalledProcessError as e:
            self.warning("Can not use ges-launch: %s" % e)
        except OSError as e:
            self.warning("Can not use ges-launch: %s" % e)

    def add_options(self, parser):
        group = parser.add_argument_group(
            "GStreamer Editing Services specific option"
            " and behaviours",
            description="""
The GStreamer Editing Services launcher will be usable only if GES has been compiled against GstValidate
You can simply run scenarios specifying project as args. For example the following will run all available
and activated scenarios on project.xges:

    $gst-validate-launcher ges /some/ges/project.xges


Available options:""")
        group.add_argument("-P",
                           "--projects-paths",
                           dest="projects_paths",
                           default=os.path.join(utils.DEFAULT_GST_QA_ASSETS,
                                                "ges", "ges-projects"),
                           help="Paths in which to look for moved medias")
        group.add_argument("-r",
                           "--disable-recurse-paths",
                           dest="disable_recurse",
                           default=False,
                           action="store_true",
                           help="Whether to recurse into paths to find medias")

    def set_settings(self, options, args, reporter):
        TestsManager.set_settings(self, options, args, reporter)
        self._scenarios.config = self.options

        try:
            os.makedirs(utils.url2path(options.dest)[0])
        except OSError:
            pass

    def list_tests(self):
        return self.tests

    def register_defaults(self, project_paths=None):
        projects = list()
        if not self.args:
            if project_paths == None:
                path = self.options.projects_paths
            else:
                path = project_paths

            for root, dirs, files in os.walk(path):
                for f in files:
                    if not f.endswith(".xges"):
                        continue
                    projects.append(utils.path2url(os.path.join(path, root,
                                                                f)))
        else:
            for proj_uri in self.args:
                if not utils.isuri(proj_uri):
                    proj_uri = utils.path2url(proj_uri)

                if os.path.exists(proj_uri):
                    projects.append(proj_uri)

        if self.options.long_limit != 0:
            scenarios = [
                "none", "scrub_forward_seeking", "scrub_backward_seeking"
            ]
        else:
            scenarios = [
                "play_15s", "scrub_forward_seeking_full",
                "scrub_backward_seeking_full"
            ]
        for proj_uri in projects:
            # First playback casses
            project = XgesProjectDescriptor(proj_uri)
            for scenario_name in scenarios:
                scenario = self._scenarios.get_scenario(scenario_name)
                if scenario is None:
                    continue

                if scenario.get_min_media_duration() >= (
                        project.get_duration() / utils.GST_SECOND):
                    continue

                classname = "playback.%s.%s" % (
                    scenario.name, os.path.basename(proj_uri).replace(
                        ".xges", ""))
                self.add_test(
                    GESPlaybackTest(classname,
                                    self.options,
                                    self.reporter,
                                    project,
                                    scenario=scenario))

            # And now rendering casses
            for comb in GES_ENCODING_TARGET_COMBINATIONS:
                classname = "render.%s.%s" % (str(comb).replace(
                    ' ', '_'), os.path.splitext(os.path.basename(proj_uri))[0])
                self.add_test(
                    GESRenderTest(classname,
                                  self.options,
                                  self.reporter,
                                  project,
                                  combination=comb))
Exemple #3
0
class GstValidateTranscodingTest(GstValidateTest,
                                 GstValidateEncodingTestInterface):
    scenarios_manager = ScenarioManager()

    def __init__(self,
                 classname,
                 options,
                 reporter,
                 combination,
                 uri,
                 media_descriptor,
                 timeout=DEFAULT_TIMEOUT,
                 scenario=None,
                 extra_env_variables=None):
        Loggable.__init__(self)

        extra_env_variables = extra_env_variables or {}

        file_dur = long(media_descriptor.get_duration()) / GST_SECOND
        if not media_descriptor.get_num_tracks("video"):
            self.debug("%s audio only file applying transcoding ratio."
                       "File 'duration' : %s" % (classname, file_dur))
            duration = file_dur / AUDIO_ONLY_FILE_TRANSCODING_RATIO
        else:
            duration = file_dur

        try:
            timeout = GST_VALIDATE_PROTOCOL_TIMEOUTS[
                media_descriptor.get_protocol()]
        except KeyError:
            pass

        super(GstValidateTranscodingTest,
              self).__init__(GST_VALIDATE_TRANSCODING_COMMAND,
                             classname,
                             options,
                             reporter,
                             duration=duration,
                             timeout=timeout,
                             scenario=scenario,
                             media_descriptor=media_descriptor,
                             extra_env_variables=None)
        extra_env_variables = extra_env_variables or {}

        GstValidateEncodingTestInterface.__init__(self, combination,
                                                  media_descriptor)

        self.uri = uri

    def set_rendering_info(self):
        self.dest_file = os.path.join(
            self.options.dest,
            self.classname.replace(".transcode.", os.sep).replace(".", os.sep))
        mkdir(os.path.dirname(urlparse.urlsplit(self.dest_file).path))
        if urlparse.urlparse(self.dest_file).scheme == "":
            self.dest_file = path2url(self.dest_file)

        profile = self.get_profile()
        self.add_arguments("-o", profile)

    def build_arguments(self):
        GstValidateTest.build_arguments(self)
        self.set_rendering_info()
        self.add_arguments(self.uri, self.dest_file)

    def get_current_value(self):
        if self.scenario:
            sent_eos = self.sent_eos_position()
            if sent_eos is not None:
                t = time.time()
                if ((t - sent_eos)) > 30:
                    if self.media_descriptor.get_protocol() == Protocols.HLS:
                        self.set_result(
                            Result.PASSED,
                            """Got no EOS 30 seconds after sending EOS,
                                        in HLS known and tolerated issue:
                                        https://bugzilla.gnome.org/show_bug.cgi?id=723868"""
                        )
                        return Result.KNOWN_ERROR

                    self.set_result(
                        Result.FAILED,
                        "Pipeline did not stop 30 Seconds after sending EOS")

                    return Result.FAILED

        size = self.get_current_size()
        if size is None:
            return self.get_current_position()

        return size

    def check_results(self):
        if self.result in [Result.FAILED, Result.TIMEOUT] or \
                self.process.returncode != 0:
            GstValidateTest.check_results(self)
            return

        res, msg = self.check_encoded_file()
        self.set_result(res, msg)
Exemple #4
0
class PitiviTestsManager(TestsManager):

    name = "pitivi"
    """The name identifying this test manager class."""

    _scenarios = ScenarioManager()

    def init(self):
        """Initializes the manager."""
        self.fixme("Implement init checking")

        return True

    def add_options(self, parser):
        """Adds options to the specified ArgumentParser."""
        group = parser.add_argument_group(
            "Pitivi specific option group"
            " and behaviours", description="")
        group.add_argument("--pitivi-executable",
                           dest="pitivi_executable",
                           default=os.path.join("..", "..", "bin", "pitivi"),
                           help="Path to the pitivi executable")
        group.add_argument("--pitivi-scenarios-paths",
                           dest="pitivi_scenario_paths",
                           help="Paths in which to look for scenario files")

    def set_settings(self, options, args, reporter):
        """Configures the manager based on the specified options."""
        TestsManager.set_settings(self, options, args, reporter)
        PitiviTestsManager._scenarios.config = self.options

        try:
            os.makedirs(utils.url2path(options.dest)[0])
        except OSError:
            pass

    def list_tests(self):
        """Lists the tests in the order they have been added."""
        return self.tests

    def find_scenarios(self):
        """Yields paths to the found scenario files."""
        for path in self.options.pitivi_scenario_paths:
            for root, unused_dirs, files in os.walk(path):
                for file in files:
                    if not file.endswith(".scenario"):
                        continue
                    yield os.path.join(path, root, file)

    def register_defaults(self):
        """Adds the available scenario files as tests."""
        for scenario_name in self.find_scenarios():
            scenario = PitiviTestsManager._scenarios.get_scenario(
                scenario_name)
            if scenario is None:
                continue

            classname = "pitivi.%s" % scenario.name
            self.add_test(
                PitiviTest(self.options.pitivi_executable,
                           classname,
                           self.options,
                           self.reporter,
                           scenario=scenario))