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
=== modified file 'lava_test/core/providers.py'
--- lava_test/core/providers.py 2011-09-27 20:27:39 +0000
+++ lava_test/core/providers.py 2011-10-13 10:35:26 +0000
@@ -26,6 +26,7 @@
2626
27 _builtin_tests = [27 _builtin_tests = [
28 'bootchart',28 'bootchart',
29 'insanity',
29 'firefox',30 'firefox',
30 'glmemperf',31 'glmemperf',
31 'gmpbench',32 'gmpbench',
3233
=== added file 'lava_test/test_definitions/insanity.py'
--- lava_test/test_definitions/insanity.py 1970-01-01 00:00:00 +0000
+++ lava_test/test_definitions/insanity.py 2011-10-13 10:35:26 +0000
@@ -0,0 +1,141 @@
1# Copyright (c) 2010 Linaro
2#
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.
7#
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.
12#
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/>.
15#
16
17import os
18import re
19import subprocess
20import simplejson
21import gzip
22import base64
23
24from lava_test.core.installers import TestInstaller
25from lava_test.core.parsers import TestParser
26from lava_test.core.runners import TestRunner
27from lava_test.core.tests import Test
28
29
30MAX_TEST_CASE_ID_LEN = 100
31MAX_ATTR_KEY_LEN = 32
32MAX_ATTR_VAL_LEN = 512
33
34MAX_ATTACHMENT_SIZE = 10 * 1024 * 1024
35
36SETTINGS = "/usr/share/insanity/web/settings.py"
37
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.
40RUNSTEPS = ["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",
47 ]
48
49class InsanityParser(TestParser):
50 def parse(self, artifacts):
51 filename = "testoutput.log"
52 with open(filename, 'r') as stream:
53 while not stream.readline().startswith("//////////"):
54 pass
55 results = simplejson.load(stream)
56
57 self._results = results
58 self.fixresults({"pass": "pass", "fail": "fail",
59 "skip": "skip", "expected-failure": "pass"})
60 self.fixlengths()
61 self.attach_logfiles()
62
63
64 def fixlengths(self):
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:
68 t["test_case_id"] = \
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:
74 attributes.pop(k)
75 # start includes namespace info
76 k = k[:MAX_ATTR_KEY_LEN]
77 attributes[k] = v
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:]
81
82
83 def attach_logfiles(self):
84 attachments = []
85 mime_type = "text/plain"
86 total_attachment_size = 0
87
88 for test in self.results["test_results"]:
89 pathname = test.get("log_filename", "")
90 if not pathname:
91 continue
92 if not os.path.exists(pathname):
93 print "%r not found: skipping." % pathname
94 continue
95
96 if pathname.endswith(".gz"):
97 stream = gzip.open(pathname, 'rb')
98 else:
99 stream = open(pathname)
100
101 output_text = stream.read()
102 stream.close()
103
104 total_attachment_size += len(output_text)
105 if total_attachment_size > MAX_ATTACHMENT_SIZE:
106 break
107
108 attachments.append({
109 "pathname": pathname,
110 "mime_type": mime_type,
111 "content": base64.standard_b64encode(output_text)
112 })
113
114 self.results.setdefault("attachments", []).extend(attachments)
115
116 def fixresults(self, fixupdict):
117 """Convert results to a known, standard format
118
119 pass it a dict of keys/values to replace
120 For instance:
121 {"TPASS":"pass", "TFAIL":"fail"}
122 This is really only used for qualitative tests
123 """
124 for t in self.results['test_results']:
125 if t.has_key("result"):
126 t['result'] = fixupdict[t['result']]
127
128inst = 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
137 ])
138run = TestRunner(RUNSTEPS)
139parse = InsanityParser("")
140
141testobj = Test(test_id="insanity", installer=inst, runner=run, parser=parse)

Subscribers

People subscribed via source and target branches