source: src/tests/pybin/test_run.py@ 633a642

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 633a642 was f3b9efc, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Tests now properly work with multiple architectures

  • Property mode set to 100644
File size: 1.8 KB
Line 
1import os
2
3from pybin.tools import *
4
5import pybin.settings
6
7# Test class that defines what a test is
8class Test:
9 def __init__(self):
10 self.name = ''
11 self.path = ''
12 self.arch = ''
13
14 def toString(self):
15 return "{:25s} ({:5s} {:s})".format( self.name, self.arch if self.arch else "Any", self.target() )
16
17 def prepare(self):
18 sh("mkdir -p %s" % os.path.join(self.path, '.err'))
19 sh("mkdir -p %s" % os.path.join(self.path, '.out'))
20 sh("mkdir -p %s" % os.path.join(self.path, '.in' ))
21
22 def expect(self):
23 return ("%s/.expect/%s%s.txt" % (self.path, self.name, '' if not self.arch else ".%s" % self.arch))
24
25 def error_log(self):
26 return ("%s/.err/%s.log" % (self.path, self.name))
27
28 def output_log(self):
29 return ("%s/.out/%s.log" % (self.path, self.name))
30
31 def input(self):
32 return ("%s/.in/%s.txt" % (self.path, self.name))
33
34 def target_output(self):
35 return self.output_log() if not settings.generating else self.expect()
36
37 def target(self):
38 return os.path.join(self.path, self.name)
39
40 @classmethod
41 def valid_name(_, name):
42 return not name.endswith( ('.c', '.cc', '.cpp', '.cfa') )
43
44 @classmethod
45 def from_target(_, target):
46 test = Test()
47 test.name = os.path.basename(target)
48 test.path = os.path.dirname (target)
49 test.arch = settings.arch.toString() if settings.arch.cross_compile else ''
50 return test
51
52
53class TestResult:
54 SUCCESS = 0
55 FAILURE = 1
56 TIMEOUT = 124
57
58 @classmethod
59 def toString( cls, retcode ):
60 if settings.generating :
61 if retcode == TestResult.SUCCESS: return "Done"
62 elif retcode == TestResult.TIMEOUT: return "TIMEOUT"
63 else : return "ERROR code %d" % retcode
64 else :
65 if retcode == TestResult.SUCCESS: return "PASSED"
66 elif retcode == TestResult.TIMEOUT: return "TIMEOUT"
67 else : return "FAILED with code %d" % retcode
Note: See TracBrowser for help on using the repository browser.