Changeset c04a849 in rtems-tools for tester


Ignore:
Timestamp:
May 31, 2014, 10:03:05 AM (5 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, e9f48e9face6c4dea62712d73b35412c0fe10332
Children:
60937e1
Parents:
5cdcde1
Message:

tester: Correctly handle contro-c.

Add support to kill running tests if the user presses control-c.

Location:
tester/rt
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • tester/rt/config.py

    r5cdcde1 rc04a849  
    6363        self.output = None
    6464        self.report = report
    65         self.load(name)
     65        self.name = name
    6666
    6767    def __del__(self):
     
    182182                print ' '.join(l)
    183183
     184    def run(self):
     185        self.load(self.name)
     186
    184187    def capture(self, text):
    185188        text = [(']', l) for l in text.replace(chr(13), '').splitlines()]
     
    204207                return True
    205208        return False
     209
     210    def kill(self):
     211        if self.process:
     212            self.process.kill()
  • tester/rt/test.py

    r5cdcde1 rc04a849  
    3939from rtemstoolkit import log
    4040from rtemstoolkit import path
    41 
     41from rtemstoolkit import stacktraces
     42
     43import bsps
    4244import config
    4345import console
     
    4648import version
    4749import fnmatch
    48 
    49 def stacktraces():
    50     import traceback
    51     code = []
    52     for threadId, stack in sys._current_frames().items():
    53         code.append("\n# thread-id: %s" % threadId)
    54         for filename, lineno, name, line in traceback.extract_stack(stack):
    55             code.append('file: "%s", line %d, in %s' % (filename, lineno, name))
    56             if line:
    57                 code.append("  %s" % (line.strip()))
    58     return '\n'.join(code)
    5950
    6051class test(object):
     
    7970                raise error.general('cannot find RTEMS tools path: %s' % (rtems_tools_bin))
    8071            self.opts.defaults['rtems_tools'] = rtems_tools_bin
    81         self.config = config.file(report, bsp_config, self.opts)
     72        self.config = config.file(self.report, self.bsp_config, self.opts)
     73
     74    def run(self):
     75        if self.config:
     76            self.config.run()
     77
     78    def kill(self):
     79        if self.config:
     80            self.config.kill()
    8281
    8382class test_run(object):
     
    103102                             self.bsp, self.bsp_config,
    104103                             self.opts)
     104            self.test.run()
    105105        except KeyboardInterrupt:
    106106            pass
     
    120120        if self.result is not None:
    121121            raise self.result[0], self.result[1], self.result[2]
     122
     123    def kill(self):
     124        if self.test:
     125            self.test.kill()
    122126
    123127def find_executables(paths, glob):
     
    176180    raise error.exit()
    177181
     182def killall(tests):
     183    for test in tests:
     184        test.kill()
     185
    178186def run(command_path = None):
    179187    import sys
     188    tests = []
    180189    stdtty = console.save()
    181190    opts = None
     
    195204        log.notice('RTEMS Testing - Tester, v%s' % (version.str()))
    196205        if opts.find_arg('--list-bsps'):
    197             list_bsps(opts)
     206            bsps.list(opts)
    198207        exe_filter = opts.find_arg('--filter')
    199208        if exe_filter:
     
    247256        jobs = int(opts.jobs(opts.defaults['_ncpus']))
    248257        exe = 0
    249         tests = []
    250258        finished = []
    251259        if jobs > len(executables):
     
    289297        reports.summary()
    290298        end_time = datetime.datetime.now()
    291         log.notice('Testing time: %s' % (str(end_time - start_time)))
     299        log.notice('Average test time: %s' % (str((end_time - start_time) / total)))
     300        log.notice('Testing time     : %s' % (str(end_time - start_time)))
    292301    except error.general, gerr:
    293302        print gerr
     
    303312            for t in threading.enumerate():
    304313                print '}} ', t.name
    305             print stacktraces()
     314            print stacktraces.trace()
    306315        log.notice('abort: user terminated')
     316        killall(tests)
    307317        sys.exit(1)
    308318    finally:
Note: See TracChangeset for help on using the changeset viewer.