validate:launcher: Batch inspecting scenarios

Removing almost 1 second to start running tests with the default
testsuite
This commit is contained in:
Thibault Saunier 2020-01-07 19:29:05 -03:00
parent ca93a4b704
commit bc622ec658
3 changed files with 34 additions and 15 deletions

View file

@ -4056,13 +4056,12 @@ static gboolean
_parse_scenario (GFile * f, GKeyFile * kf)
{
gboolean ret = FALSE;
gchar *fname = g_file_get_basename (f);
gchar *path = g_file_get_path (f);
if (g_str_has_suffix (fname, GST_VALIDATE_SCENARIO_SUFFIX)) {
if (g_str_has_suffix (path, GST_VALIDATE_SCENARIO_SUFFIX)) {
gboolean needs_clock_sync = FALSE;
GstStructure *desc = NULL;
gchar **name = g_strsplit (fname, GST_VALIDATE_SCENARIO_SUFFIX, 0);
GList *tmp, *structures = gst_validate_structs_parse_from_gfile (f);
for (tmp = structures; tmp; tmp = tmp->next) {
@ -4088,22 +4087,21 @@ _parse_scenario (GFile * f, GKeyFile * kf)
if (desc) {
KeyFileGroupName kfg;
kfg.group_name = name[0];
kfg.group_name = g_file_get_path (f);
kfg.kf = kf;
gst_structure_foreach (desc,
(GstStructureForeachFunc) _add_description, &kfg);
gst_structure_free (desc);
} else {
g_key_file_set_string (kf, name[0], "noinfo", "nothing");
g_key_file_set_string (kf, path, "noinfo", "nothing");
}
g_list_free_full (structures, (GDestroyNotify) gst_structure_free);
g_strfreev (name);
ret = TRUE;
}
g_free (fname);
g_free (path);
return ret;
}

View file

@ -314,6 +314,14 @@ class GstValidatePipelineTestsGenerator(GstValidateTestsGenerator):
uri_minfo_special_scenarios, scenarios)
def populate_tests(self, uri_minfo_special_scenarios, scenarios):
special_scenarios = []
for description in self._pipelines_descriptions:
for s in description.get('extra_data', {}).get('scenarios', []):
if os.path.isabs(s):
special_scenarios.append(s)
self.test_manager.scenarios_manager.discover_scenarios(special_scenarios)
for description in self._pipelines_descriptions:
pipeline = description['pipeline']
extra_data = description.get('extra_data', {})

View file

@ -2187,7 +2187,8 @@ class Scenario(object):
class ScenarioManager(Loggable):
_instance = None
all_scenarios = []
system_scenarios = []
special_scenarios = {}
FILE_EXTENSION = "scenario"
@ -2239,11 +2240,12 @@ class ScenarioManager(Loggable):
config.readfp(f)
for section in config.sections():
name = None
if scenario_paths:
for scenario_path in scenario_paths:
if section in os.path.splitext(os.path.basename(scenario_path))[0]:
if section == scenario_path:
if mfile is None:
name = section
name = os.path.basename(section).replace("." + self.FILE_EXTENSION, "")
path = scenario_path
else:
# The real name of the scenario is:
@ -2251,22 +2253,33 @@ class ScenarioManager(Loggable):
name = scenario_path.replace(mfile + ".", "").replace(
"." + self.FILE_EXTENSION, "")
path = scenario_path
break
else:
name = section
name = os.path.basename(section).replace("." + self.FILE_EXTENSION, "")
path = None
assert name
props = config.items(section)
scenarios.append(Scenario(name, props, path))
scenario = Scenario(name, props, path)
if scenario_paths:
self.special_scenarios[path] = scenario
scenarios.append(scenario)
if not scenario_paths:
self.discovered = True
self.all_scenarios.extend(scenarios)
self.system_scenarios.extend(scenarios)
return scenarios
def get_scenario(self, name):
if name is not None and os.path.isabs(name) and name.endswith(self.FILE_EXTENSION):
scenario = self.special_scenarios.get(name)
if scenario:
return scenario
scenarios = self.discover_scenarios([name])
self.special_scenarios[name] = scenarios
if scenarios:
return scenarios[0]
@ -2275,10 +2288,10 @@ class ScenarioManager(Loggable):
self.discover_scenarios()
if name is None:
return self.all_scenarios
return self.system_scenarios
try:
return [scenario for scenario in self.all_scenarios if scenario.name == name][0]
return [scenario for scenario in self.system_scenarios if scenario.name == name][0]
except IndexError:
self.warning("Scenario: %s not found" % name)
return None