summaryrefslogtreecommitdiff
diff options
-rwxr-xr-xbin/rotation_test3
-rwxr-xr-xbin/sleep_test142
-rw-r--r--jobs/firewire.txt.in3
-rw-r--r--jobs/suspend.txt.in4
-rw-r--r--jobs/usb.txt.in4
5 files changed, 83 insertions, 73 deletions
diff --git a/bin/rotation_test b/bin/rotation_test
index 8fcf727..5187401 100755
--- a/bin/rotation_test
+++ b/bin/rotation_test
@@ -45,8 +45,9 @@ def main():
for rot in rotations:
try:
status = rotate_screen(rotations[rot])
- except(xrandr.RRError, xrandr.UnsupportedRRError) as error:
+ except (xrandr.RRError, xrandr.UnsupportedRRError) as exc:
status = 1
+ error = exc
else:
error = 'N/A'
# Collect the status and the error message
diff --git a/bin/sleep_test b/bin/sleep_test
index f63ab06..088a7a1 100755
--- a/bin/sleep_test
+++ b/bin/sleep_test
@@ -1,11 +1,12 @@
-#!/usr/bin/python
+#!/usr/bin/python3
'''
Program to automate system entering and resuming from sleep states
-Copyright (C) 2010,2011 Canonical Ltd.
+Copyright (C) 2010-2014 Canonical Ltd.
Author:
Jeff Lane <jeffrey.lane@canonical.com>
+ Daniel Manrique <roadmr@ubuntu.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2,
@@ -20,13 +21,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
-import os
-import sys
import logging
+import os
import re
-from subprocess import call
+import sys
+import syslog
+
from optparse import OptionParser, OptionGroup
-from syslog import *
+from subprocess import call
class ListDictHandler(logging.StreamHandler):
@@ -41,16 +43,20 @@ class ListDictHandler(logging.StreamHandler):
for msg in record.msg:
logger = logging.getLogger(record.name)
new_record = logger.makeRecord(record.name, record.levelno,
- record.pathname, record.lineno, msg, record.args,
- record.exc_info, record.funcName)
+ record.pathname, record.lineno,
+ msg, record.args,
+ record.exc_info,
+ record.funcName)
logging.StreamHandler.emit(self, new_record)
elif isinstance(record.msg, dict):
- for key, val in record.msg.iteritems():
+ for key, val in record.msg.items():
logger = logging.getLogger(record.name)
new_msg = '%s: %s' % (key, val)
new_record = logger.makeRecord(record.name, record.levelno,
- record.pathname, record.lineno, new_msg, record.args,
- record.exc_info, record.funcName)
+ record.pathname, record.lineno,
+ new_msg, record.args,
+ record.exc_info,
+ record.funcName)
logging.StreamHandler.emit(self, new_record)
else:
logging.StreamHandler.emit(self, record)
@@ -74,9 +80,9 @@ class SuspendTest():
future kernels.
'''
- states_fh = open('/sys/power/state', 'r', 0)
+ states_fh = open('/sys/power/state', 'rb', 0)
try:
- states = states_fh.read().split()
+ states = states_fh.read().decode('ascii').split()
finally:
states_fh.close()
logging.debug('The following sleep states were found:')
@@ -89,9 +95,9 @@ class SuspendTest():
def GetCurrentTime(self):
- time_fh = open('/sys/class/rtc/rtc0/since_epoch', 'r', 0)
+ time_fh = open('/sys/class/rtc/rtc0/since_epoch', 'rb', 0)
try:
- time = int(time_fh.read())
+ time = int(time_fh.read().decode('ascii'))
finally:
time_fh.close()
return time
@@ -110,13 +116,13 @@ class SuspendTest():
self.last_time = self.GetCurrentTime()
logging.debug('Current epoch time: %s' % self.last_time)
- wakealarm_fh = open('/sys/class/rtc/rtc0/wakealarm', 'w', 0)
+ wakealarm_fh = open('/sys/class/rtc/rtc0/wakealarm', 'wb', 0)
try:
- wakealarm_fh.write('0\n')
+ wakealarm_fh.write('0\n'.encode('ascii'))
wakealarm_fh.flush()
- wakealarm_fh.write('+%s\n' % time)
+ wakealarm_fh.write('+{}\n'.format(time).encode('ascii'))
wakealarm_fh.flush()
finally:
wakealarm_fh.close()
@@ -153,10 +159,10 @@ class SuspendTest():
def GetResults(self, mode, perf):
'''
- This will parse /var/log/messages for our start and end markers. Then
- it'll find a few key phrases that are part of the sleep and resume
- process, grab their timestamps, Bob's your Uncle and return a
- three-tuple consisting of: (PASS/FAIL,Sleep elapsed time, Resume
+ This will parse /var/log/messages for our start and end markers. Then
+ it'll find a few key phrases that are part of the sleep and resume
+ process, grab their timestamps, Bob's your Uncle and return a
+ three-tuple consisting of: (PASS/FAIL,Sleep elapsed time, Resume
elapsed time)
'''
# figure out our elapsed time
@@ -185,7 +191,7 @@ class SuspendTest():
sleep_end_time = re.split('[\[\]]',
loglist[idx - 1])[1].strip()
logging.debug('Sleep ended at %s' % sleep_end_time)
- resume_start_time = re.split('[\[\]]',
+ resume_start_time = re.split('[\[\]]',
loglist[idx])[1].strip()
logging.debug('Resume started at %s' % resume_start_time)
idx += 1
@@ -194,7 +200,7 @@ class SuspendTest():
loglist[idx])[1].strip()
logging.debug('Resume ended at %s' % resume_end_time)
if self.end_marker in loglist[idx]:
- logging.debug('End Marker found, run appears to '
+ logging.debug('End Marker found, run appears to '
'have completed')
run_complete = 'Pass'
break
@@ -206,7 +212,7 @@ class SuspendTest():
else:
if self.end_marker in loglist:
logging.debug('End Marker found, '
- 'run appears to have completed')
+ 'run appears to have completed')
run_complete = 'Pass'
sleep_elapsed = None
resume_elapsed = None
@@ -218,7 +224,7 @@ class SuspendTest():
Write a stamped marker to syslogd (will appear in /var/log/messages).
This is used to calculate the elapsed time for each iteration.
'''
- syslog(LOG_INFO, '---' + marker + '---')
+ syslog(syslog.LOG_INFO, '---' + marker + '---')
def CheckAlarm(self, mode):
'''
@@ -229,10 +235,10 @@ class SuspendTest():
the system did not wake by alarm IRQ, but by some other means.
'''
rtc = {}
- rtc_fh = open('/proc/driver/rtc', 'r', 0)
- alarm_fh = open('/sys/class/rtc/rtc0/wakealarm', 'r', 0)
+ rtc_fh = open('/proc/driver/rtc', 'rb', 0)
+ alarm_fh = open('/sys/class/rtc/rtc0/wakealarm', 'rb', 0)
try:
- rtc_data = rtc_fh.read().splitlines()
+ rtc_data = rtc_fh.read().decode('ascii').splitlines()
for item in rtc_data:
rtc_entry = item.partition(':')
rtc[rtc_entry[0].strip()] = rtc_entry[2].strip()
@@ -240,7 +246,7 @@ class SuspendTest():
rtc_fh.close()
try:
- alarm = int(alarm_fh.read())
+ alarm = int(alarm_fh.read().decode('ascii'))
except ValueError:
alarm = None
finally:
@@ -275,44 +281,44 @@ class SuspendTest():
def main():
usage = 'Usage: %prog [OPTIONS]'
parser = OptionParser(usage)
- group = OptionGroup(parser, 'This will not work for hibernat testing due' \
- ' to a kernel timestamp bug when doing an S4 ' \
+ group = OptionGroup(parser, 'This will not work for hibernat testing due'
+ ' to a kernel timestamp bug when doing an S4 '
'(hibernate/resume) sleep cycle')
group.add_option('-p', '--perf',
- action='store_true',
- default=False,
- help='Add some output that tells you how long it ' \
- 'takes to enter a sleep state and how long it ' \
- 'takes to resume.')
+ action='store_true',
+ default=False,
+ help='Add some output that tells you how long it '
+ 'takes to enter a sleep state and how long it '
+ 'takes to resume.')
parser.add_option('-i', '--iterations',
- action='store',
- type='int',
- metavar='NUM',
- default=1,
- help='The number of times to run the suspend/resume \
- loop. Default is %default')
+ action='store',
+ type='int',
+ metavar='NUM',
+ default=1,
+ help='The number of times to run the suspend/resume '
+ 'loop. Default is %default')
parser.add_option('-w', '--wake-in',
- action='store',
- type='int',
- metavar='NUM',
- default=60,
- dest='wake_time',
- help='Sets wake up time (in seconds) in the future \
- from now. Default is %default.')
+ action='store',
+ type='int',
+ metavar='NUM',
+ default=60,
+ dest='wake_time',
+ help='Sets wake up time (in seconds) in the future '
+ 'from now. Default is %default.')
parser.add_option('-s', '--sleep-state',
- action='store',
- default='mem',
- metavar='MODE',
- dest='mode',
- help='Sets the sleep state to test. Passing mem will \
- set the sleep state to Suspend-To-Ram or S3. Passing \
- disk will set the sleep state to Suspend-To-Disk or S4\
- (hibernate). Default sleep state is %default')
+ action='store',
+ default='mem',
+ metavar='MODE',
+ dest='mode',
+ help='Sets the sleep state to test. Passing mem will '
+ 'set the sleep state to Suspend-To-Ram or S3. Passing '
+ 'disk will set the sleep state to Suspend-To-Disk or S4 '
+ '(hibernate). Default sleep state is %default')
parser.add_option('-d', '--debug',
- action='store_true',
- default=False,
- help='Choose this to add verbose output for debug \
- purposes')
+ action='store_true',
+ default=False,
+ help='Choose this to add verbose output for debug \
+ purposes')
parser.add_option_group(group)
(options, args) = parser.parse_args()
options_dict = vars(options)
@@ -330,10 +336,10 @@ def main():
# Set up the logger
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
-
+
if options.debug:
handler.setLevel(logging.DEBUG)
-
+
logger.addHandler(handler)
logging.debug('Running with these options')
logging.debug(options_dict)
@@ -349,7 +355,7 @@ def main():
return 1
else:
logging.debug('%s sleep state supported, continuing test'
- % options.mode)
+ % options.mode)
# We run the following for the number of iterations requested
for iteration in range(0, options.iterations):
@@ -358,7 +364,7 @@ def main():
suspender.DoSuspend(options.mode)
run_count += 1
run_result[run_count] = suspender.GetResults(options.mode,
- options.perf)
+ options.perf)
if suspender.CheckAlarm(options.mode):
logging.debug('The alarm is still set')
@@ -367,7 +373,7 @@ def main():
resume_total = 0.0
logging.info('=' * 20 + ' Test Results ' + '=' * 20)
logging.info(run_result)
-
+
for k in run_result.iterkeys():
sleep_total += run_result[k][1]
resume_total += run_result[k][2]
@@ -381,7 +387,7 @@ def main():
if fail_count > 0:
logging.error('%s sleep/resume test cycles failed' %
- fail_count)
+ fail_count)
logging.error(run_result)
return 1
else:
diff --git a/jobs/firewire.txt.in b/jobs/firewire.txt.in
index 448a1de..67bce5e 100644
--- a/jobs/firewire.txt.in
+++ b/jobs/firewire.txt.in
@@ -1,5 +1,6 @@
plugin: user-interact
id: firewire/insert
+require: device.category == 'FIREWIRE'
command: removable_storage_watcher insert firewire
_description:
PURPOSE:
@@ -15,6 +16,7 @@ _description:
plugin: shell
id: firewire/storage-test
user: root
+require: device.category == 'FIREWIRE'
depends: firewire/insert
command: removable_storage_test -s 268400000 firewire
_description:
@@ -24,6 +26,7 @@ _description:
plugin: user-interact
id: firewire/remove
depends: firewire/storage-test
+require: device.category == 'FIREWIRE'
command: removable_storage_watcher remove firewire
_description:
PURPOSE:
diff --git a/jobs/suspend.txt.in b/jobs/suspend.txt.in
index b15e8ba..1ff61db 100644
--- a/jobs/suspend.txt.in
+++ b/jobs/suspend.txt.in
@@ -1718,7 +1718,7 @@ requires:
usb.usb3 == 'supported'
depends: suspend/usb3_insert_after_suspend
user: root
-command: removable_storage_test -s 268400000 -m 500000000 -p 7 usb
+command: removable_storage_test -s 268400000 -m 500000000 usb --driver xhci_hcd
_description:
This test is automated and executes after the suspend/usb3_insert_after_suspend
test is run.
@@ -1741,7 +1741,7 @@ user: root
requires:
usb.usb3 == 'supported'
depends: suspend/suspend_advanced_auto
-command: removable_storage_test -l usb && removable_storage_test -s 268400000 -m 500000000 -p 7 usb
+command: removable_storage_test -l usb && removable_storage_test -s 268400000 -m 500000000 usb --driver xhci_hcd
_description:
This is an automated version of usb3/storage-automated and assumes that the
server has usb 3.0 storage devices plugged in prior to checkbox execution. It
diff --git a/jobs/usb.txt.in b/jobs/usb.txt.in
index 2934be9..6437dd7 100644
--- a/jobs/usb.txt.in
+++ b/jobs/usb.txt.in
@@ -160,7 +160,7 @@ requires:
depends: usb3/insert
user: root
estimated_duration: 45.0
-command: removable_storage_test -s 268400000 -m 500000000 -p 7 usb
+command: removable_storage_test -s 268400000 -m 500000000 usb --driver xhci_hcd
_description:
This test is automated and executes after the usb3/insert test is run.
@@ -180,7 +180,7 @@ user: root
requires:
usb.usb3 == 'supported'
estimated_duration: 45.0
-command: removable_storage_test -l usb && removable_storage_test -s 268400000 -m 500000000 -p 7 usb
+command: removable_storage_test -l usb && removable_storage_test -s 268400000 -m 500000000 usb --driver xhci_hcd
_description:
This is an automated version of usb3/storage-automated and assumes that the
server has usb 3.0 storage devices plugged in prior to checkbox execution. It