1
# Copyright (c) 2010 Linaro
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 3 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
24
from lava_test.core.installers import TestInstaller
25
from lava_test.core.parsers import TestParser
26
from lava_test.core.runners import TestRunner
27
from lava_test.core.tests import Test
30
MAX_TEST_CASE_ID_LEN = 100
32
MAX_ATTR_VAL_LEN = 512
34
MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024
36
SETTINGS = "/usr/share/insanity/web/settings.py"
38
# Re-running failing tests is expensive, as it produces very large log files.
39
# Only remove --no-reruns if you have a small number of failing tests.
40
RUNSTEPS = ["rm -f testrun.db",
41
"gst-media-test --no-reruns -t playbin-test --settings %s" % SETTINGS,
42
"gst-media-test --no-reruns -t full-gnlfilesource-scenario " \
43
"--settings %s" % SETTINGS,
44
"gst-media-test --no-reruns -t simple-encoder-scenario",
45
"echo ////////////////////",
46
"insanity-dumpresults-json testrun.db --all",
49
class InsanityParser(TestParser):
50
def parse(self, artifacts):
51
filename = "testoutput.log"
52
with open(filename, 'r') as stream:
53
while not stream.readline().startswith("//////////"):
55
results = simplejson.load(stream)
57
self._results = results
58
self.fixresults({"pass": "pass", "fail": "fail",
59
"skip": "skip", "expected-failure": "pass"})
61
self.attach_logfiles()
65
for t in self.results['test_results']:
66
if t.has_key("test_case_id"):
67
if len(t["test_case_id"]) > MAX_TEST_CASE_ID_LEN:
69
t["test_case_id"][-MAX_TEST_CASE_ID_LEN:]
70
if t.has_key("attributes"):
71
attributes = t["attributes"]
72
for k, v in attributes.items():
73
if len(k) > MAX_ATTR_KEY_LEN:
75
# start includes namespace info
76
k = k[:MAX_ATTR_KEY_LEN]
78
if len(v) > MAX_ATTR_VAL_LEN:
79
# end tends to be more useful than the start.
80
attributes[k] = v[-MAX_ATTR_VAL_LEN:]
83
def attach_logfiles(self):
85
mime_type = "text/plain"
86
total_attachment_size = 0
88
for test in self.results["test_results"]:
89
pathname = test.get("log_filename", "")
92
if not os.path.exists(pathname):
93
print "%r not found: skipping." % pathname
96
if pathname.endswith(".gz"):
97
stream = gzip.open(pathname, 'rb')
99
stream = open(pathname)
101
output_text = stream.read()
104
total_attachment_size += len(output_text)
105
if total_attachment_size > MAX_ATTACHMENT_SIZE:
109
"pathname": pathname,
110
"mime_type": mime_type,
111
"content": base64.standard_b64encode(output_text)
114
self.results.setdefault("attachments", []).extend(attachments)
116
def fixresults(self, fixupdict):
117
"""Convert results to a known, standard format
119
pass it a dict of keys/values to replace
121
{"TPASS":"pass", "TFAIL":"fail"}
122
This is really only used for qualitative tests
124
for t in self.results['test_results']:
125
if t.has_key("result"):
126
t['result'] = fixupdict[t['result']]
128
inst = TestInstaller(deps=["insanity-tools",
129
"samplemedia-minimal",
130
"gstreamer0.10-plugins-base", # videotestsrc et al
131
"gstreamer0.10-plugins-good", # matroskademux et al
132
"gstreamer0.10-plugins-bad", #
133
"gstreamer0.10-plugins-ugly", # asfdemux et al
134
"gstreamer0.10-ffmpeg", # ffdec_h264 et al
135
"gstreamer0.10-gnonlin", # gnlfilesource
136
"gdb", # debugging backtraces
138
run = TestRunner(RUNSTEPS)
139
parse = InsanityParser("")
141
testobj = Test(test_id="insanity", installer=inst, runner=run, parser=parse)