Esempio n. 1
0
def run(filename, debug, verbose, flags, env):
    args = ((['-mg'] if debug else []) +
            [os.path.basename(filename)] + flags +
            ([] if verbose else ['-level', '5']))
    if verbose: print('Running', ' '.join(args))
    proc = regent.regent(
        args,
        stdout=None if verbose else subprocess.PIPE,
        stderr=None if verbose else subprocess.STDOUT,
        env=env,
        cwd=os.path.dirname(os.path.abspath(filename)))
    try:
        output, _ = proc.communicate()
        retcode = proc.wait()
    except (KeyboardInterrupt, TestTimeoutException):
        if verbose: print('terminating child process...')
        proc.terminate()
        maxtime = 15
        while True:
            retcode = proc.poll()
            if retcode is not None:
                break
            if maxtime > 0:
                time.sleep(0.1)
                maxtime = maxtime - 0.1
            else:
                print('Child process failed to terminate - sending SIGKILL')
                proc.kill()
                break
        raise
    if retcode != 0:
        raise TestFailure(' '.join(args), output.decode('utf-8') if output is not None else None)
    return ' '.join(args)
Esempio n. 2
0
def run(filename, debug, verbose, flags, env):
    args = ((['-mg'] if debug else []) +
            [os.path.basename(filename)] + flags +
            ([] if verbose else ['-level', '5']))
    if verbose: print('Running', ' '.join(args))
    proc = regent.regent(
        args,
        stdout=None if verbose else subprocess.PIPE,
        stderr=None if verbose else subprocess.STDOUT,
        env=env,
        cwd=os.path.dirname(os.path.abspath(filename)))
    try:
        output, _ = proc.communicate()
        retcode = proc.wait()
    except (KeyboardInterrupt, TestTimeoutException):
        if verbose: print('terminating child process...')
        proc.terminate()
        maxtime = 15
        while True:
            retcode = proc.poll()
            if retcode is not None:
                break
            if maxtime > 0:
                time.sleep(0.1)
                maxtime = maxtime - 0.1
            else:
                print('Child process failed to terminate - sending SIGKILL')
                proc.kill()
                break
        raise
    if retcode != 0:
        raise TestFailure(' '.join(args), output.decode('utf-8') if output is not None else None)
    return ' '.join(args)
Esempio n. 3
0
def run(filename, debug, verbose, flags):
    args = ((['-mg'] if debug else []) + [os.path.basename(filename)] + flags +
            ([] if verbose else ['-level', '5']))
    proc = regent.regent(args,
                         stdout=None if verbose else subprocess.PIPE,
                         stderr=None if verbose else subprocess.STDOUT,
                         cwd=os.path.dirname(os.path.abspath(filename)))
    output, _ = proc.communicate()
    retcode = proc.wait()
    if retcode != 0:
        raise TestFailure(' '.join(args), output.decode('utf-8'))
Esempio n. 4
0
def run(filename, verbose, flags):
    args = [os.path.basename(filename)] + flags + ([] if verbose else ["-level", "5"])
    proc = regent.regent(
        args,
        stdout=None if verbose else subprocess.PIPE,
        stderr=None if verbose else subprocess.STDOUT,
        cwd=os.path.dirname(os.path.abspath(filename)),
    )
    output, _ = proc.communicate()
    retcode = proc.wait()
    if retcode != 0:
        raise TestFailure(" ".join(args), str(output))
Esempio n. 5
0
def run(filename, debug, verbose, flags):
    args = ((['-mg'] if debug else []) +
            [os.path.basename(filename)] + flags +
            ([] if verbose else ['-level', '5']))
    proc = regent.regent(
        args,
        stdout = None if verbose else subprocess.PIPE,
        stderr = None if verbose else subprocess.STDOUT,
        cwd = os.path.dirname(os.path.abspath(filename)))
    output, _ = proc.communicate()
    retcode = proc.wait()
    if retcode != 0:
        raise TestFailure(' '.join(args), output.decode('utf-8'))
Esempio n. 6
0
def run(filename, debug, verbose, timelimit, flags, env):
    args = ((['-mg'] if debug else []) + [os.path.basename(filename)] + flags +
            ([] if verbose else ['-level', 'runtime=5,threads=5']))
    if verbose: print('Running', ' '.join(args))

    def set_timeout():
        # set hard limit above soft limit so we might get SIGXCPU return code
        resource.setrlimit(resource.RLIMIT_CPU, (timelimit, timelimit + 1))

    proc = regent.regent(args,
                         stdout=None if verbose else subprocess.PIPE,
                         stderr=None if verbose else subprocess.STDOUT,
                         env=env,
                         cwd=os.path.dirname(os.path.abspath(filename)),
                         preexec_fn=set_timeout)
    try:
        output, _ = proc.communicate()
        retcode = proc.wait()
    except KeyboardInterrupt:
        if verbose: print('terminating child process...')
        proc.terminate()
        maxtime = 15
        while True:
            retcode = proc.poll()
            if retcode is not None:
                break
            if maxtime > 0:
                time.sleep(0.1)
                maxtime = maxtime - 0.1
            else:
                print('Child process failed to terminate - sending SIGKILL')
                proc.kill()
                break
        raise
    if retcode != 0:
        raise TestFailure(
            ' '.join(args), retcode,
            output.decode('utf-8') if output is not None else None)
    return ' '.join(args)