~dstansby-deactivatedaccount/ubuntu/maverick/checkbox/checkbox-fix-525454

« back to all changes in this revision

Viewing changes to scripts/ltp_filter

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug, Marc Tardif
  • Date: 2010-03-09 16:58:36 UTC
  • Revision ID: james.westby@ubuntu.com-20100309165836-26f22oe6ubppzx0d
Tags: 0.9
[ Marc Tardif ]
New upstream release (LP: #532882):
* Introduced job_prompt plugin to treat all jobs (suites, tests, etc.) as composites.
* Replaced the registry and resource scripts and centralized job iteration.
* Replaced dependency on dbus by using sudo/gksu/kdesudo instead.
* Replaced mktemp with mkdtemp for security purposes.
* Fixed strings in fingerprint and modem tests (LP: #457759)
* Fixed client side validation of Launchpad form (LP: #438671)
* Added device information to tags when reporting bugs with apport.
* Added shorthands for blacklist-file and whitelist-file.
* Added support for apport default configuration (LP: #465447)
* Added support for scrolled options list (LP: #411526)
* Added support for tests generated by suites to run as root.
* Added support for requirements in attachments.
* Added support for armv7l processor
* Added Autotest integration
* Added LTP integration
* Added Phoronix integration
* Added qa-regression-testing integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import re
 
4
import sys
 
5
 
 
6
from optparse import OptionParser
 
7
 
 
8
# TPASS     The test case produced expected results.
 
9
# TFAIL     The test case produced unexpected results.
 
10
# TBROK     A resource needed to execute the test case was not available (e.g. a temporary file could not be opened).
 
11
# TCONF     The test case was not appropriate for the current hardware or software configuration (e.g. MLS was not enabled).
 
12
# TRETR     The test case was no longer valid and has been "retired."
 
13
# TWARN     The testing procedure caused undesirable side effects that did not affect test results (e.g. a temporary file could not be removed after all test results were recorded).
 
14
# TINFO     An informative message about the execution of the test that does not correspond to a test case result and does not indicate a problem.
 
15
 
 
16
ltp_to_checkox_status = {
 
17
    "TPASS": "pass",
 
18
    "TFAIL": "fail",
 
19
    "TBROK": "unresolved",
 
20
    "TCONF": "unsupported"}
 
21
 
 
22
def print_line(key, value):
 
23
    print "%s: %s" % (key, value)
 
24
 
 
25
def print_element(element):
 
26
    for key, value in element.iteritems():
 
27
        print_line(key, value)
 
28
 
 
29
    print
 
30
 
 
31
def parse_file(file):
 
32
    test_pattern = re.compile("(?P<case>\w+)\s+(?P<number>\d+)\s+(?P<status>[A-Z]+)\s+:\s+(?P<data>.*)")
 
33
 
 
34
    elements = []
 
35
    for line in file.readlines():
 
36
        match = test_pattern.match(line)
 
37
        if match:
 
38
            if match.group("status") in ltp_to_checkox_status:
 
39
                element = {
 
40
                    "plugin": "shell",
 
41
                    "name": "%s.%s" % (match.group("case"), match.group("number")),
 
42
                    "requires": "package.alias == 'linux'",
 
43
                    "description": "%s.%s" % (match.group("case"), match.group("number")),
 
44
                    "status": ltp_to_checkox_status[match.group("status")],
 
45
                    "data": match.group("data")}
 
46
                elements.append(element)
 
47
 
 
48
    return elements
 
49
 
 
50
def parse_filename(filename):
 
51
    if filename == "-":
 
52
        file = sys.stdin
 
53
    else:
 
54
        file = open(filename, "r")
 
55
 
 
56
    return parse_file(file)
 
57
 
 
58
def parse_filenames(filenames):
 
59
    elements = []
 
60
    for filename in filenames:
 
61
        elements.extend(parse_filename(filename))
 
62
 
 
63
    return elements
 
64
 
 
65
def main(args):
 
66
    usage = "Usage: %prog [FILE...]"
 
67
    parser = OptionParser(usage=usage)
 
68
    parser.add_option("-s", "--suite",
 
69
        help="Suite corresponding to the tests")
 
70
    (options, args) = parser.parse_args(args)
 
71
 
 
72
    if not args:
 
73
        filenames = ["-"]
 
74
    else:
 
75
        filenames = args
 
76
 
 
77
    elements = parse_filenames(filenames)
 
78
    if not elements:
 
79
        return 1
 
80
 
 
81
    for element in elements:
 
82
        if options.suite:
 
83
            element["suite"] = options.suite
 
84
        print_element(element)
 
85
 
 
86
    return 0
 
87
 
 
88
 
 
89
if __name__ == "__main__":
 
90
    sys.exit(main(sys.argv[1:]))