~ubuntu-branches/ubuntu/oneiric/checkbox/oneiric-proposed

« back to all changes in this revision

Viewing changes to scripts/fwts_test

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Manrique, Marc Tardif, Chad A. Davis, Barry Warsaw
  • Date: 2011-07-01 11:37:27 UTC
  • Revision ID: james.westby@ubuntu.com-20110701113727-k4pekmtyr7v2i6le
Tags: 0.12.3
[ Marc Tardif ]
* Only reading CHECKBOX_* environment variables in config (LP: #802458)
* Imported scripts and jobs from Platform Services.

[Chad A. Davis]
* Switch to dh_python2 and debhelper7 (LP: #788514)

[Barry Warsaw]
* Fix checkbox_clean.run() to ignore missing executables, as is the case
  in a fresh checkout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import sys
 
4
from optparse import OptionParser
 
5
from subprocess import Popen, PIPE
 
6
 
 
7
TESTS = ['acpiinfo',
 
8
         'acpitables',
 
9
         'apicedge',
 
10
         'apicinstance',
 
11
         'bios_info',
 
12
         'bios32',
 
13
         'checksum',
 
14
         'crs',
 
15
         'dmesg_common',
 
16
         'dmi_decode',
 
17
         'ebda',
 
18
         'fadt',
 
19
         'fan',
 
20
         'hda_audio',
 
21
         'hpet_check',
 
22
         'maxfreq',
 
23
         'maxreadreq',
 
24
         'mcfg',
 
25
         'microcode',
 
26
         'mtrr',
 
27
         'nx',
 
28
         'os2gap',
 
29
         'osilinux',
 
30
         'smbios',
 
31
         'version',
 
32
         'virt',
 
33
         'wmi',
 
34
         'cstates',
 
35
         'dmar']
 
36
 
 
37
def main():
 
38
    usage = 'usage %prog [OPTIONS]'
 
39
    parser = OptionParser(usage)
 
40
    parser.add_option('-c','--cpufreq',
 
41
                      action='store_true',
 
42
                      help='Chose this option to run the CPU Frequency Scaling test only')
 
43
    parser.add_option('-w','--wakealarm',
 
44
                      action='store_true',
 
45
                      help='Run the fwts wakealarm test only')
 
46
    parser.add_option('-a','--all',
 
47
                      action='store_true',
 
48
                      help='Run ALL FWTS automated tests (assumes -w and -c)')
 
49
    parser.add_option('-l','--log',
 
50
                      default='/tmp/fwts_results.log',
 
51
                      help='Specify the location and name of the log file. Default log path is %default')
 
52
    (options, args) = parser.parse_args()
 
53
 
 
54
    if options.cpufreq and options.wakealarm:
 
55
        parser.error('cpufreq and wakealarm can not be chosen togehter. Choose -a instead')
 
56
 
 
57
    tests = []
 
58
    results = {}
 
59
 
 
60
    if options.cpufreq:
 
61
        tests += ['cpufreq']
 
62
    elif options.wakealarm:
 
63
        tests += ['wakealarm']
 
64
    elif options.all:
 
65
        tests += ['wakealarm','cpufreq'] + TESTS
 
66
    else:
 
67
        tests += TESTS
 
68
 
 
69
    # run the tests we want
 
70
    for test in tests:
 
71
        command = 'fwts -q --stdout-summary -r %s %s' % (options.log,test)
 
72
        results[test] = Popen(command, stdout=PIPE, shell=True).communicate()[0].strip()
 
73
 
 
74
    # parse the summaries
 
75
    passed = 0
 
76
    failed = 0
 
77
    for test in tests:
 
78
        if results[test] == 'FAILED_CRITICAL' or \
 
79
           results[test] == 'FAILED_HIGH':
 
80
            failed += 1
 
81
        elif results[test] == 'PASSED':
 
82
            passed += 1
 
83
        else:
 
84
            continue
 
85
 
 
86
    if failed != 0:
 
87
        return 1
 
88
    else:
 
89
        return 0
 
90
 
 
91
if __name__ == '__main__':
 
92
    sys.exit(main())