~pieq/checkbox/add-30suspend-1reboot-cycles-support

« back to all changes in this revision

Viewing changes to providers/plainbox-provider-checkbox/bin/sleep_time_check

  • Committer: Pierre Equoy
  • Date: 2015-10-01 07:12:33 UTC
  • Revision ID: pierre.equoy@canonical.com-20151001071233-vndj1d03o7apqtf5
Add support for '30 suspends + 1 reboot' cycle

Add the following jobs:

- power-management/suspend-30-cycles-log-check-with-reboots
- power-management/suspend-30-cycle-log-attach-with-reboots
- power-management/suspend-30-cycles-time-check-with-reboots

Modifies the `pm_test` script to include `sleep_test` output in its logs in
order to easily access the data needed by `sleep_time_check` to compute
average times.

`sleep_time_check` has been updated to take into account more than one
sleep/resume times (the mean value is computed and returned).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
import sys
4
4
import argparse
 
5
from statistics import mean
5
6
 
6
7
 
7
8
def main():
35
36
        return False
36
37
 
37
38
    sleep_time = None
 
39
    sleep_times = []
38
40
    resume_time = None
 
41
    resume_times = []
39
42
    # find our times
40
43
    for line in lines:
41
44
        if "Average time to sleep" in line:
42
45
            sleep_time = float(line.split(':')[1].strip())
 
46
            sleep_times.append(sleep_time)
43
47
        elif "Average time to resume" in line:
44
48
            resume_time = float(line.split(':')[1].strip())
 
49
            resume_times.append(resume_time)
45
50
 
46
 
    if sleep_time is None or resume_time is None:
 
51
    if (sleep_time is None or resume_time is None) or \
 
52
    (len(sleep_times) != len(resume_times)):
47
53
        print("ERROR: One or more times was not reported correctly")
48
54
        return False
49
55
 
50
 
    print("Average time to enter sleep state: %s seconds" % sleep_time)
51
 
    print("Average time to resume from sleep state: %s seconds" % resume_time)
 
56
    print("Average time to enter sleep state: %.4f seconds" % mean(sleep_times))
 
57
    print("Average time to resume from sleep state: %.4f seconds" % mean(resume_times))
52
58
 
53
59
    failed = False
54
60
    if sleep_time > args.sleep_threshold: