Changeset afe8882


Ignore:
Timestamp:
Aug 15, 2018, 3:51:12 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
bdff89d
Parents:
7bd4cc9
Message:

Fixed calling tests from outside directory and added arguments to change test timeouts (still can't be configured for a specific test)

Location:
tests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tests/config.py.in

    r7bd4cc9 rafe8882  
    55"""
    66
    7 SRCDIR   = "@srcdir@"
    8 BUILDDIR = "@builddir@"
     7SRCDIR   = "@abs_srcdir@"
     8BUILDDIR = "@abs_builddir@"
    99HOSTARCH = "@host_cpu@"
  • tests/pybin/settings.py

    r7bd4cc9 rafe8882  
    66
    77try :
    8         sys.path.append(os.getcwd())
     8        testpath = os.path.dirname(os.path.abspath(os.path.join(os.getcwd(), sys.argv[0])))
     9        sys.path.append(testpath)
    910        import config
    1011
    1112        SRCDIR = os.path.abspath(config.SRCDIR)
    1213        BUILDDIR = os.path.abspath(config.BUILDDIR)
     14        os.chdir(testpath)
     15
    1316except:
    1417        print('ERROR: missing config.py, re-run configure script.', file=sys.stderr)
     
    8891                self.flags  = """INSTALL_FLAGS="%s" """ % ("" if value else "-in-tree")
    8992
     93class Timeouts:
     94        def __init__(self, ts, tg):
     95                self.single = Timeouts.check(ts)
     96                self.total  = Timeouts.check(tg)
     97
     98        @classmethod
     99        def check(_, value):
     100                if value < 1:
     101                        print("Timeouts must be at least 1 second", file=sys.stderr)
     102                        sys.exit(1)
     103
     104                return value
     105
    90106def init( options ):
    91107        global arch
     
    95111        global debug
    96112        global install
     113        global timeout
    97114
    98115        dry_run    = options.dry_run
     
    102119        install    = Install(options.install)
    103120        arch       = Architecture(options.arch)
     121        timeout    = Timeouts(options.timeout, options.global_timeout)
    104122
    105123
     
    110128
    111129def validate():
    112         make_ret, _ = tools.make( ".validate", error_file = ".validate.err", redirects  = "2> /dev/null 1> /dev/null", )
     130        errf = os.path.join(BUILDDIR, ".validate.err")
     131        make_ret, _ = tools.make( ".validate", error_file = errf, redirects  = "2> /dev/null 1> /dev/null", )
    113132        if make_ret != 0:
    114                 with open (".validate.err", "r") as myfile:
     133                with open (errf, "r") as myfile:
    115134                        error=myfile.read()
    116135                print("ERROR: Invalid configuration %s:%s" % (arch.string, debug.string), file=sys.stderr)
    117136                print("       verify returned : \n%s" % error, file=sys.stderr)
    118                 tools.rm("%s/.validate.err" % BUILDDIR)
     137                tools.rm(errf)
    119138                sys.exit(1)
    120139
    121         tools.rm("%s/.validate.err" % BUILDDIR)
     140        tools.rm(errf)
  • tests/test.py

    r7bd4cc9 rafe8882  
    8888        parser.add_argument('--install', help='Run all tests based on installed binaries or tree binaries', type=yes_no, default='no')
    8989        parser.add_argument('--arch', help='Test for specific architecture', type=str, default='')
     90        parser.add_argument('--timeout', help='Maximum duration in seconds after a single test is considered to have timed out', type=int, default=60)
     91        parser.add_argument('--global-timeout', help='Maximum cumulative duration in seconds after the ALL tests are considered to have timed out', type=int, default=7200)
    9092        parser.add_argument('--dry-run', help='Don\'t run the tests, only output the commands', action='store_true')
    9193        parser.add_argument('--list', help='List all test available', action='store_true')
     
    160162                if settings.dry_run or fileIsExecutable(exe_file) :
    161163                        # run test
    162                         retcode, _ = sh("timeout 60 %s > %s 2>&1" % (exe_file, out_file), input = in_file)
     164                        retcode, _ = sh("timeout %d %s > %s 2>&1" % (settings.timeout.single, exe_file, out_file), input = in_file)
    163165                else :
    164166                        # simply cat the result into the output
     
    234236                        tests,
    235237                        chunksize = 1
    236                 ).get(7200)
     238                ).get(settings.timeout.total)
    237239        except KeyboardInterrupt:
    238240                pool.terminate()
     
    283285        # users may want to simply list the tests
    284286        if options.list_comp :
    285                 print("-h --help --debug --dry-run --list --arch --all --regenerate-expected -j --jobs ", end='')
     287                print("-h --help --debug --dry-run --list --arch --all --regenerate-expected --install --timeout --global-timeout -j --jobs ", end='')
    286288                print(" ".join(map(lambda t: "%s" % (t.target()), tests)))
    287289
Note: See TracChangeset for help on using the changeset viewer.