From c5c39d88b18fbfa08a4c5652cbc4905741ab9e3f Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 27 Apr 2015 13:25:44 +0200 Subject: [PATCH] validate: move look_for_file_in_source_dir and get_valgrind_suppression_file to utils Reviewers: thiblahute Differential Revision: http://phabricator.freedesktop.org/D130 --- validate/launcher/baseclasses.py | 19 +++---------------- validate/launcher/utils.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/validate/launcher/baseclasses.py b/validate/launcher/baseclasses.py index 46ffd9ee11..4d28182075 100644 --- a/validate/launcher/baseclasses.py +++ b/validate/launcher/baseclasses.py @@ -25,7 +25,6 @@ import re import time import utils import signal -import config import urlparse import subprocess import threading @@ -37,7 +36,7 @@ from loggable import Loggable import xml.etree.cElementTree as ET from utils import mkdir, Result, Colors, printc, DEFAULT_TIMEOUT, GST_SECOND, \ - Protocols + Protocols, look_for_file_in_source_dir, get_valgrind_suppression_file # The factor by which we increase the hard timeout when running inside # Valgrind @@ -401,7 +400,7 @@ class GstValidateTest(Test): # application which is using rpath instead of libtool's wrappers. It's # slightly faster to start and will not confuse valgrind. debug = '%s-debug' % application_name - p = self.look_for_file_in_source_dir('tools', debug) + p = look_for_file_in_source_dir('tools', debug) if p: application_name = p @@ -626,23 +625,11 @@ class GstValidateTest(Test): return position - def look_for_file_in_source_dir(self, subdir, name): - root_dir = os.path.abspath(os.path.dirname(os.path.join(os.path.dirname(os.path.abspath(__file__))))) - p = os.path.join(root_dir, subdir, name) - if os.path.exists(p): - return p - def get_valgrind_suppression_file(self, subdir, name): - # Are we running from sources? - p = self.look_for_file_in_source_dir(subdir, name) + p = get_valgrind_suppression_file(subdir, name) if p: return p - # Look in system data dirs - p = os.path.join(config.DATADIR, 'gstreamer-1.0', 'validate', name) - if os.path.exists(p): - return p - self.error("Could not find any %s file" % name) def get_valgrind_suppressions(self): diff --git a/validate/launcher/utils.py b/validate/launcher/utils.py index 30a9c9b892..e9a78ea019 100644 --- a/validate/launcher/utils.py +++ b/validate/launcher/utils.py @@ -18,6 +18,7 @@ # Boston, MA 02110-1301, USA. """ Some utilies. """ +import config import os import re import sys @@ -181,6 +182,29 @@ def TIME_ARGS(time): (time / GST_SECOND) % 60, time % GST_SECOND) + +def look_for_file_in_source_dir(subdir, name): + root_dir = os.path.abspath(os.path.dirname(os.path.join(os.path.dirname(os.path.abspath(__file__))))) + p = os.path.join(root_dir, subdir, name) + if os.path.exists(p): + return p + + return None + + +def get_valgrind_suppression_file(subdir, name): + # Are we running from sources? + p = look_for_file_in_source_dir(subdir, name) + if p: + return p + + # Look in system data dirs + p = os.path.join(config.DATADIR, 'gstreamer-1.0', 'validate', name) + if os.path.exists(p): + return p + + return None + # # Some utilities to parse gst-validate output # #