validate: move look_for_file_in_source_dir and get_valgrind_suppression_file to utils

Reviewers: thiblahute

Differential Revision: http://phabricator.freedesktop.org/D130
This commit is contained in:
Guillaume Desmottes 2015-04-27 13:25:44 +02:00 committed by Thibault Saunier
parent 6a89662da6
commit c5c39d88b1
2 changed files with 27 additions and 16 deletions

View file

@ -25,7 +25,6 @@ import re
import time import time
import utils import utils
import signal import signal
import config
import urlparse import urlparse
import subprocess import subprocess
import threading import threading
@ -37,7 +36,7 @@ from loggable import Loggable
import xml.etree.cElementTree as ET import xml.etree.cElementTree as ET
from utils import mkdir, Result, Colors, printc, DEFAULT_TIMEOUT, GST_SECOND, \ 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 # The factor by which we increase the hard timeout when running inside
# Valgrind # Valgrind
@ -401,7 +400,7 @@ class GstValidateTest(Test):
# application which is using rpath instead of libtool's wrappers. It's # application which is using rpath instead of libtool's wrappers. It's
# slightly faster to start and will not confuse valgrind. # slightly faster to start and will not confuse valgrind.
debug = '%s-debug' % application_name 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: if p:
application_name = p application_name = p
@ -626,23 +625,11 @@ class GstValidateTest(Test):
return position 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): def get_valgrind_suppression_file(self, subdir, name):
# Are we running from sources? p = get_valgrind_suppression_file(subdir, name)
p = self.look_for_file_in_source_dir(subdir, name)
if p: if p:
return 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) self.error("Could not find any %s file" % name)
def get_valgrind_suppressions(self): def get_valgrind_suppressions(self):

View file

@ -18,6 +18,7 @@
# Boston, MA 02110-1301, USA. # Boston, MA 02110-1301, USA.
""" Some utilies. """ """ Some utilies. """
import config
import os import os
import re import re
import sys import sys
@ -181,6 +182,29 @@ def TIME_ARGS(time):
(time / GST_SECOND) % 60, (time / GST_SECOND) % 60,
time % GST_SECOND) 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 # # Some utilities to parse gst-validate output #
# #