From 9b69bcad0861ccd911b9efcab1b8371313da5a18 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 25 Jan 2019 22:27:07 -0300 Subject: [PATCH] validate:launcher: Handle launching launching a sub launcher If you use validate-launcher in a meson testsuite, those test now gets integrated as one unique testsuite (with a pretty long namespace). --- validate/launcher/apps/gstcheck.py | 38 +++++++++++++++++++++++++++++++++++--- validate/launcher/baseclasses.py | 5 ++++- validate/launcher/main.py | 7 ++++++- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/validate/launcher/apps/gstcheck.py b/validate/launcher/apps/gstcheck.py index 6d5c238..c29a831 100644 --- a/validate/launcher/apps/gstcheck.py +++ b/validate/launcher/apps/gstcheck.py @@ -19,6 +19,7 @@ import argparse import json import os +import sys import re import pickle import platform @@ -30,6 +31,7 @@ import concurrent.futures as conc from launcher import config from launcher.utils import printc, Colors +from launcher.main import setup_launcher_from_args class MesonTest(Test): @@ -166,12 +168,35 @@ class MesonTestsManager(TestsManager): mesontests = self.get_meson_tests() for test in mesontests: - self.add_test(MesonTest(self.get_test_name(test), - self.options, self.reporter, test)) + if not self.setup_tests_from_sublauncher(test): + self.add_test(MesonTest(self.get_test_name(test), + self.options, self.reporter, test)) self._registered = True return self.tests + def setup_tests_from_sublauncher(self, test): + cmd = test['cmd'] + binary = cmd[0] + sublauncher_tests = set() + if binary != sys.argv[0]: + return sublauncher_tests + + res, _, tests_launcher = setup_launcher_from_args(cmd[1:], main_options=self.options) + if res is False: + return sublauncher_tests + + for sublauncher_test in tests_launcher.list_tests(): + name = self.get_test_name(test) + sublauncher_tests.add(name) + + sublauncher_test.generator = None + sublauncher_test.options = self.options + sublauncher_test.classname = name + '.' + sublauncher_test.classname + self.add_test(sublauncher_test) + + return sublauncher_tests + class GstCheckTestsManager(MesonTestsManager): name = "check" @@ -268,7 +293,12 @@ class GstCheckTestsManager(MesonTestsManager): self.load_tests_info() mesontests = self.get_meson_tests() to_inspect = [] + all_sublaunchers_tests = set() for test in mesontests: + sublauncher_tests = self.setup_tests_from_sublauncher(test) + if sublauncher_tests: + all_sublaunchers_tests |= sublauncher_tests + continue binary = test['cmd'][0] test_info = self.check_binary_ts(binary) if test_info is True: @@ -296,9 +326,11 @@ class GstCheckTestsManager(MesonTestsManager): e.result() for test in mesontests: + name = self.get_test_name(test) + if name in all_sublaunchers_tests: + continue gst_tests = self.tests_info[test['cmd'][0]][1] if not gst_tests: - name = self.get_test_name(test) child_env = self.get_child_env(name) self.add_test(MesonTest(name, self.options, self.reporter, test, child_env)) diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py index 0a22a3c..e1dd6c9 100644 --- a/validate/launcher/baseclasses.py +++ b/validate/launcher/baseclasses.py @@ -592,6 +592,7 @@ class GstValidateTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer): class GstValidateListener(socketserver.BaseRequestHandler): + def handle(self): """Implements BaseRequestHandler handle method""" test = None @@ -1518,6 +1519,7 @@ class _TestsLauncher(Loggable): tester.name not in wanted_test_manager: continue + prev_testsuite_name = TestsManager.loading_testsuite if self.options.user_paths: TestsManager.loading_testsuite = tester.name tester.register_defaults() @@ -1526,7 +1528,8 @@ class _TestsLauncher(Loggable): TestsManager.loading_testsuite = testsuite.__name__ if testsuite.setup_tests(tester, self.options): loaded = True - TestsManager.loading_testsuite = None + if prev_testsuite_name: + TestsManager.loading_testsuite = prev_testsuite_name if not loaded: printc("Could not load testsuite: %s" diff --git a/validate/launcher/main.py b/validate/launcher/main.py index f0f844f..1470d62 100644 --- a/validate/launcher/main.py +++ b/validate/launcher/main.py @@ -540,7 +540,7 @@ class LauncherConfig(Loggable): return parser -def setup_launcher_from_args(args): +def setup_launcher_from_args(args, main_options=None): loggable.init("GST_VALIDATE_LAUNCHER_DEBUG", True, False) parser = LauncherConfig.create_parser() tests_launcher = _TestsLauncher() @@ -555,6 +555,11 @@ def setup_launcher_from_args(args): options = LauncherConfig() parser.parse_args(args=args, namespace=options) + if main_options: + # Override output directories and logging properties of the sub launcher. + for option in ["main_dir", "output_dir", "logsdir", "dest", "clone_dir", + "redirect_logs", "verbose"]: + setattr(options, option, getattr(main_options, option)) if not options.cleanup(): return False, None, None -- 2.7.4