Changeset 7030dab for tests/pybin


Ignore:
Timestamp:
Apr 6, 2020, 4:46:28 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
Children:
e3bc51c
Parents:
71d6bd8 (diff), 057298e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into new-ast

Location:
tests/pybin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/pybin/settings.py

    r71d6bd8 r7030dab  
    7777                        print("updated to %s" % self.target)
    7878
    79         def match(self, arch):
     79        def filter(self, tests):
     80                return [test for test in tests if not test.arch or self.target == test.arch]
    8081                return True if not arch else self.target == arch
    8182
     
    113114
    114115def init( options ):
     116        global all_arch
     117        global all_debug
     118        global all_install
    115119        global arch
    116120        global archive
     121        global continue_
    117122        global debug
    118         global distcc
    119123        global dry_run
    120124        global generating
     
    123127        global output_width
    124128        global timeout
     129        global timeout2gdb
    125130
    126         arch         = Architecture(options.arch)
     131        all_arch     = [Architecture(o) for o in list(dict.fromkeys(options.arch   ))]
     132        all_debug    = [Debug(o)        for o in list(dict.fromkeys(options.debug  ))]
     133        all_install  = [Install(o)      for o in list(dict.fromkeys(options.install))]
    127134        archive      = os.path.abspath(os.path.join(original_path, options.archive_errors)) if options.archive_errors else None
    128         debug        = Debug(options.debug)
     135        continue_    = options.continue_
    129136        dry_run      = options.dry_run # must be called before tools.config_hash()
    130         distcc       = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash()
    131137        generating   = options.regenerate_expected
    132         install      = Install(options.install)
    133138        make         = ['make']
    134139        output_width = 24
    135140        timeout      = Timeouts(options.timeout, options.global_timeout)
     141        timeout2gdb  = options.timeout_with_gdb
    136142
    137143        # if we distribute, distcc errors will fail tests, use log file for distcc
     
    146152
    147153def validate():
     154        """Validate the current configuration and update globals"""
     155
     156        global distcc
     157        distcc       = "DISTCC_CFA_PATH=~/.cfadistcc/%s/cfa" % tools.config_hash()
    148158        errf = os.path.join(BUILDDIR, ".validate.err")
    149159        make_ret, out = tools.make( ".validate", error_file = errf, output_file=subprocess.DEVNULL, error=subprocess.DEVNULL )
  • tests/pybin/tools.py

    r71d6bd8 r7030dab  
    7575                                        return proc.returncode, out.decode("utf-8") if out else None
    7676                                except subprocess.TimeoutExpired:
    77                                         proc.send_signal(signal.SIGABRT)
    78                                         proc.communicate()
    79                                         return 124, str(None)
     77                                        if settings.timeout2gdb:
     78                                                print("Process {} timeout".format(proc.pid))
     79                                                proc.communicate()
     80                                                return 124, str(None)
     81                                        else:
     82                                                proc.send_signal(signal.SIGABRT)
     83                                                proc.communicate()
     84                                                return 124, str(None)
    8085
    8186        except Exception as ex:
     
    175180
    176181def which(program):
    177     fpath, fname = os.path.split(program)
    178     if fpath:
    179         if is_exe(program):
    180             return program
    181     else:
    182         for path in os.environ["PATH"].split(os.pathsep):
    183             exe_file = os.path.join(path, program)
    184             if is_exe(exe_file):
    185                 return exe_file
    186 
    187     return None
     182        fpath, fname = os.path.split(program)
     183        if fpath:
     184                if is_exe(program):
     185                        return program
     186        else:
     187                for path in os.environ["PATH"].split(os.pathsep):
     188                        exe_file = os.path.join(path, program)
     189                        if is_exe(exe_file):
     190                                return exe_file
     191        return None
    188192
    189193@contextlib.contextmanager
     
    323327        raise argparse.ArgumentTypeError(msg)
    324328
     329# Convert a function that converts a string to one that converts comma separated string.
     330def comma_separated(elements):
     331    return lambda string: [elements(part) for part in string.split(',')]
     332
    325333def fancy_print(text):
    326334        column = which('column')
     
    365373
    366374class Timed:
    367     def __enter__(self):
    368         self.start = time.time()
    369         return self
    370 
    371     def __exit__(self, *args):
    372         self.end = time.time()
    373         self.duration = self.end - self.start
     375        def __enter__(self):
     376                self.start = time.time()
     377                return self
     378
     379        def __exit__(self, *args):
     380                self.end = time.time()
     381                self.duration = self.end - self.start
    374382
    375383def timed(src, timeout):
    376384        expire = time.time() + timeout
    377385        i = iter(src)
    378         while True:
    379                 yield i.next(max(expire - time.time(), 0))
     386        with contextlib.suppress(StopIteration):
     387                while True:
     388                        yield i.next(max(expire - time.time(), 0))
Note: See TracChangeset for help on using the changeset viewer.