6
from optparse import OptionParser
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.
16
ltp_to_checkox_status = {
19
"TBROK": "unresolved",
20
"TCONF": "unsupported"}
22
def print_line(key, value):
23
print "%s: %s" % (key, value)
25
def print_element(element):
26
for key, value in element.iteritems():
27
print_line(key, value)
32
test_pattern = re.compile("(?P<case>\w+)\s+(?P<number>\d+)\s+(?P<status>[A-Z]+)\s+:\s+(?P<data>.*)")
35
for line in file.readlines():
36
match = test_pattern.match(line)
38
if match.group("status") in ltp_to_checkox_status:
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)
50
def parse_filename(filename):
54
file = open(filename, "r")
56
return parse_file(file)
58
def parse_filenames(filenames):
60
for filename in filenames:
61
elements.extend(parse_filename(filename))
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)
77
elements = parse_filenames(filenames)
81
for element in elements:
83
element["suite"] = options.suite
84
print_element(element)
89
if __name__ == "__main__":
90
sys.exit(main(sys.argv[1:]))