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
=== modified file 'debian/changelog'
--- debian/changelog 2013-04-30 14:37:48 +0000
+++ debian/changelog 2013-05-01 08:07:31 +0000
@@ -5,6 +5,11 @@
5 a bug on ARM. Modified output so most of it is redirected to stderr for5 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) 6 fail cases, we don't need that much for success cases. (LP: #1078897)
77
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
8 -- Brendan Donegan <brendan.donegan@canonical.com> Fri, 26 Apr 2013 18:23:03 +010013 -- Brendan Donegan <brendan.donegan@canonical.com> Fri, 26 Apr 2013 18:23:03 +0100
914
10checkbox (0.16) raring; urgency=low15checkbox (0.16) raring; urgency=low
1116
=== modified file 'jobs/suspend.txt.in'
--- jobs/suspend.txt.in 2013-04-24 17:17:25 +0000
+++ jobs/suspend.txt.in 2013-05-01 08:07:31 +0000
@@ -851,21 +851,17 @@
851plugin: shell851plugin: shell
852name: suspend/gpu_lockup_after_suspend852name: suspend/gpu_lockup_after_suspend
853requires:853requires:
854 package.name == 'fwts'
855 package.name == 'wmctrl'854 package.name == 'wmctrl'
856 package.name == 'mesa-utils'855 package.name == 'mesa-utils'
857depends: suspend/suspend_advanced_auto856depends: suspend/suspend_advanced_auto
858user: root
859command: gpu_test857command: gpu_test
860_description:858_description:
861 PURPOSE:859 PURPOSE:
862 Do some challenging operations, suspend the system, do more challenging860 Do some challenging operations then check for lockup on the GPU
863 operations - then check for lockup on the GPU
864 STEPS:861 STEPS:
865 1. Create 2 glxgears windows and move them quickly862 1. Create 2 glxgears windows and move them quickly
866 2. Switch workspaces/viewports with wmctrl863 2. Switch workspaces with wmctrl
867 3. Launch an HTML5 video playback in firefox864 3. Launch an HTML5 video playback in firefox
868 4. Suspend/resume
869 VERIFICATION:865 VERIFICATION:
870 After a 60s workload, check kern.log for reported GPU errors866 After a 60s workload, check kern.log for reported GPU errors
871867
872868
=== modified file 'scripts/gpu_test'
--- scripts/gpu_test 2012-08-24 07:30:14 +0000
+++ scripts/gpu_test 2013-05-01 08:07:31 +0000
@@ -1,12 +1,36 @@
1#!/usr/bin/python31#!/usr/bin/python3
22# Copyright 2013 Canonical Ltd.
3# Written by:
4# Sylvain Pineau <sylvain.pineau@canonical.com>
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License version 3,
8# as published by the Free Software Foundation.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18"""
19Script checking gpu lockups.
20
21Several threads are started to exercise the GPU in ways that can cause gpu
22lockups.
23Inspired by the workload directory of the xdiagnose package.
24"""
25
26import os
3import re27import re
4import os28import subprocess
5import sys29import sys
6import time30import time
7import subprocess31from gi.repository import Gio
32from math import cos, sin
8from threading import Thread33from threading import Thread
9from math import cos, sin
1034
1135
12class GlxThread(Thread):36class GlxThread(Thread):
@@ -44,7 +68,8 @@
44 coords = "%s,%s" % (x, y)68 coords = "%s,%s" % (x, y)
45 subprocess.call(69 subprocess.call(
46 'wmctrl -i -r %s -e 0,%s,-1,-1' % (self.id, coords),70 'wmctrl -i -r %s -e 0,%s,-1,-1' % (self.id, coords),
47 shell=True)71 shell=True
72 )
48 time.sleep(0.002 * self.offset)73 time.sleep(0.002 * self.offset)
49 if self.cancel:74 if self.cancel:
50 return75 return
@@ -55,27 +80,6 @@
55 Start a thread performing fast workspace switches80 Start a thread performing fast workspace switches
56 """81 """
5782
58 def __init__(self, size):
59 Thread.__init__(self)
60 self.size = size
61 self.cancel = False
62
63 def run(self):
64 while(1):
65 for i in range(self.size):
66 subprocess.call('wmctrl -s %s' % i, shell=True)
67 time.sleep(0.5)
68 if self.cancel:
69 # Switch back to workspace #1
70 subprocess.call('wmctrl -s 0', shell=True)
71 return
72
73
74class ChangeViewport(Thread):
75 """
76 Start a thread performing fast viewport switches
77 """
78
79 def __init__(self, hsize, vsize, xsize, ysize):83 def __init__(self, hsize, vsize, xsize, ysize):
80 Thread.__init__(self)84 Thread.__init__(self)
81 self.hsize = hsize85 self.hsize = hsize
@@ -93,7 +97,7 @@
93 shell=True)97 shell=True)
94 time.sleep(0.5)98 time.sleep(0.5)
95 if self.cancel:99 if self.cancel:
96 # Switch back to viewport #1100 # Switch back to workspace #1
97 subprocess.call('wmctrl -o 0,0', shell=True)101 subprocess.call('wmctrl -o 0,0', shell=True)
98 return102 return
99103
@@ -104,48 +108,31 @@
104 """108 """
105109
106 def run(self):110 def run(self):
107 html5_path = os.path.join(os.getenv('CHECKBOX_SHARE', 'data/websites/html5_video.html'))111 html5_path = os.path.join(
112 os.getenv('CHECKBOX_SHARE'),
113 'data/websites/html5_video.html')
108 subprocess.call(114 subprocess.call(
109 'sudo -H -u %s xdg-open %s' % (os.getenv('SUDO_USER'), html5_path),115 'xdg-open %s' % html5_path,
110 stdout=open(os.devnull, 'w'),116 stdout=open(os.devnull, 'w'),
111 stderr=subprocess.STDOUT,117 stderr=subprocess.STDOUT,
112 shell=True)118 shell=True)
113119
114 def terminate(self):120 def terminate(self):
115 subprocess.call('wmctrl -c firefox', shell=True)121 subprocess.call("pkill firefox", shell=True)
116122
117123
118def pidof(name):124def check_gpu(log=None):
119 for pid in os.listdir("/proc"):125 if not log:
120 if not pid.isdigit():126 log = '/var/log/kern.log'
121 continue127 with open(log, 'r') as f:
122 try:
123 exe = os.readlink(os.path.join("/proc", pid, "exe"))
124 except OSError:
125 continue
126 if os.path.basename(exe) == name:
127 return int(pid)
128 return 0
129
130
131def is_unity_2d_running():
132 return pidof("unity-2d-panel") > 0
133
134
135def check_gpu():
136 f = open('/var/log/kern.log', 'r')
137 with f:
138 if re.findall(r'gpu\s+hung', f.read(), flags=re.I):128 if re.findall(r'gpu\s+hung', f.read(), flags=re.I):
139 print("GPU hung Detected")129 print("GPU hung Detected")
140 sys.exit(1)130 return 1
141131
142132
143def main():133def main():
144 if not (os.geteuid() == 0):134 if check_gpu():
145 print("Must be run as root.")
146 return 1135 return 1
147
148 check_gpu()
149 GlxWindows = []136 GlxWindows = []
150 GlxRotate = []137 GlxRotate = []
151 subprocess.call("pkill 'glxgears|firefox'", shell=True)138 subprocess.call("pkill 'glxgears|firefox'", shell=True)
@@ -153,6 +140,8 @@
153 Html5Video = Html5VideoThread()140 Html5Video = Html5VideoThread()
154 Html5Video.start()141 Html5Video.start()
155142
143 source = Gio.SettingsSchemaSource.get_default()
144
156 for i in range(2):145 for i in range(2):
157 GlxWindows.append(GlxThread())146 GlxWindows.append(GlxThread())
158 GlxWindows[i].start()147 GlxWindows[i].start()
@@ -169,28 +158,33 @@
169 GlxRotate.append(RotateGlxThread(GlxWindows[i].id, i + 1))158 GlxRotate.append(RotateGlxThread(GlxWindows[i].id, i + 1))
170 GlxRotate[i].start()159 GlxRotate[i].start()
171160
172 if is_unity_2d_running():161 hsize = vsize = 2
173 size = int(subprocess.check_output(162 hsize_ori = vsize_ori = None
174 'gconftool --get /apps/metacity/general/num_workspaces',163 if source.lookup("org.compiz.core", True):
175 shell=True))164 settings = Gio.Settings(
176 DesktopSwitch = ChangeWorkspace(size)165 "org.compiz.core",
166 "/org/compiz/profiles/unity/plugins/core/"
167 )
168 hsize_ori = settings.get_int("hsize")
169 vsize_ori = settings.get_int("vsize")
170 settings.set_int("hsize", hsize)
171 settings.set_int("vsize", vsize)
172 time.sleep(5)
177 else:173 else:
178 (x_res, y_res) = re.search(b'DG:\s+(\d+)x(\d+)',
179 subprocess.check_output('wmctrl -d', shell=True)).groups()
180 hsize = int(subprocess.check_output(174 hsize = int(subprocess.check_output(
181 'gconftool --get /apps/compiz-1/general/screen0/options/hsize',175 'gconftool --get /apps/compiz-1/general/screen0/options/hsize',
182 shell=True))176 shell=True))
183 vsize = int(subprocess.check_output(177 vsize = int(subprocess.check_output(
184 'gconftool --get /apps/compiz-1/general/screen0/options/vsize',178 'gconftool --get /apps/compiz-1/general/screen0/options/vsize',
185 shell=True))179 shell=True))
186 DesktopSwitch = ChangeViewport(180 (x_res, y_res) = re.search(
187 hsize, vsize, int(x_res) // hsize, int(y_res) // vsize)181 b'DG:\s+(\d+)x(\d+)',
182 subprocess.check_output('wmctrl -d', shell=True)).groups()
183 DesktopSwitch = ChangeWorkspace(
184 hsize, vsize, int(x_res) // hsize, int(y_res) // vsize)
188 DesktopSwitch.start()185 DesktopSwitch.start()
189186
190 time.sleep(20)187 time.sleep(35)
191 # Suspend/resume the SUT
192 subprocess.call('fwts -q s3 --s3-sleep-delay=30', shell=True)
193 time.sleep(20)
194188
195 for i in range(2):189 for i in range(2):
196 GlxRotate[i].cancel = True190 GlxRotate[i].cancel = True
@@ -198,7 +192,16 @@
198 DesktopSwitch.cancel = True192 DesktopSwitch.cancel = True
199 time.sleep(10)193 time.sleep(10)
200 Html5Video.terminate()194 Html5Video.terminate()
201 check_gpu()195 if check_gpu():
196 return 1
197
198 if source.lookup("org.compiz.core", True):
199 settings = Gio.Settings(
200 "org.compiz.core",
201 "/org/compiz/profiles/unity/plugins/core/")
202 settings.set_int("hsize", hsize_ori)
203 settings.set_int("vsize", vsize_ori)
204 Gio.Settings.sync()
202205
203if __name__ == '__main__':206if __name__ == '__main__':
204 sys.exit(main())207 sys.exit(main())

Subscribers

People subscribed via source and target branches