validate: tools: Create a class for scenarios

This commit is contained in:
Thibault Saunier 2014-01-24 11:41:25 +01:00
parent ba1f428351
commit 2391a56714
3 changed files with 75 additions and 33 deletions

View file

@ -23,7 +23,7 @@ import subprocess
import utils import utils
from urllib import unquote from urllib import unquote
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from baseclasses import GstValidateTest, TestsManager from baseclasses import GstValidateTest, TestsManager, Scenario
DURATION_TOLERANCE = utils.GST_SECOND / 2 DURATION_TOLERANCE = utils.GST_SECOND / 2
DEFAULT_GES_LAUNCH = "ges-launch-1.0" DEFAULT_GES_LAUNCH = "ges-launch-1.0"
@ -207,11 +207,15 @@ class GESTestsManager(TestsManager):
else: else:
projects.append(utils.path2url(proj)) projects.append(utils.path2url(proj))
SCENARIOS = ["play_15s", "seek_forward", "seek_backward", "scrub_forward_seeking"] SCENARIOS = [Scenario.get_scenario("play_15s"),
Scenario.get_scenario("seek_forward"),
Scenario.get_scenario("seek_backward"),
Scenario.get_scenario("scrub_forward_seeking")]
for proj in projects: for proj in projects:
# First playback casses # First playback casses
for scenario in SCENARIOS: for scenario in SCENARIOS:
classname = "ges.playback.%s.%s" % (scenario, os.path.basename(proj).replace(".xges", "")) classname = "ges.playback.%s.%s" % (scenario.name,
os.path.basename(proj).replace(".xges", ""))
self.add_test(GESPlaybackTest(classname, self.add_test(GESPlaybackTest(classname,
self.options, self.options,
self.reporter, self.reporter,

View file

@ -22,7 +22,7 @@ import subprocess
import ConfigParser import ConfigParser
from loggable import Loggable from loggable import Loggable
from baseclasses import GstValidateTest, TestsManager, Test from baseclasses import GstValidateTest, TestsManager, Test, Scenario, NamedDic
from utils import MediaFormatCombination, get_profile,\ from utils import MediaFormatCombination, get_profile,\
path2url, get_current_position, get_current_size, \ path2url, get_current_position, get_current_size, \
DEFAULT_TIMEOUT, which, GST_SECOND, Result, \ DEFAULT_TIMEOUT, which, GST_SECOND, Result, \
@ -45,15 +45,28 @@ COMBINATIONS = [
MediaFormatCombination("mp4", "mp3", "h264"), MediaFormatCombination("mp4", "mp3", "h264"),
MediaFormatCombination("mkv", "vorbis", "h264")] MediaFormatCombination("mkv", "vorbis", "h264")]
class NamedDic(object):
def __init__(self, props):
for name, value in props.iteritems():
setattr(self, name, value)
PROTOCOL_TIMEOUTS = {"http": 60, PROTOCOL_TIMEOUTS = {"http": 60,
"hls": 60} "hls": 60}
G_V_SCENARIOS = {"file": [Scenario.get_scenario("play_15s"),
Scenario.get_scenario("simple_backward"),
Scenario.get_scenario("fast_forward"),
Scenario.get_scenario("seek_forward"),
Scenario.get_scenario("seek_backward"),
Scenario.get_scenario("scrub_forward_seeking")],
"http": [Scenario.get_scenario("play_15s"),
Scenario.get_scenario("fast_forward"),
Scenario.get_scenario("seek_forward"),
Scenario.get_scenario("seek_backward"),
Scenario.get_scenario("simple_backward")],
"hls": [Scenario.get_scenario("play_15s"),
Scenario.get_scenario("fast_forward"),
Scenario.get_scenario("seek_forward"),
Scenario.get_scenario("seek_backward")],
}
class GstValidateLaunchTest(GstValidateTest): class GstValidateLaunchTest(GstValidateTest):
def __init__(self, classname, options, reporter, pipeline_desc, def __init__(self, classname, options, reporter, pipeline_desc,
@ -78,10 +91,10 @@ class GstValidateLaunchTest(GstValidateTest):
class GstValidateMediaCheckTest(Test): class GstValidateMediaCheckTest(Test):
def __init__(self, classname, options, reporter, media_info_path, uri): def __init__(self, classname, options, reporter, media_info_path, uri, timeout=DEFAULT_TIMEOUT):
super(GstValidateMediaCheckTest, self).__init__(DISCOVERER_COMMAND[0], classname, super(GstValidateMediaCheckTest, self).__init__(DISCOVERER_COMMAND[0], classname,
options, reporter, options, reporter,
timeout=30) timeout=timeout)
self._uri = uri self._uri = uri
self._media_info_path = urlparse.urlparse(media_info_path).path self._media_info_path = urlparse.urlparse(media_info_path).path
@ -115,6 +128,7 @@ class GstValidateTranscodingTest(GstValidateTest):
self.add_arguments("-o", profile) self.add_arguments("-o", profile)
def build_arguments(self): def build_arguments(self):
GstValidateTest.build_arguments(self)
self.set_rendering_info() self.set_rendering_info()
self.add_arguments(self.uri, self.dest_file) self.add_arguments(self.uri, self.dest_file)
@ -146,13 +160,8 @@ class GstValidateManager(TestsManager, Loggable):
return False return False
def list_tests(self): def list_tests(self):
SCENARIOS = ["play_15s", "simple_backward",
"fast_forward", "seek_forward",
"seek_backward", "scrub_forward_seeking"]
for test_pipeline in PLAYBACK_TESTS: for test_pipeline in PLAYBACK_TESTS:
for scenario in SCENARIOS: self._add_playback_test(test_pipeline)
self._add_playback_test(scenario, test_pipeline)
for uri, mediainfo in self._list_uris(): for uri, mediainfo in self._list_uris():
classname = "validate.media_check.%s" % (os.path.splitext(os.path.basename(uri))[0].replace(".", "_")) classname = "validate.media_check.%s" % (os.path.splitext(os.path.basename(uri))[0].replace(".", "_"))
@ -160,7 +169,8 @@ class GstValidateManager(TestsManager, Loggable):
self.options, self.options,
self.reporter, self.reporter,
mediainfo.path, mediainfo.path,
uri)) uri,
timeout=timeout))
for uri, mediainfo in self._list_uris(): for uri, mediainfo in self._list_uris():
if mediainfo.config.getboolean("media-info", "is-image") is True: if mediainfo.config.getboolean("media-info", "is-image") is True:
@ -246,12 +256,12 @@ class GstValidateManager(TestsManager, Loggable):
return self._uris return self._uris
def _get_fname(self, scenario, protocol=None): def _get_fname(self, scenario, protocol=None):
if scenario is not None and scenario.lower() != "none": if scenario is not None and scenario.name.lower() != "none":
return "%s.%s.%s.%s" % ("validate", protocol, "playback", scenario) return "%s.%s.%s.%s" % ("validate", protocol, "playback", scenario.name)
return "%s.%s.%s" % ("validate", protocol, "playback") return "%s.%s.%s" % ("validate", protocol, "playback")
def _add_playback_test(self, scenario, pipe): def _add_playback_test(self, pipe):
if self.options.mute: if self.options.mute:
if "autovideosink" in pipe: if "autovideosink" in pipe:
pipe = pipe.replace("autovideosink", "fakesink") pipe = pipe.replace("autovideosink", "fakesink")
@ -263,7 +273,7 @@ class GstValidateManager(TestsManager, Loggable):
npipe = pipe npipe = pipe
protocol = minfo.config.get("file-info", "protocol") protocol = minfo.config.get("file-info", "protocol")
if scenario != "none": for scenario in G_V_SCENARIOS[protocol]:
if minfo.config.getboolean("media-info", "seekable") is False: if minfo.config.getboolean("media-info", "seekable") is False:
self.debug("Do not run %s as %s does not support seeking", self.debug("Do not run %s as %s does not support seeking",
scenario, uri) scenario, uri)
@ -274,17 +284,17 @@ class GstValidateManager(TestsManager, Loggable):
# is run sync, otherwize some tests will fail # is run sync, otherwize some tests will fail
npipe = pipe.replace("fakesink", "'fakesink sync=true'") npipe = pipe.replace("fakesink", "'fakesink sync=true'")
fname = "%s.%s" % (self._get_fname(scenario, fname = "%s.%s" % (self._get_fname(scenario,
protocol), protocol),
os.path.basename(uri).replace(".", "_")) os.path.basename(uri).replace(".", "_"))
self.debug("Adding: %s", fname) self.debug("Adding: %s", fname)
self.add_test(GstValidateLaunchTest(fname, self.add_test(GstValidateLaunchTest(fname,
self.options, self.options,
self.reporter, self.reporter,
npipe.replace("__uri__", uri), npipe.replace("__uri__", uri),
scenario=scenario, scenario=scenario,
file_infos=minfo.config) file_infos=minfo.config)
) )
else: else:
self.add_test(GstValidateLaunchTest(self._get_fname(scenario, "testing"), self.add_test(GstValidateLaunchTest(self._get_fname(scenario, "testing"),

View file

@ -433,3 +433,31 @@ class _TestsLauncher(Loggable):
for tester in self.testers: for tester in self.testers:
if tester.needs_http_server(): if tester.needs_http_server():
return True return True
class NamedDic(object):
def __init__(self, props):
if props:
for name, value in props.iteritems():
setattr(self, name, value)
class Scenario(NamedDic):
def __init__(self, name, props=None):
self.name = name
NamedDic.__init__(self, props)
@classmethod
def get_scenario(cls, name):
return [scenario for scenario in ALL_SCENARIOS if scenario.name == name][0]
ALL_SCENARIOS = [
Scenario("play_15s", {"max_duration": 15}),
Scenario("simple_backward"),
Scenario("fast_forward"),
Scenario("seek_forward"),
Scenario("seek_backward"),
Scenario("scrub_forward_seeking")
]