Changeset 0c13238


Ignore:
Timestamp:
Jan 23, 2019, 3:02:43 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
1d832f4
Parents:
c018b85
Message:

Aborts now create core dumps which are printed by the test harness.

  • printing is done with gdb, print-core.gdb is the list of commands that will print
  • since all core dumps are assumed to be call 'core' this doesn't handle fancy core patterns and has race conditions if multiple program core dump.
Location:
tests
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • tests/pybin/tools.py

    rc018b85 r0c13238  
    33import __main__
    44import argparse
     5import fileinput
    56import multiprocessing
    67import os
    78import re
     9import resource
    810import signal
    911import stat
    1012import sys
    11 import fileinput
     13import time
    1214
    1315from pybin import settings
     
    131133
    132134    return None
     135
     136def run(exe, output, input):
     137        ret, _ = sh("timeout %d %s > %s 2>&1" % (settings.timeout.single, exe, output), input = input)
     138        return ret
     139
    133140################################################################################
    134141#               file handling
    135142################################################################################
     143# move a file
     144def mv(source, dest):
     145        ret, _ = sh("mv %s %s" % (source, dest))
     146        return ret
     147
     148# cat one file into the other
     149def cat(source, dest):
     150        ret, _ = sh("cat %s > %s" % (source, dest))
     151        return ret
    136152
    137153# helper function to replace patterns in a file
     
    230246                signal.signal(signal.SIGINT, signal.SIG_IGN)
    231247
     248
     249# enable core dumps for all the test children
     250resource.setrlimit(resource.RLIMIT_CORE, (resource.RLIM_INFINITY, resource.RLIM_INFINITY))
     251
    232252################################################################################
    233253#               misc
     
    251271        else:
    252272                print(text)
     273
     274
     275def coreInfo(path):
     276        cmd   = os.path.join(settings.SRCDIR, "pybin/print-core.gdb")
     277        if not os.path.isfile(cmd):
     278                return 1, "ERR Printing format for core dumps not found"
     279
     280        dname = os.path.dirname(path)
     281        core  = os.path.join(dname, "core" )
     282        if not os.path.isfile(path):
     283                return 1, "ERR Executable path is wrong"
     284
     285        if not os.path.isfile(core):
     286                return 1, "ERR No core dump"
     287
     288        return sh("gdb -n %s %s -batch -x %s" % (path, core, cmd), print2stdout=False)
     289
     290class Timed:
     291    def __enter__(self):
     292        self.start = time.time()
     293        return self
     294
     295    def __exit__(self, *args):
     296        self.end = time.time()
     297        self.duration = self.end - self.start
  • tests/test.py

    rc018b85 r0c13238  
    121121#               running test functions
    122122################################################################################
    123 # fix the absolute paths in the output
    124 def fixoutput( fname ):
    125         if not is_ascii(fname):
    126                 return
    127 
    128         file_replace(fname, "%s/" % settings.SRCDIR, "")
    129 
     123def success(val):
     124        return val == 0 or settings.dry_run
     125
     126def isExe(file):
     127        return settings.dry_run or fileIsExecutable(file)
     128
     129def noRule(file, target):
     130        return not settings.dry_run and fileContainsOnly(file, "make: *** No rule to make target `%s'.  Stop." % target)
    130131
    131132# logic to run a single test and return the result (No handling of printing or other test framework logic)
     
    143144
    144145        # build, skipping to next test on error
    145         before = time.time()
    146         make_ret, _ = make( test.target(),
    147                 redirects  = "2> %s 1> /dev/null" % out_file,
    148                 error_file = err_file
    149         )
    150         after = time.time()
    151 
    152         comp_dur = after - before
    153 
     146        with Timed() as comp_dur:
     147                make_ret, _ = make( test.target(),      redirects  = ("2> %s 1> /dev/null" % out_file), error_file = err_file )
     148
     149        # if the make command succeds continue otherwise skip to diff
    154150        run_dur = None
    155 
    156         # if the make command succeds continue otherwise skip to diff
    157         if make_ret == 0 or settings.dry_run:
    158                 before = time.time()
    159                 if settings.dry_run or fileIsExecutable(exe_file) :
    160                         # run test
    161                         retcode, _ = sh("timeout %d %s > %s 2>&1" % (settings.timeout.single, exe_file, out_file), input = in_file)
    162                 else :
    163                         # simply cat the result into the output
    164                         retcode, _ = sh("cat %s > %s" % (exe_file, out_file))
    165 
    166                 after = time.time()
    167                 run_dur = after - before
     151        if success(make_ret):
     152                with Timed() as run_dur:
     153                        if isExe(exe_file):
     154                                # run test
     155                                retcode = run(exe_file, out_file, in_file)
     156                        else :
     157                                # simply cat the result into the output
     158                                retcode = cat(exe_file, out_file)
    168159        else:
    169                 retcode, _ = sh("mv %s %s" % (err_file, out_file))
    170 
    171 
    172         if retcode == 0:
    173                 # fixoutput(out_file)
     160                retcode = mv(err_file, out_file)
     161
     162        if success(retcode):
    174163                if settings.generating :
    175164                        # if we are ounly generating the output we still need to check that the test actually exists
    176                         if not settings.dry_run and fileContainsOnly(out_file, "make: *** No rule to make target `%s'.  Stop." % test.target()) :
    177                                 retcode = 1;
     165                        if noRule(out_file, test.target()) :
     166                                retcode = 1
    178167                                error = "\t\tNo make target for test %s!" % test.target()
    179                                 sh("rm %s" % out_file, False)
     168                                rm(out_file)
    180169                        else:
    181170                                error = None
     
    188177                        error = myfile.read()
    189178
     179                ret, info = coreInfo(exe_file)
     180                error = error + info
     181
     182
    190183
    191184        # clean the executable
    192         sh("rm -f %s > /dev/null 2>&1" % test.target())
    193 
    194         return retcode, error, [comp_dur, run_dur]
     185        rm(exe_file)
     186
     187        return retcode, error, [comp_dur.duration, run_dur.duration if run_dur else None]
    195188
    196189# run a single test and handle the errors, outputs, printing, exception handling, etc.
     
    199192        with SignalHandling():
    200193                # print formated name
    201                 name_txt = "%20s  " % t.name
     194                name_txt = "%24s  " % t.name
    202195
    203196                retcode, error, duration = run_single_test(t)
     
    263256        allTests = listTests( options.include, options.exclude )
    264257
     258
    265259        # if user wants all tests than no other treatement of the test list is required
    266260        if options.all or options.list or options.list_comp or options.include :
Note: See TracChangeset for help on using the changeset viewer.