Exemplo n.º 1
0
def run_replay(testfile, inputfiles, reporterrors, settings):
    for filename in [testfile] + inputfiles:
        if not os.path.isfile(filename):
            print('Error:', filename, 'does not exist!')
            return

    t = Test(testfile, settings)

    if settings['verbose']:
        print 'Running test ' + testfile
    t.reset()
    t.replay(inputfiles)

    try:
        result = t.run(reporterrors)
        if result == True:
            return True
        else:
            return False
    except ToolInputError as e:
        print 'Result: ' + next(x for x in e.value.split('\n') if 'error' in x)
    except UnusedToolsError as e:
        print 'Result: UnusedToolsError'
    except ToolCrashedError as e:
        print 'Result: ToolCrashedError'
    except MemoryExceededError as e:
        print 'Result: Memory Exceeded'
    except TimeExceededError as e:
        print 'Result: Time Exceeded'
Exemplo n.º 2
0
t = Test(testfile, settings)

grammarfiles = t.options['grammar']
constraintsfiles = t.options['constraints']

constraints = yaml.load(''.join([open(f).read() for f in constraintsfiles]))
grammar = ''.join([open(f).read() for f in grammarfiles])
generator = randgen.RandGen(grammar, constraints)

if not t.validTermLengths(generator, termlength):
    print 'invalid term length: ' + str(termlength)
else:
    for i in range(numtests):
        if settings['verbose']:
            print 'Running test ' + testfile
        t.reset()
        t.initialize(generator, termlength)

        try:

            result = t.run(reporterrors)
            if result == True:
                print 'Result: success'
            else:
                print 'Result: failed'

        except ToolInputError as e:
            print 'Result: ' + next(x for x in e.value.split('\n') if 'error' in x)

        except UnusedToolsError as e:
            print 'Result: UnusedToolsError'