Esempio n. 1
0
def run():
    '''
    Runs the Z3-translator on each pair (file, numInstances) in tests, 
    and ensures that the number of generated models equals numInstances.
    '''
    clock = Clock()
    tests = getTestSet()
    num_passed = 0
    exceptions = 0
    exception_list = []
    failed_list = []
    temp_model_count = Options.NUM_INSTANCES
    for t in tests:
        (file, expected_model_count) = t
        try:
            if expected_model_count == Options.INFINITE and Options.NUM_INSTANCES < 0:
                #will change it back after the test runs
                Options.NUM_INSTANCES = 5
            
            module = file.getModule()
            print_separate("Attempting: " + str(file.__name__))
            clock.tick("Total Z3 Run Time")
            cfr = ClaferModel(module)
            actual_model_count = cfr.run()
            clock.tack("Total Z3 Run Time")
            clock = clock.combineClocks(cfr.clock)
            if(expected_model_count == actual_model_count or 
               (expected_model_count == Options.INFINITE and actual_model_count == Options.NUM_INSTANCES)):
                print("PASSED: " + str(file.__name__))
                num_passed = num_passed + 1
            else:
                failed_list.append(str(file.__name__))
                print("FAILED: " + str(file.__name__) + " " + str(expected_model_count) + " " + str(actual_model_count))
        except:
            print("FAILED: " + str(file.__name__) + " " + "\nException raised.")
            traceback.print_exc()
            exception_list.append(str(file.__name__))
            exceptions = exceptions + 1
        Options.NUM_INSTANCES = temp_model_count    
    print_separate("Results: " + str(num_passed) + "/" + str(len(tests)) + "\n| " + 
                   "Failed List: " + str(failed_list) + "\n| " +
                   "Exceptions: " + str(exceptions) + "/" + str(len(tests)) + "\n| " +
                   "Exception List: " + str(exception_list))
    clock.printEvents()