Merge lp:~sylvain-pineau/checkbox/gpu_test_raring into lp:checkbox

Proposed by Sylvain Pineau
Status: Merged
Approved by: Daniel Manrique
Approved revision: 2095
Merged at revision: 2097
Proposed branch: lp:~sylvain-pineau/checkbox/gpu_test_raring
Merge into: lp:checkbox
Diff against target: 271 lines (+81/-77)
3 files modified
debian/changelog (+5/-0)
jobs/suspend.txt.in (+2/-6)
scripts/gpu_test (+74/-71)
To merge this branch: bzr merge lp:~sylvain-pineau/checkbox/gpu_test_raring
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+161792@code.launchpad.net

Commit message

scripts/gpu_test: Raring version

Description of the change

scripts/gpu_test: Raring version

Remove the need of running the script with the root user,
Restore the workspaces switch and the HTML5 video playback
Remove the extra suspend/resume

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

Looks good and works as advertised. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-04-30 14:37:48 +0000
3+++ debian/changelog 2013-05-01 08:07:31 +0000
4@@ -5,6 +5,11 @@
5 a bug on ARM. Modified output so most of it is redirected to stderr for
6 fail cases, we don't need that much for success cases. (LP: #1078897)
7
8+ [ Sylvain Pineau ]
9+ * jobs/suspend.txt.in, scripts/gpu_test: Remove the need of running the script
10+ with the root user, restore the workspaces switch and the HTML5 video
11+ playback ; remove the extra suspend/resume (LP: #1172851)
12+
13 -- Brendan Donegan <brendan.donegan@canonical.com> Fri, 26 Apr 2013 18:23:03 +0100
14
15 checkbox (0.16) raring; urgency=low
16
17=== modified file 'jobs/suspend.txt.in'
18--- jobs/suspend.txt.in 2013-04-24 17:17:25 +0000
19+++ jobs/suspend.txt.in 2013-05-01 08:07:31 +0000
20@@ -851,21 +851,17 @@
21 plugin: shell
22 name: suspend/gpu_lockup_after_suspend
23 requires:
24- package.name == 'fwts'
25 package.name == 'wmctrl'
26 package.name == 'mesa-utils'
27 depends: suspend/suspend_advanced_auto
28-user: root
29 command: gpu_test
30 _description:
31 PURPOSE:
32- Do some challenging operations, suspend the system, do more challenging
33- operations - then check for lockup on the GPU
34+ Do some challenging operations then check for lockup on the GPU
35 STEPS:
36 1. Create 2 glxgears windows and move them quickly
37- 2. Switch workspaces/viewports with wmctrl
38+ 2. Switch workspaces with wmctrl
39 3. Launch an HTML5 video playback in firefox
40- 4. Suspend/resume
41 VERIFICATION:
42 After a 60s workload, check kern.log for reported GPU errors
43
44
45=== modified file 'scripts/gpu_test'
46--- scripts/gpu_test 2012-08-24 07:30:14 +0000
47+++ scripts/gpu_test 2013-05-01 08:07:31 +0000
48@@ -1,12 +1,36 @@
49 #!/usr/bin/python3
50-
51+# Copyright 2013 Canonical Ltd.
52+# Written by:
53+# Sylvain Pineau <sylvain.pineau@canonical.com>
54+#
55+# This program is free software: you can redistribute it and/or modify
56+# it under the terms of the GNU General Public License version 3,
57+# as published by the Free Software Foundation.
58+#
59+# This program is distributed in the hope that it will be useful,
60+# but WITHOUT ANY WARRANTY; without even the implied warranty of
61+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
62+# GNU General Public License for more details.
63+#
64+# You should have received a copy of the GNU General Public License
65+# along with this program. If not, see <http://www.gnu.org/licenses/>.
66+
67+"""
68+Script checking gpu lockups.
69+
70+Several threads are started to exercise the GPU in ways that can cause gpu
71+lockups.
72+Inspired by the workload directory of the xdiagnose package.
73+"""
74+
75+import os
76 import re
77-import os
78+import subprocess
79 import sys
80 import time
81-import subprocess
82+from gi.repository import Gio
83+from math import cos, sin
84 from threading import Thread
85-from math import cos, sin
86
87
88 class GlxThread(Thread):
89@@ -44,7 +68,8 @@
90 coords = "%s,%s" % (x, y)
91 subprocess.call(
92 'wmctrl -i -r %s -e 0,%s,-1,-1' % (self.id, coords),
93- shell=True)
94+ shell=True
95+ )
96 time.sleep(0.002 * self.offset)
97 if self.cancel:
98 return
99@@ -55,27 +80,6 @@
100 Start a thread performing fast workspace switches
101 """
102
103- def __init__(self, size):
104- Thread.__init__(self)
105- self.size = size
106- self.cancel = False
107-
108- def run(self):
109- while(1):
110- for i in range(self.size):
111- subprocess.call('wmctrl -s %s' % i, shell=True)
112- time.sleep(0.5)
113- if self.cancel:
114- # Switch back to workspace #1
115- subprocess.call('wmctrl -s 0', shell=True)
116- return
117-
118-
119-class ChangeViewport(Thread):
120- """
121- Start a thread performing fast viewport switches
122- """
123-
124 def __init__(self, hsize, vsize, xsize, ysize):
125 Thread.__init__(self)
126 self.hsize = hsize
127@@ -93,7 +97,7 @@
128 shell=True)
129 time.sleep(0.5)
130 if self.cancel:
131- # Switch back to viewport #1
132+ # Switch back to workspace #1
133 subprocess.call('wmctrl -o 0,0', shell=True)
134 return
135
136@@ -104,48 +108,31 @@
137 """
138
139 def run(self):
140- html5_path = os.path.join(os.getenv('CHECKBOX_SHARE', 'data/websites/html5_video.html'))
141+ html5_path = os.path.join(
142+ os.getenv('CHECKBOX_SHARE'),
143+ 'data/websites/html5_video.html')
144 subprocess.call(
145- 'sudo -H -u %s xdg-open %s' % (os.getenv('SUDO_USER'), html5_path),
146+ 'xdg-open %s' % html5_path,
147 stdout=open(os.devnull, 'w'),
148 stderr=subprocess.STDOUT,
149 shell=True)
150
151 def terminate(self):
152- subprocess.call('wmctrl -c firefox', shell=True)
153-
154-
155-def pidof(name):
156- for pid in os.listdir("/proc"):
157- if not pid.isdigit():
158- continue
159- try:
160- exe = os.readlink(os.path.join("/proc", pid, "exe"))
161- except OSError:
162- continue
163- if os.path.basename(exe) == name:
164- return int(pid)
165- return 0
166-
167-
168-def is_unity_2d_running():
169- return pidof("unity-2d-panel") > 0
170-
171-
172-def check_gpu():
173- f = open('/var/log/kern.log', 'r')
174- with f:
175+ subprocess.call("pkill firefox", shell=True)
176+
177+
178+def check_gpu(log=None):
179+ if not log:
180+ log = '/var/log/kern.log'
181+ with open(log, 'r') as f:
182 if re.findall(r'gpu\s+hung', f.read(), flags=re.I):
183 print("GPU hung Detected")
184- sys.exit(1)
185+ return 1
186
187
188 def main():
189- if not (os.geteuid() == 0):
190- print("Must be run as root.")
191+ if check_gpu():
192 return 1
193-
194- check_gpu()
195 GlxWindows = []
196 GlxRotate = []
197 subprocess.call("pkill 'glxgears|firefox'", shell=True)
198@@ -153,6 +140,8 @@
199 Html5Video = Html5VideoThread()
200 Html5Video.start()
201
202+ source = Gio.SettingsSchemaSource.get_default()
203+
204 for i in range(2):
205 GlxWindows.append(GlxThread())
206 GlxWindows[i].start()
207@@ -169,28 +158,33 @@
208 GlxRotate.append(RotateGlxThread(GlxWindows[i].id, i + 1))
209 GlxRotate[i].start()
210
211- if is_unity_2d_running():
212- size = int(subprocess.check_output(
213- 'gconftool --get /apps/metacity/general/num_workspaces',
214- shell=True))
215- DesktopSwitch = ChangeWorkspace(size)
216+ hsize = vsize = 2
217+ hsize_ori = vsize_ori = None
218+ if source.lookup("org.compiz.core", True):
219+ settings = Gio.Settings(
220+ "org.compiz.core",
221+ "/org/compiz/profiles/unity/plugins/core/"
222+ )
223+ hsize_ori = settings.get_int("hsize")
224+ vsize_ori = settings.get_int("vsize")
225+ settings.set_int("hsize", hsize)
226+ settings.set_int("vsize", vsize)
227+ time.sleep(5)
228 else:
229- (x_res, y_res) = re.search(b'DG:\s+(\d+)x(\d+)',
230- subprocess.check_output('wmctrl -d', shell=True)).groups()
231 hsize = int(subprocess.check_output(
232 'gconftool --get /apps/compiz-1/general/screen0/options/hsize',
233 shell=True))
234 vsize = int(subprocess.check_output(
235 'gconftool --get /apps/compiz-1/general/screen0/options/vsize',
236 shell=True))
237- DesktopSwitch = ChangeViewport(
238- hsize, vsize, int(x_res) // hsize, int(y_res) // vsize)
239+ (x_res, y_res) = re.search(
240+ b'DG:\s+(\d+)x(\d+)',
241+ subprocess.check_output('wmctrl -d', shell=True)).groups()
242+ DesktopSwitch = ChangeWorkspace(
243+ hsize, vsize, int(x_res) // hsize, int(y_res) // vsize)
244 DesktopSwitch.start()
245
246- time.sleep(20)
247- # Suspend/resume the SUT
248- subprocess.call('fwts -q s3 --s3-sleep-delay=30', shell=True)
249- time.sleep(20)
250+ time.sleep(35)
251
252 for i in range(2):
253 GlxRotate[i].cancel = True
254@@ -198,7 +192,16 @@
255 DesktopSwitch.cancel = True
256 time.sleep(10)
257 Html5Video.terminate()
258- check_gpu()
259+ if check_gpu():
260+ return 1
261+
262+ if source.lookup("org.compiz.core", True):
263+ settings = Gio.Settings(
264+ "org.compiz.core",
265+ "/org/compiz/profiles/unity/plugins/core/")
266+ settings.set_int("hsize", hsize_ori)
267+ settings.set_int("vsize", vsize_ori)
268+ Gio.Settings.sync()
269
270 if __name__ == '__main__':
271 sys.exit(main())

Subscribers

People subscribed via source and target branches