/usr/share/pyshared/insanity/tests/scenarios/gnltest.py is in python-insanity 0.0+git20110920.4750a8e8-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | # GStreamer QA system
#
# tests/scenario/gnltest.py
#
# Copyright (c) 2007, Edward Hervey <bilboed@bilboed.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
"""
Full gnonlin scenario
"""
from insanity.scenario import Scenario
from insanity.tests.gnltest import GnlFileSourceTest, GnlFullFileSourceTest
from insanity.tests.typefind import TypeFindTest
import gst
class FullGnlFileSourceScenario(Scenario):
__test_description__ = """
Runs gnlfilesource test on each media stream of the given uri
"""
__test_full_description__ = """
Will analyze a given uri (using typefind-test) and then add a gnltest
for each contained stream.
"""
__test_name__ = "full-gnlfilesource-scenario"
_subtest_type = GnlFileSourceTest
def setUp(self):
if not Scenario.setUp(self):
return False
self.__doneTypeFindTest = False
# add the initial typefind test
self.addSubTest(TypeFindTest, self.arguments)
return True
def subTestDone(self, test):
# if we've already seen the typefind test, return True
if self.__doneTypeFindTest:
return True
# let's have a look at the streams
infos = test.getExtraInfo()
streamsduration = {}
streamscaps = {}
for x,y in infos.iteritems():
if x.startswith('streams.'):
nm = x.split('.')[1]
if x.endswith('.duration'):
streamsduration[nm] = y
elif x.endswith('.caps'):
streamscaps[nm] = y
if streamsduration == {}:
return False
if not 'total-uri-duration' in infos.keys():
return False
checks = dict(test.getCheckList())
for item in ['duration-available', 'no-timeout', 'subprocess-exited-normally']:
if not item in checks.keys():
return False
if checks[item] == False:
return False
# duration is in ms
uriduration = infos['total-uri-duration']
if uriduration <= 0:
return False
# pick a duration/media-start which is within the given uri duration
mstart = uriduration / 2
duration = 1000 # 1s
if uriduration < 2000: # 2s
duration = mstart
validcaps = [caps for x, caps in streamscaps.iteritems() if 'o/x-raw-' in caps]
if validcaps == []:
return False
validcaps.sort()
i = 1
# finally, add a GnlFileSourceTest for each stream
for streamcap in validcaps:
args = self.arguments.copy()
args["caps-string"] = streamcap
args["media-start"] = mstart
args["duration"] = duration
self.addSubTest(self._subtest_type, args,
instance_name="stream%s.from_middle" % i)
# ... and also starting from 0 ...
args = self.arguments.copy()
args["caps-string"] = streamcap
args["media-start"] = 0
args["duration"] = duration
self.addSubTest(self._subtest_type, args,
instance_name="stream%s.from_start" % i)
# ... and also going to the end
args = self.arguments.copy()
args["caps-string"] = streamcap
args["media-start"] = uriduration - duration
args["duration"] = duration
self.addSubTest(self._subtest_type, args,
instance_name="stream%s.from_near_end" % i)
i += 1
self.__doneTypeFindTest = True
return True
def _extractRawStreams(self, streams):
res = []
for stream in streams:
padname, length, caps = stream
if caps.startswith("audio/x-raw-"):
res.append((padname, length, "audio/x-raw-int;audio/x-raw-float"))
elif caps.startswith("video/x-raw-"):
res.append((padname, length, "video/x-raw-yuv;video/x-raw-rgb"))
return res
class TotalGnlFileSourceScenario(FullGnlFileSourceScenario):
__test_name__ = "complete-gnlfilesource-scenario"
__test_description__ = ""
_subtest_type = GnlFullFileSourceTest
|