Big change #1 for personality function references:
[llvm/avr.git] / utils / lit / Test.py
blobd3f627456f8abd423cb9d9b7a619f3f601747cce
1 import os
3 # Test results.
5 class TestResult:
6 def __init__(self, name, isFailure):
7 self.name = name
8 self.isFailure = isFailure
10 PASS = TestResult('PASS', False)
11 XFAIL = TestResult('XFAIL', False)
12 FAIL = TestResult('FAIL', True)
13 XPASS = TestResult('XPASS', True)
14 UNRESOLVED = TestResult('UNRESOLVED', True)
15 UNSUPPORTED = TestResult('UNSUPPORTED', False)
17 # Test classes.
19 class TestFormat:
20 """TestFormat - Test information provider."""
22 def __init__(self, name):
23 self.name = name
25 class TestSuite:
26 """TestSuite - Information on a group of tests.
28 A test suite groups together a set of logically related tests.
29 """
31 def __init__(self, name, source_root, exec_root, config):
32 self.name = name
33 self.source_root = source_root
34 self.exec_root = exec_root
35 # The test suite configuration.
36 self.config = config
38 def getSourcePath(self, components):
39 return os.path.join(self.source_root, *components)
41 def getExecPath(self, components):
42 return os.path.join(self.exec_root, *components)
44 class Test:
45 """Test - Information on a single test instance."""
47 def __init__(self, suite, path_in_suite, config):
48 self.suite = suite
49 self.path_in_suite = path_in_suite
50 self.config = config
51 # The test result code, once complete.
52 self.result = None
53 # Any additional output from the test, once complete.
54 self.output = None
55 # The wall time to execute this test, if timing and once complete.
56 self.elapsed = None
58 def setResult(self, result, output, elapsed):
59 assert self.result is None, "Test result already set!"
60 self.result = result
61 self.output = output
62 self.elapsed = elapsed
64 def getFullName(self):
65 return self.suite.config.name + '::' + '/'.join(self.path_in_suite)
67 def getSourcePath(self):
68 return self.suite.getSourcePath(self.path_in_suite)
70 def getExecPath(self):
71 return self.suite.getExecPath(self.path_in_suite)