source: tests/pybin/settings.py @ d3c1c6a

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since d3c1c6a was d3c1c6a, checked in by tdelisle <tdelisle@…>, 5 years ago

Tests now prints path+name when runnning

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[f85bc15]1import os
[f3b9efc]2import sys
[5b993e0]3from . import tools
[bacc36c]4
[f85bc15]5try :
[afe8882]6        testpath = os.path.dirname(os.path.abspath(os.path.join(os.getcwd(), sys.argv[0])))
7        sys.path.append(testpath)
[552f5cb]8        import config
[f85bc15]9
[552f5cb]10        SRCDIR = os.path.abspath(config.SRCDIR)
11        BUILDDIR = os.path.abspath(config.BUILDDIR)
[afe8882]12        os.chdir(testpath)
13
[f85bc15]14except:
15        print('ERROR: missing config.py, re-run configure script.', file=sys.stderr)
16        sys.exit(1)
17
[bacc36c]18class Architecture:
[f3b9efc]19        KnownArchitectures = {
20                'x64'                   : 'x64',
21                'x86-64'                : 'x64',
[552f5cb]22                'x86_64'                : 'x64',
[f3b9efc]23                'x86'                   : 'x86',
24                'i386'          : 'x86',
25                'i486'          : 'x86',
26                'i686'          : 'x86',
27                'Intel 80386'   : 'x86',
28                'arm'                   : 'arm',
29                'ARM'                   : 'arm',
30        }
31
[575a6e5]32        CrossCompileFlags = {
33                'x64' : 'ARCH_FLAGS=-m64',
34                'x86' : 'ARCH_FLAGS=-m32',
35        }
36
[f3b9efc]37        def __init__(self, arch):
[575a6e5]38                try:
39                        canonical_host = Architecture.makeCanonical( config.HOSTARCH )
40                except KeyError:
41                        print("Unkown host architecture %s" % config.HOSTARCH, file=sys.stderr)
42                        sys.exit(1)
43
[f3b9efc]44                if arch:
45                        try:
[575a6e5]46                                arch = Architecture.makeCanonical( arch )
[f3b9efc]47                        except KeyError:
[575a6e5]48                                print("Unkown architecture %s" % arch, file=sys.stderr)
[f3b9efc]49                                sys.exit(1)
[575a6e5]50
51                if arch and arch != canonical_host:
52                        self.target = arch
53                        self.cross_compile = True
54                else:
55                        self.target = canonical_host
56                        self.cross_compile = False
[47c1928]57
58
59                try :
60                        self.flags = Architecture.CrossCompileFlags[self.target]
61                except KeyError:
62                        print("Cross compilation not available for architecture %s" % self.target, file=sys.stderr)
63                        sys.exit(1)
[575a6e5]64
[f3b9efc]65                self.string = self.target
66
67        def update(self):
68                if not self.cross_compile:
69                        self.target = machine_default()
70                        self.string = self.target
71                        print("updated to %s" % self.target)
72
73        def match(self, arch):
74                return True if not arch else self.target == arch
75
76        @classmethod
77        def makeCanonical(_, arch):
78                return Architecture.KnownArchitectures[arch]
79
[bacc36c]80
[f3b9efc]81class Debug:
82        def __init__(self, value):
83                self.string = "debug" if value else "no debug"
[575a6e5]84                self.flags  = """DEBUG_FLAGS="%s" """ % ("-debug -O0" if value else "-nodebug -O2")
[bacc36c]85
[a5121bf]86class Install:
87        def __init__(self, value):
88                self.string = "installed" if value else "in-tree"
89                self.flags  = """INSTALL_FLAGS="%s" """ % ("" if value else "-in-tree")
90
[afe8882]91class Timeouts:
92        def __init__(self, ts, tg):
93                self.single = Timeouts.check(ts)
94                self.total  = Timeouts.check(tg)
95
96        @classmethod
97        def check(_, value):
98                if value < 1:
99                        print("Timeouts must be at least 1 second", file=sys.stderr)
100                        sys.exit(1)
101
102                return value
103
[bacc36c]104def init( options ):
105        global arch
106        global dry_run
107        global generating
108        global make
[209383b]109        global debug
[a5121bf]110        global install
[afe8882]111        global timeout
[d3c1c6a]112        global width
[bacc36c]113
114        dry_run    = options.dry_run
115        generating = options.regenerate_expected
[f3b9efc]116        make       = 'make'
117        debug        = Debug(options.debug)
[a5121bf]118        install    = Install(options.install)
[f3b9efc]119        arch       = Architecture(options.arch)
[afe8882]120        timeout    = Timeouts(options.timeout, options.global_timeout)
[d3c1c6a]121        width      = 24
[bacc36c]122
[f85bc15]123
[bacc36c]124def updateMakeCmd(force, jobs):
125        global make
126
[28582b2]127        make = "make" if not force else ("make -j%i" % jobs)
128
129def validate():
[afe8882]130        errf = os.path.join(BUILDDIR, ".validate.err")
131        make_ret, _ = tools.make( ".validate", error_file = errf, redirects  = "2> /dev/null 1> /dev/null", )
[28582b2]132        if make_ret != 0:
[afe8882]133                with open (errf, "r") as myfile:
[28582b2]134                        error=myfile.read()
[575a6e5]135                print("ERROR: Invalid configuration %s:%s" % (arch.string, debug.string), file=sys.stderr)
[28582b2]136                print("       verify returned : \n%s" % error, file=sys.stderr)
[afe8882]137                tools.rm(errf)
[28582b2]138                sys.exit(1)
139
[d3c1c6a]140        tools.rm(errf)
141
142def prep_output(tests):
143        global width
144        width = max(map(lambda t: len(t.target()), tests))
Note: See TracBrowser for help on using the repository browser.