summaryrefslogtreecommitdiff
path: root/bin
diff options
authorMaciej Kisielewski <maciej.kisielewski@canonical.com>2015-08-06 07:15:34 +0000
committerDaniel Manrique <>2015-08-06 07:15:34 +0000
commit7dfb4ff3d56f22d5ed27671ef40e881f92178014 (patch)
tree38cb80e44f95fb5f6de7fecf0b99254769208f29 /bin
parent14fa57140d658f0423c0c67eef2bbac6222ff1cb (diff)
parentc868fb55fb99a4c20c4f2848302f9f91c2fb8f3a (diff)
"automatic merge of lp:~kissiel/checkbox/suspends-reboots-job/ by tarmac [r=zyga][bug=][author=kissiel]"
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pm_test25
-rwxr-xr-xbin/sleep_test4
2 files changed, 25 insertions, 4 deletions
diff --git a/bin/pm_test b/bin/pm_test
index 827758fa..7a5ab33e 100755
--- a/bin/pm_test
+++ b/bin/pm_test
@@ -91,6 +91,7 @@ class PowerManagementOperation(object):
self.check_last_cycle_duration()
if self.args.repetitions > 0:
+ self.run_suspend_cycles(self.args.suspends_before_reboot)
self.run_pm_command()
else:
self.summary()
@@ -101,7 +102,9 @@ class PowerManagementOperation(object):
that is, not too short, not too long
"""
min_pm_time = timedelta(seconds=self.args.min_pm_time)
- max_pm_time = timedelta(seconds=self.args.max_pm_time)
+ # add time needed for suspend/resume cycles ( < 100s each)
+ max_pm_time = timedelta(seconds=self.args.max_pm_time +
+ self.args.suspends_before_reboot * 100)
if self.args.pm_timestamp:
pm_timestamp = datetime.fromtimestamp(self.args.pm_timestamp)
now = datetime.now()
@@ -150,6 +153,18 @@ class PowerManagementOperation(object):
subprocess.check_call(command_str, shell=True)
signal.pause()
+ def run_suspend_cycles(self, cycles_count):
+ """Run suspend and resume cycles."""
+ if cycles_count < 1:
+ return
+ sleep_test_path = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)), 'sleep_test')
+ command_str = '{} -s mem -p -i {} -w 10'.format(
+ sleep_test_path, cycles_count)
+ logging.info('Running suspend/resume cycles')
+ logging.debug('Executing: {0!r}...'.format(command_str))
+ subprocess.check_call(command_str, shell=True)
+
def summary(self):
"""
Gather hardware information for the last time,
@@ -602,7 +617,7 @@ class AutoStartFile(object):
[Desktop Entry]
Name={pm_operation} test
Comment=Verify {pm_operation} works properly
-Exec=sudo /usr/bin/python3 {script} -r {repetitions} -w {wakeup} --hardware-delay {hardware_delay} --pm-delay {pm_delay} --min-pm-time {min_pm_time} --max-pm-time {max_pm_time} --append --total {total} --start {start} --pm-timestamp {pm_timestamp} {silent} --log-level={log_level} --log-dir={log_dir} {pm_operation}
+Exec=sudo /usr/bin/python3 {script} -r {repetitions} -w {wakeup} --hardware-delay {hardware_delay} --pm-delay {pm_delay} --min-pm-time {min_pm_time} --max-pm-time {max_pm_time} --append --total {total} --start {start} --pm-timestamp {pm_timestamp} {silent} --log-level={log_level} --log-dir={log_dir} --suspends-before-reboot={suspend_cycles} {pm_operation}
Type=Application
X-GNOME-Autostart-enabled=true
Hidden=false
@@ -653,6 +668,7 @@ Hidden=false
silent='--silent' if self.args.silent else '',
log_level=self.args.log_level_str,
log_dir=self.args.log_dir,
+ suspend_cycles=self.args.suspends_before_reboot,
pm_operation=self.args.pm_operation))
logging.debug(contents)
@@ -782,6 +798,11 @@ class MyArgumentParser(object):
# Total number of iterations initially passed through the command line
parser.add_argument('--total', type=int, default=0, help=SUPPRESS)
+
+ # suspend cycles before reboot
+ parser.add_argument('--suspends-before-reboot', type=int, default=0,
+ help=('How many cycles of suspend/resume to run'
+ 'before each reboot or poweroff'))
self.parser = parser
def parse(self):
diff --git a/bin/sleep_test b/bin/sleep_test
index 088a7a10..f28b0a0c 100755
--- a/bin/sleep_test
+++ b/bin/sleep_test
@@ -224,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(syslog.LOG_INFO, '---' + marker + '---')
+ syslog.syslog(syslog.LOG_INFO, '---' + marker + '---')
def CheckAlarm(self, mode):
'''
@@ -374,7 +374,7 @@ def main():
logging.info('=' * 20 + ' Test Results ' + '=' * 20)
logging.info(run_result)
- for k in run_result.iterkeys():
+ for k in run_result.keys():
sleep_total += run_result[k][1]
resume_total += run_result[k][2]
sleep_avg = sleep_total / run_count