示例#1
0
def symbolic (filee, inputs, analysis, jalangi=util.DEFAULT_INSTALL):
    try:
        shutil.rmtree("jalangi_tmp")
    except: pass
    os.mkdir("jalangi_tmp")
    os.putenv("JALANGI_HOME", jalangi.get_home())
    os.chdir("jalangi_tmp")
    (instrumented_f, out) = instrument(os.path.join(os.pardir,filee), jalangi=jalangi)
    i = 0
    iters = 1
    while i <= iters and i <= inputs:
        try:                    # Ignore failures on first iteration
            os.remove("inputs.js")
        except:
            pass
        if not os.path.isfile("inputs.js"):
            util.mkempty("inputs.js")
        util.run_node_script_std(jalangi.symbolic_script(), analysis, os.path.join(os.path.dirname(os.path.join(os.pardir,filee) + ".js"),instrumented_f), jalangi=jalangi, savestderr=True)
        try:
            iters = int(util.head("jalangi_tail",1)[0])
        except: pass
        i = i + 1
    if iters == inputs:
        print "{}.js passed".format(filee)
        with open("../jalangi_sym_test_results", 'a') as f:
         f.write("{}.js passed\n".format(filee))
    else:
        print "{}.js failed".format(filee)
        with open("../jalangi_sym_test_results", 'a') as f:
         f.write("{}.js failed\n".format(filee))
    print "Tests Generated = {}".format(iters)
示例#2
0
def rerunall(filee, jalangi=util.DEFAULT_INSTALL):
    os.chdir("jalangi_tmp")
    try:
        shutil.rmtree(".coverage_data")
        os.remove("inputs.js")
        util.mkempty("inputs.js")
    except:
        pass
    print "---- Runing tests on {} ----".format(filee)
    util.run_node_script_std(os.path.join(os.pardir, filee + ".js"),
                             jalangi=jalangi)
    for i in glob.glob("jalangi_inputs*"):
        print "Running {} on {}".format(filee, i)
        shutil.copy(i, "inputs.js")
        util.run_node_script_std(os.path.join(os.pardir, filee + ".js"),
                                 jalangi=jalangi,
                                 savestderr=True)
    if jalangi.coverage():
        time.sleep(2)
        os.system("cover combine")
        os.system("cover report html")
        shutil.copy("cover_html/index.html", "../jalangi/out/out.html")
        for x in glob.glob("cover_html/*.*"):
            shutil.copy(x, "../jalangi/out/".format(x))
        print "Test results are in {}".format("cover_html/index.html")
示例#3
0
def instrument(filee,output_dir=".",jalangi=util.DEFAULT_INSTALL):
    """
    Invoke Jalangi and instrument the file
    returns: A tuple of the filename of the instrumented version and the output of Jalangi
    """
    print "---- Instrumenting {} ----" .format(filee)
    util.run_node_script_std(jalangi.instrumentation_script(), "--initIID", filee + ".js",  jalangi=jalangi)
    return (os.path.basename(filee) + "_jalangi_.js", "")
示例#4
0
def app_instrument(filee,jalangi=util.DEFAULT_INSTALL):
    print "---- Instrumenting {} ----" .format(filee)
    util.run_node_script_std(jalangi.inst_dir_script(),
                             '--direct_in_output',
                             '--selenium',
                             '--copy_runtime',
                             '--outputDir', '.',
                             filee, jalangi=jalangi)
    return (".", "")
示例#5
0
def instrument(filee, output_dir=".", jalangi=util.DEFAULT_INSTALL):
    """
    Invoke Jalangi and instrument the file
    returns: A tuple of the filename of the instrumented version and the output of Jalangi
    """
    print "---- Instrumenting {} ----".format(filee)
    util.run_node_script_std(jalangi.instrumentation_script(),
                             "--initIID",
                             filee + ".js",
                             jalangi=jalangi)
    return (os.path.basename(filee) + "_jalangi_.js", "")
示例#6
0
def app_instrument(filee, jalangi=util.DEFAULT_INSTALL):
    print "---- Instrumenting {} ----".format(filee)
    util.run_node_script_std(jalangi.inst_dir_script(),
                             '--direct_in_output',
                             '--selenium',
                             '--copy_runtime',
                             '--outputDir',
                             '.',
                             filee,
                             jalangi=jalangi)
    return (".", "")
示例#7
0
def concolic (filee, inputs, jalangi=util.DEFAULT_INSTALL):
    try:
        shutil.rmtree("jalangi_tmp")
    except: pass
    os.mkdir("jalangi_tmp")
    os.mkdir("jalangi_tmp/out")
    os.putenv("JALANGI_HOME", jalangi.get_home())
    os.chdir("jalangi_tmp")
    (instrumented_f, out) = instrument(os.path.join(os.pardir,filee), jalangi=jalangi)
    i = 0
    iters = 0
    while i <= iters and i <= inputs:
        try: # Ignore failures on first iteration
            os.remove("inputs.js")
            shutil.copy("jalangi_inputs{}.js".format(i), "inputs.js")
        except:
            pass
        if not os.path.isfile("inputs.js"):
            util.mkempty("inputs.js")
        print "==== Input {} ====".format(i)
        print "---- Recording execution of {} ----".format(filee)
        os.putenv("JALANGI_MODE", "record")
        os.putenv("JALANGI_ANALYSIS", "none")
        util.run_node_script_std(os.path.join(os.path.dirname(os.path.join(os.pardir,filee) + ".js"),instrumented_f), jalangi=jalangi)
        print "---- Replaying {} ----".format(filee)
        os.putenv("JALANGI_MODE", "replay")
        os.putenv("JALANGI_ANALYSIS", "analyses/concolic/SymbolicEngine")
        util.run_node_script_std(jalangi.replay_script(), jalangi=jalangi)
        
        try:
            iters = int(util.head("jalangi_tail",1)[0])
        except: pass
        i = i + 1
        
    for i in glob.glob("jalangi_inputs*"):
        print "*** Generated (jalangi_tmp/{}:1:1) for ({}.js:1:1)".format(i,filee)
    iters = iters + 1
    if iters == inputs:
        print "{}.js passed".format(filee)
        with open("../jalangi_sym_test_results", 'a') as f:
         f.write("{}.js passed\n".format(filee))
    else:
        print "{}.js failed".format(filee)
        with open("../jalangi_sym_test_results", 'a') as f:
         f.write("{}.js failed\n".format(filee))
    util.move_coverage(jalangi)
示例#8
0
def analysis(analysis, filee, jalangi=util.DEFAULT_INSTALL):
    try:
        shutil.rmtree("jalangi_tmp")
    except: pass
    os.mkdir("jalangi_tmp")
    os.chdir("jalangi_tmp")
    #Instrument file first
    (instrumented_f,out) = instrument(filee, jalangi=jalangi)
    util.mkempty("inputs.js")
    print "---- Recording execution of {} ----".format(filee)
    os.putenv("JALANGI_MODE", "record")
    os.putenv("JALANGI_ANALYSIS", "none")
    util.run_node_script_std(os.path.join(os.path.dirname(filee + ".js"),instrumented_f), jalangi=jalangi)
    print "---- Replaying {} ----".format(filee)
    os.putenv("JALANGI_MODE", "replay")
    os.putenv("JALANGI_ANALYSIS", analysis)
    util.run_node_script_std(jalangi.replay_script(), jalangi=jalangi)
    util.move_coverage(jalangi)
示例#9
0
def symbolic(filee, inputs, analysis, jalangi=util.DEFAULT_INSTALL):
    try:
        shutil.rmtree("jalangi_tmp")
    except:
        pass
    os.mkdir("jalangi_tmp")
    os.putenv("JALANGI_HOME", jalangi.get_home())
    os.chdir("jalangi_tmp")
    (instrumented_f, out) = instrument(os.path.join(os.pardir, filee),
                                       jalangi=jalangi)
    i = 0
    iters = 1
    while i <= iters and i <= inputs:
        try:  # Ignore failures on first iteration
            os.remove("inputs.js")
        except:
            pass
        if not os.path.isfile("inputs.js"):
            util.mkempty("inputs.js")
        util.run_node_script_std(
            jalangi.symbolic_script(),
            analysis,
            os.path.join(
                os.path.dirname(os.path.join(os.pardir, filee) + ".js"),
                instrumented_f),
            jalangi=jalangi,
            savestderr=True)
        try:
            iters = int(util.head("jalangi_tail", 1)[0])
        except:
            pass
        i = i + 1
    if iters == inputs:
        print "{}.js passed".format(filee)
        with open("../jalangi_sym_test_results", 'a') as f:
            f.write("{}.js passed\n".format(filee))
    else:
        print "{}.js failed".format(filee)
        with open("../jalangi_sym_test_results", 'a') as f:
            f.write("{}.js failed\n".format(filee))
    print "Tests Generated = {}".format(iters)
示例#10
0
def rerunall(filee, jalangi=util.DEFAULT_INSTALL):
    os.chdir("jalangi_tmp")
    try:
        shutil.rmtree(".coverage_data")
        os.remove("inputs.js")
        util.mkempty("inputs.js")
    except: pass
    print "---- Runing tests on {} ----".format(filee)
    util.run_node_script_std(os.path.join(os.pardir, filee + ".js"), jalangi=jalangi)
    for i in glob.glob("jalangi_inputs*"):
        print "Running {} on {}".format(filee, i)
        shutil.copy(i, "inputs.js")
        util.run_node_script_std(os.path.join(os.pardir,filee +".js"), jalangi=jalangi, savestderr=True)
    if jalangi.coverage():
        time.sleep(2)
        os.system("cover combine")
        os.system("cover report html")
        shutil.copy("cover_html/index.html","../jalangi/out/out.html")
        for x in glob.glob("cover_html/*.*"):
            shutil.copy(x,  "../jalangi/out/".format(x))
        print "Test results are in {}".format("cover_html/index.html")