Merge lp:~le-chi-thu/lava-test/insanity_2 into lp:lava-test/0.0

Proposed by Le Chi Thu
Status: Merged
Merged at revision: 101
Proposed branch: lp:~le-chi-thu/lava-test/insanity_2
Merge into: lp:lava-test/0.0
Diff against target: 157 lines (+142/-0)
2 files modified
lava_test/core/providers.py (+1/-0)
lava_test/test_definitions/insanity.py (+141/-0)
To merge this branch: bzr merge lp:~le-chi-thu/lava-test/insanity_2
Reviewer Review Type Date Requested Status
Paul Larson (community) Approve
Review via email: mp+79249@code.launchpad.net

Description of the change

Updated after comments on insanity branch (that branch is deleted). Moved back the fixresults(self, fixupdict) to insanity.py and sync with the trunk.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lava_test/core/providers.py'
2--- lava_test/core/providers.py 2011-09-27 20:27:39 +0000
3+++ lava_test/core/providers.py 2011-10-13 10:35:26 +0000
4@@ -26,6 +26,7 @@
5
6 _builtin_tests = [
7 'bootchart',
8+ 'insanity',
9 'firefox',
10 'glmemperf',
11 'gmpbench',
12
13=== added file 'lava_test/test_definitions/insanity.py'
14--- lava_test/test_definitions/insanity.py 1970-01-01 00:00:00 +0000
15+++ lava_test/test_definitions/insanity.py 2011-10-13 10:35:26 +0000
16@@ -0,0 +1,141 @@
17+# Copyright (c) 2010 Linaro
18+#
19+# This program is free software: you can redistribute it and/or modify
20+# it under the terms of the GNU General Public License as published by
21+# the Free Software Foundation, either version 3 of the License, or
22+# (at your option) any later version.
23+#
24+# This program is distributed in the hope that it will be useful,
25+# but WITHOUT ANY WARRANTY; without even the implied warranty of
26+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27+# GNU General Public License for more details.
28+#
29+# You should have received a copy of the GNU General Public License
30+# along with this program. If not, see <http://www.gnu.org/licenses/>.
31+#
32+
33+import os
34+import re
35+import subprocess
36+import simplejson
37+import gzip
38+import base64
39+
40+from lava_test.core.installers import TestInstaller
41+from lava_test.core.parsers import TestParser
42+from lava_test.core.runners import TestRunner
43+from lava_test.core.tests import Test
44+
45+
46+MAX_TEST_CASE_ID_LEN = 100
47+MAX_ATTR_KEY_LEN = 32
48+MAX_ATTR_VAL_LEN = 512
49+
50+MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024
51+
52+SETTINGS = "/usr/share/insanity/web/settings.py"
53+
54+# Re-running failing tests is expensive, as it produces very large log files.
55+# Only remove --no-reruns if you have a small number of failing tests.
56+RUNSTEPS = ["rm -f testrun.db",
57+ "gst-media-test --no-reruns -t playbin-test --settings %s" % SETTINGS,
58+ "gst-media-test --no-reruns -t full-gnlfilesource-scenario " \
59+ "--settings %s" % SETTINGS,
60+ "gst-media-test --no-reruns -t simple-encoder-scenario",
61+ "echo ////////////////////",
62+ "insanity-dumpresults-json testrun.db --all",
63+ ]
64+
65+class InsanityParser(TestParser):
66+ def parse(self, artifacts):
67+ filename = "testoutput.log"
68+ with open(filename, 'r') as stream:
69+ while not stream.readline().startswith("//////////"):
70+ pass
71+ results = simplejson.load(stream)
72+
73+ self._results = results
74+ self.fixresults({"pass": "pass", "fail": "fail",
75+ "skip": "skip", "expected-failure": "pass"})
76+ self.fixlengths()
77+ self.attach_logfiles()
78+
79+
80+ def fixlengths(self):
81+ for t in self.results['test_results']:
82+ if t.has_key("test_case_id"):
83+ if len(t["test_case_id"]) > MAX_TEST_CASE_ID_LEN:
84+ t["test_case_id"] = \
85+ t["test_case_id"][-MAX_TEST_CASE_ID_LEN:]
86+ if t.has_key("attributes"):
87+ attributes = t["attributes"]
88+ for k, v in attributes.items():
89+ if len(k) > MAX_ATTR_KEY_LEN:
90+ attributes.pop(k)
91+ # start includes namespace info
92+ k = k[:MAX_ATTR_KEY_LEN]
93+ attributes[k] = v
94+ if len(v) > MAX_ATTR_VAL_LEN:
95+ # end tends to be more useful than the start.
96+ attributes[k] = v[-MAX_ATTR_VAL_LEN:]
97+
98+
99+ def attach_logfiles(self):
100+ attachments = []
101+ mime_type = "text/plain"
102+ total_attachment_size = 0
103+
104+ for test in self.results["test_results"]:
105+ pathname = test.get("log_filename", "")
106+ if not pathname:
107+ continue
108+ if not os.path.exists(pathname):
109+ print "%r not found: skipping." % pathname
110+ continue
111+
112+ if pathname.endswith(".gz"):
113+ stream = gzip.open(pathname, 'rb')
114+ else:
115+ stream = open(pathname)
116+
117+ output_text = stream.read()
118+ stream.close()
119+
120+ total_attachment_size += len(output_text)
121+ if total_attachment_size > MAX_ATTACHMENT_SIZE:
122+ break
123+
124+ attachments.append({
125+ "pathname": pathname,
126+ "mime_type": mime_type,
127+ "content": base64.standard_b64encode(output_text)
128+ })
129+
130+ self.results.setdefault("attachments", []).extend(attachments)
131+
132+ def fixresults(self, fixupdict):
133+ """Convert results to a known, standard format
134+
135+ pass it a dict of keys/values to replace
136+ For instance:
137+ {"TPASS":"pass", "TFAIL":"fail"}
138+ This is really only used for qualitative tests
139+ """
140+ for t in self.results['test_results']:
141+ if t.has_key("result"):
142+ t['result'] = fixupdict[t['result']]
143+
144+inst = TestInstaller(deps=["insanity-tools",
145+ "samplemedia-minimal",
146+ "gstreamer0.10-plugins-base", # videotestsrc et al
147+ "gstreamer0.10-plugins-good", # matroskademux et al
148+ "gstreamer0.10-plugins-bad", #
149+ "gstreamer0.10-plugins-ugly", # asfdemux et al
150+ "gstreamer0.10-ffmpeg", # ffdec_h264 et al
151+ "gstreamer0.10-gnonlin", # gnlfilesource
152+ "gdb", # debugging backtraces
153+ ])
154+run = TestRunner(RUNSTEPS)
155+parse = InsanityParser("")
156+
157+testobj = Test(test_id="insanity", installer=inst, runner=run, parser=parse)

Subscribers

People subscribed via source and target branches