From 4bb264815423517d722c339770ba60a208e84662 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sun, 25 Nov 2018 11:36:06 -0300 Subject: [PATCH] validate: launcher: Add a way to load pipeline tests from a scenario --- validate/launcher/apps/gstvalidate.py | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/validate/launcher/apps/gstvalidate.py b/validate/launcher/apps/gstvalidate.py index d44733de45..2ab231bd59 100644 --- a/validate/launcher/apps/gstvalidate.py +++ b/validate/launcher/apps/gstvalidate.py @@ -26,6 +26,7 @@ import shlex import socket import subprocess import configparser +import json from launcher.loggable import Loggable from launcher.baseclasses import GstValidateTest, Test, \ @@ -174,6 +175,34 @@ class GstValidatePipelineTestsGenerator(GstValidateTestsGenerator): self._pipelines_descriptions = pipelines_descriptions self._valid_scenarios = valid_scenarios + @classmethod + def from_json(self, test_manager, json_file): + with open(json_file, 'r') as f: + descriptions = json.load(f) + + name = os.path.basename(json_file).replace('.json', '') + pipelines_descriptions = [] + for test_name, defs in descriptions.items(): + desc = [test_name] + pipeline = defs['pipeline'] + scenarios = [] + for scenario in defs['scenarios']: + scenario_name = scenario_file = scenario['name'] + actions = scenario.get('actions') + if actions: + scenario_dir = os.path.join( + test_manager.options.privatedir, name, test_name) + scenario_file = os.path.join( + scenario_dir, scenario_name + '.scenario') + os.makedirs(scenario_dir, exist_ok=True) + with open(scenario_file, 'w') as f: + f.write('\n'.join(actions) + '\n') + scenarios.append(scenario_file) + extra_datas = {'scenarios': scenarios} + pipelines_descriptions.append([test_name, pipeline, extra_datas]) + + return GstValidatePipelineTestsGenerator(name, test_manager, pipelines_descriptions=pipelines_descriptions) + def get_fname(self, scenario, protocol=None, name=None): if name is None: name = self.name