This commit is contained in:
anil
2020-08-19 14:56:03 +02:00
2 changed files with 340 additions and 158 deletions
+19 -17
View File
@@ -56,25 +56,27 @@ def export():
if not os.path.exists(join(BUGDIR)):
os.mkdir(join(BUGDIR))
cmd = 'bugzoo bug list | grep Yes'
o,e = shellGitCheckout(cmd)
# cmd = 'bugzoo bug list | grep Yes'
# o,e = shellGitCheckout(cmd)
#
# # if o =='':
# # with open(join(DATA_PATH,'bugzooList'),mode='r') as b:
# # o = b.read()
#
# bugList = []
# for line in o.split('\n'):
# if(line.strip() == ''):
# continue
# bugList.append(line.split('|')[1].strip())
# bugList
# # bugList = [i.replace(':', '-').replace('manybugs-', 'squareslab/manybugs:') for i in bugList]
# # exportCore(bugList[0])
# # print("bugList length: {}".format(len(bugList)))
if o =='':
with open(join(DATA_PATH,'bugzooList'),mode='r') as b:
o = b.read()
bugList = []
for line in o.split('\n'):
if(line.strip() == ''):
continue
bugList.append(line.split('|')[1].strip())
bugList
# bugList = [i.replace(':', '-').replace('manybugs-', 'squareslab/manybugs:') for i in bugList]
# exportCore(bugList[0])
# print("bugList length: {}".format(len(bugList)))
bugList = ['manybugs:gmp:14166-14167','manybugs:gzip:2009-08-16-3fe0caeada-39a362ae9d','manybugs:gzip:2009-10-09-1a085b1446-118a107f2d','manybugs:gzip:2010-02-19-3eb6091d69-884ef6d16c','manybugs:libtiff:2005-12-21-3b848a7-3edb9cd','manybugs:libtiff:2006-02-23-b2ce5d8-207c78a','manybugs:libtiff:2006-03-03-a72cf60-0a36d7f','manybugs:libtiff:2006-03-03-eec4c06-ee65c74','manybugs:libtiff:2007-07-13-09e8220-f2d989d','manybugs:libtiff:2007-11-02-371336d-865f7b2','manybugs:libtiff:2009-02-05-764dbba-2e42d63','manybugs:libtiff:2009-08-28-e8a47d4-023b6df','manybugs:libtiff:2010-11-27-eb326f9-eec7ec0','manybugs:lighttpd:1948-1949','manybugs:lighttpd:2254-2259','manybugs:lighttpd:2661-2662','manybugs:lighttpd:2785-2786','manybugs:php:2011-03-25-8138f7de40-3acdca4703','manybugs:php:2011-04-02-70075bc84c-5a8c917c37','manybugs:php:2011-11-19-eeba0b5681-d3b20b4058','manybugs:php:2011-12-04-1e6a82a1cf-dfa08dc325','manybugs:php:2011-12-10-74343ca506-52c36e60c4','manybugs:php:2012-02-08-ff63c09e6f-6672171672']
for b in [b for b in bugList if b in sosbugs]:
# for b in [b for b in bugList if b in sosbugs]:
for b in [b for b in sosbugs]:
# cmd = 'bugzoo bug build ' + b
# o,e = shellGitCheckout(cmd)
# print(o)
+321 -141
View File
@@ -5,6 +5,70 @@ import os
from common.commons import *
DATA_PATH = os.environ["DATA_PATH"]
ROOT_DIR = os.environ["ROOT_DIR"]
DATASET = os.environ["dataset"]
COCCI_PATH = join(os.environ["coccinelle"],'spatch')
def patchSourceFile(bugPath,spfile,bugName):
# print(bugPath)
srcName = bugPath.split('/')[-1].split('-')[0]
srcPath = bugPath
patchName = srcName
if(isfile(join(DATA_PATH,"manybugs",bugName,'patched',patchName+spfile+'.c'))):
return join(DATA_PATH,"manybugs",bugName,'patched',patchName+spfile+'.c')
if not (isfile(join(DATA_PATH,"manybugs",bugName,'patches',patchName+spfile+'.txt'))):
cmd = COCCI_PATH + ' --sp-file ' + join(DATASET, 'cocci', spfile) + ' ' + srcPath + ' --patch -o' + join(
DATA_PATH, "manybugs", bugName, 'patches', patchName) + ' > ' + join(DATA_PATH, "manybugs", bugName,
'patches',
patchName + spfile + '.txt')
output, e = shellGitCheckout(cmd)
# logging.info(output)
patchSize = os.path.getsize(join(DATA_PATH,"manybugs",bugName,'patches',patchName+spfile+'.txt'))
if patchSize == 0 :
# os.remove(join(DATA_PATH,"introclass",bugName,'patches',patchName+spfile+'.txt'))
return None
else:
cmd = 'patch -d '+'/'.join(srcPath.split('/')[:-1])+' -i '+join(DATA_PATH,"manybugs",bugName,'patches',patchName+spfile+'.txt')+' -o '+join(DATA_PATH,"manybugs",bugName,'patched',patchName+spfile+'.c')
o,e = shellGitCheckout(cmd)
return join(DATA_PATH, "manybugs", bugName, 'patched', patchName + spfile + '.c')
sosbugs = ['manybugs:gmp:14166-14167', 'manybugs:gzip:2009-08-16-3fe0caeada-39a362ae9d',
'manybugs:gzip:2009-10-09-1a085b1446-118a107f2d', 'manybugs:gzip:2010-02-19-3eb6091d69-884ef6d16c',
'manybugs:libtiff:2005-12-21-3b848a7-3edb9cd', 'manybugs:libtiff:2006-03-03-a72cf60-0a36d7f',
'manybugs:libtiff:2006-03-03-eec4c06-ee65c74', 'manybugs:libtiff:2007-07-13-09e8220-f2d989d',
'manybugs:libtiff:2007-11-02-371336d-865f7b2', 'manybugs:libtiff:2009-02-05-764dbba-2e42d63',
'manybugs:libtiff:2009-08-28-e8a47d4-023b6df', 'manybugs:libtiff:2010-11-27-eb326f9-eec7ec0',
'manybugs:libtiff:2006-02-23-b2ce5d8-207c78a', 'manybugs:lighttpd:2661-2662', 'manybugs:lighttpd:2254-2259',
'manybugs:lighttpd:2785-2786', 'manybugs:lighttpd:1948-1949',
'manybugs:php:2011-12-10-74343ca506-52c36e60c4', 'manybugs:php:2011-04-02-70075bc84c-5a8c917c37',
'manybugs:php:2011-03-25-8138f7de40-3acdca4703', 'manybugs:php:2011-12-04-1e6a82a1cf-dfa08dc325',
'manybugs:php:2012-02-08-ff63c09e6f-6672171672', 'manybugs:php:2011-11-19-eeba0b5681-d3b20b4058',
'manybugs:php:2011-04-07-77ed819430-efcb9a71cd', 'manybugs:php:2011-02-01-01745fa657-1f49902999',
'manybugs:php:2012-03-12-7aefbf70a8-efc94f3115', 'manybugs:php:2011-10-15-0a1cc5f01c-05c5c8958e',
'manybugs:php:2011-01-30-5bb0a44e06-1e91069eb4', 'manybugs:php:2011-02-01-fefe9fc5c7-0927309852',
'manybugs:php:2011-02-27-e65d361fde-1d984a7ffd', 'manybugs:php:2011-03-19-5d0c948296-8deb11c0c3',
'manybugs:php:2011-03-23-63673a533f-2adf58cfcf', 'manybugs:php:2011-04-06-187eb235fe-2e25ec9eb7',
'manybugs:php:2011-04-09-db01e840c2-09b990f499', 'manybugs:php:2011-05-17-453c954f8a-daecb2c0f4',
'manybugs:php:2011-05-24-b60f6774dc-1056c57fa9', 'manybugs:php:2011-10-16-1f78177e2b-d4ae4e79db',
'manybugs:php:2011-10-31-2e5d5e5ac6-b5f15ef561', 'manybugs:php:2011-10-31-c4eb5f2387-2e5d5e5ac6',
'manybugs:php:2011-11-01-ceac9dc490-9b0d73af1d', 'manybugs:php:2011-11-11-fcbfbea8d2-c1e510aea8',
'manybugs:php:2011-11-15-236120d80e-fb37f3b20d', 'manybugs:php:2011-11-16-55acfdf7bd-3c7a573a2c',
'manybugs:php:2011-11-22-ecc6c335c5-b548293b99', 'manybugs:php:2011-11-23-eca88d3064-db0888dfc1',
'manybugs:php:2012-01-27-544e36dfff-acaf9c5227', 'manybugs:php:2012-01-30-9de5b6dc7c-4dc8b1ad11',
'manybugs:php:2012-02-25-c1322d2505-cfa9c90b20', 'manybugs:php:2012-03-04-60dfd64bf2-34fe62619d',
'manybugs:php:2012-03-08-0169020e49-cdc512afb3', 'manybugs:php:2012-03-11-3954743813-d4f05fbffc',
'manybugs:php:2012-03-12-438a30f1e7-7337a901b7', 'manybugs:python:69223-69224',
'manybugs:python:69368-69372', 'manybugs:python:70098-70101', 'manybugs:python:70056-70059',
'manybugs:wireshark:37112-37111', 'manybugs:wireshark:37122-37123', 'manybugs:gmp:13420-13421',
'manybugs:gzip:2009-09-26-a1d3d4019d-f17cbd13a1', 'manybugs:lighttpd:1913-1914',
'manybugs:php:2011-11-19-51a4ae6576-bc810a443d', 'manybugs:php:2011-03-11-d890ece3fc-6e74d95f34',
'manybugs:php:2011-11-19-eeba0b5681-f330c8ab4e', 'manybugs:php:2012-01-01-80dd931d40-7c3177e5ab']
def readTestSuite(testPath):
regex = r"([p|n0-9]+)\)"
with open(testPath,mode='r') as testFile:
@@ -18,112 +82,232 @@ def readTestSuite(testPath):
groupNum = groupNum + 1
testList.append(match.group(groupNum))
return testList
def myvalidateCore(t):
bugName, port = t
container = None
with bugzoo.server.ephemeral(port=port, verbose=False, timeout_connection=30000) as client:
try:
# def myvalidateCore(t):
# bugName, port = t
# container = None
# with bugzoo.server.ephemeral(port=port, verbose=False, timeout_connection=30000) as client:
# try:
#
# bug = client.bugs[bugName]
# if client.bugs.is_installed(bug):
# pass
# else:
# client.bugs.build(bug)
# fix = 'failure'
# output = ''
# output += 'bugName:' + bugName + ', '
# container = client.containers.provision(bug)
# # output += 'First_test:'
#
# preId, postId = bugName.split(':')[-1].split('-')[-2:]
# originalBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), preId)
# # for ob in originalBugs:
# # filepath = ob.split('diffs')[-1]
# # cmd = 'cp /experiment/diffs' + filepath + ' src' + filepath.replace('-' + preId, '')
# # client.containers.exec(container=container, command=cmd, context='/experiment/')
#
# validTests = readTestSuite(join(DATA_PATH, 'manybugs', bugName, 'test.sh'))
# output += 'total ' + str(len(bug.tests._tests)) + ' newtotal ' + str(len(validTests))
# # client.containers.build(container)
# # pre_failure_cases, pre_failure, total, pre_test_outcomes = test_all(bug, container, client,validTests)
# # if pre_failure == 0:
# # logging.error(bugName + ' no failed test initially')
# # return ''
# # output += '@fail:' + ','.join(pre_failure) + '@total:' + str(total) + ', ' + '@newtotal:' + str(len(validTests)) + ', '
# #
# # fixBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), postId)
# # for ob in fixBugs:
# # filepath = ob.split('diffs')[-1]
# # cmd = 'cp /experiment/diffs' + filepath + ' src' + filepath.replace('-' + postId, '')
# # client.containers.exec(container=container, command=cmd, context='/experiment/')
# # client.containers.build(container)
# # diff_files = get_diff(bug.name, client, container)
# # patch_result = patch_application(client, container, diff_files)
# # if not patch_result:
# # print("@{}@".format(patch_result))
# # continue
# # print("@{}@".format(patch_result),end=' ')
# #
# #
# # print("Second_test:",end=' ')
# # post_test_outcomes = {}
# # post_failure_cases, post_failure, total, post_test_outcomes = test_all(bug, container, client,validTests)
# # output += ','.join(post_failure) + ' '
# # if len(post_failure) == 0:
# # # times += 1
# # fix = 'success'
# # # print("fix {} by {}".format(bugName, patch_name))
# # output += 'fix {} '.format(bugName)
#
#
# # patch_names = os.listdir(join(DATA_PATH,'manybugs',bugName,'patched'))
# # patch_names = [i for i in patch_names if not i.endswith('.DS_Store')]
# # if len(originalBugs) != 1:
# # members = []
# #
# # for member in set([i.split('-')[0] for i in patch_names]):
# # members.append([i for i in patch_names if i.startswith(member)])
# #
# # patch_names= list(itertools.product(*members))
# # patch_names
# # times = 0
# # for patch_name in patch_names:
# # if isinstance(patch_name, tuple):
# # for i in patch_name:
# # copyPatch(bugName, client, container, originalBugs, i, preId)
# # else:
# # copyPatch(bugName, client, container, originalBugs, patch_name, preId)
# #
# # patch_result = client.containers.build(container)
# # if not patch_result.successful:
# # output += '@False@F '
# # continue
# # output += '@True@'
# #
# # post_test_outcomes = {}
# # post_failure_cases, post_failure, total, post_test_outcomes = test_all(bug, container, client,validTests)
# #
# # output += ','.join(post_failure) + ' '
# # if len(post_failure) == 0:
# # # times += 1
# # fix = 'success'
# # # print("fix {} by {}".format(bugName, patch_name))
# # output += 'fix {} '.format(bugName)
# #
# # output += 'times:{}, '.format(times) + fix
#
# print(output)
# return output
#
# except Exception as e:
# logging.error(e)
# # continue
# finally:
# # ''
# cmd = 'docker stop {}'.format(container.id)
# out, e = shellGitCheckout(cmd)
# # docker stop $(docker ps -q)
bug = client.bugs[bugName]
if client.bugs.is_installed(bug):
pass
def checkDataset(bugName,preId,postId,container,client,output,bug):
originalBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), preId)
for ob in originalBugs:
filepath = ob.split('diffs')[-1]
cmd = 'cp diffs' + filepath + ' src' + filepath.replace('-' + preId, '')
client.containers.exec(container=container, command=cmd, context='/experiment/')
validTests = readTestSuite(join(DATA_PATH, 'manybugs', bugName, 'test.sh'))
client.containers.build(container)
pre_failure_cases, pre_failure, total, pre_test_outcomes = test_all_(bug, container, client, validTests)
if pre_failure == 0:
logging.error(bugName + ' no failed test initially')
return ''
output += '@fail:' + ','.join(pre_failure) + '@total:' + str(total) + ', ' + '@newtotal:' + str(
len(validTests)) + ', '
fixBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), postId)
for ob in fixBugs:
filepath = ob.split('diffs')[-1]
cmd = 'cp diffs' + filepath + ' src' + filepath.replace('-' + postId, '')
client.containers.exec(container=container, command=cmd, context='/experiment/')
times = 0
name = ob
patch_result = client.containers.build(container)
if patch_result.successful:
failure_cases, failure, total, test_outcomes = test_all_(bug, container, client, validTests)
if len(failure) == 0:
times += 1
output += ' fixed by {}'.format(name)
else:
output += ' {}'.format(failure_cases)
else:
output += ' {}'.format('build error')
output += ' times:{}'.format(times)
if times > 0:
output += ' success'
else:
output += ' failure'
return output
def checkTemplates(bugName,preId,postId,container,client,output,bug):
originalBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), preId)
if not os.path.exists(join(DATA_PATH, 'manybugs', bugName, 'patches')):
os.makedirs(join(DATA_PATH, 'manybugs', bugName, 'patches'))
if not os.path.exists(join(join(DATA_PATH, 'manybugs', bugName, 'patched'))):
os.makedirs(join(DATA_PATH, 'manybugs', bugName, 'patched'))
fix = 'failure'
# for ob in originalBugs:
# filepath = ob.split('diffs')[-1]
# cmd = 'cp diffs' + filepath + ' src' + filepath.replace('-' + preId, '')
# client.containers.exec(container=container, command=cmd, context='/experiment/')
#
# validTests = readTestSuite(join(DATA_PATH, 'manybugs', bugName, 'test.sh'))
# client.containers.build(container)
# pre_failure_cases, pre_failure, total, pre_test_outcomes = test_all(bug, container, client, validTests)
# if pre_failure == 0:
# logging.error(bugName + ' no failed test initially')
# return ''
# output += '@fail:' + ','.join(pre_failure) + '@total:' + str(total) + ', ' + '@newtotal:' + str(
# len(validTests)) + ', '
# fixBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), postId)
spfiles = listdir(join(DATASET, 'cocci'))
# print("patching... " + bugName)
for idx, spfile in enumerate(spfiles):
if spfile == '.DS_Store':
continue
# path = join(DATA_PATH, 'manybugs', bugName)
path= originalBugs[0]
patch = patchSourceFile(path, spfile, bugName)
times = 0
if patch is None:
continue
# for ob in fixBugs:
cmd = 'docker cp ' + patch + ' ' + container.id + ':/experiment/src' + path.split(bugName + '/diffs')[-1].replace('-' + preId, '')
o, e = shellGitCheckout(cmd)
cmd = 'sudo chown $(whoami):$(whoami) "{}"'
cmd = cmd.format('/experiment/src' + path.split(bugName + '/diffs')[-1].replace('-' + preId, ''))
o = client.containers.exec(container=container, command=cmd, context='/experiment/')
patch_result = client.containers.build(container)
if patch_result.successful:
output += '@True:' + str(idx) + ':' + patch.split('/')[-1] + '@'
failure_cases, failure, total, test_outcomes = test_all(bug, container, client)
if failure == 0:
fix = 'success'
# print("fix {} by {}".format(bugName, patch_name))
output += 'fix {} by {} '.format(bugName, patch)
break
else:
client.bugs.build(bug)
fix = 'failure'
output = ''
output += 'bugName:' + bugName + ', '
container = client.containers.provision(bug)
# output += 'First_test:'
output += ' {}'.format(failure_cases)
else:
output += '@False:' + str(idx) + ':' + patch.split('/')[-1] + '@'
# output += ' {}'.format('build error')
# output += ' times:{}'.format(times)
# if times > 0:
# output += ' success'
# else:
# output += ' failure'
preId, postId = bugName.split(':')[-1].split('-')[-2:]
originalBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), preId)
# for ob in originalBugs:
# filepath = ob.split('diffs')[-1]
# cmd = 'cp /experiment/diffs' + filepath + ' src' + filepath.replace('-' + preId, '')
# client.containers.exec(container=container, command=cmd, context='/experiment/')
output += 'times:{}, '.format(times) + fix
validTests = readTestSuite(join(DATA_PATH, 'manybugs', bugName, 'test.sh'))
output += 'total ' + str(len(bug.tests._tests)) + ' newtotal ' + str(len(validTests))
# client.containers.build(container)
# pre_failure_cases, pre_failure, total, pre_test_outcomes = test_all(bug, container, client,validTests)
# if pre_failure == 0:
# logging.error(bugName + ' no failed test initially')
# return ''
# output += '@fail:' + ','.join(pre_failure) + '@total:' + str(total) + ', ' + '@newtotal:' + str(len(validTests)) + ', '
#
# fixBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), postId)
# for ob in fixBugs:
# filepath = ob.split('diffs')[-1]
# cmd = 'cp /experiment/diffs' + filepath + ' src' + filepath.replace('-' + postId, '')
# client.containers.exec(container=container, command=cmd, context='/experiment/')
# client.containers.build(container)
# diff_files = get_diff(bug.name, client, container)
# patch_result = patch_application(client, container, diff_files)
# if not patch_result:
# print("@{}@".format(patch_result))
# continue
# print("@{}@".format(patch_result),end=' ')
#
#
# print("Second_test:",end=' ')
# post_test_outcomes = {}
# post_failure_cases, post_failure, total, post_test_outcomes = test_all(bug, container, client,validTests)
# output += ','.join(post_failure) + ' '
# if len(post_failure) == 0:
# # times += 1
# fix = 'success'
# # print("fix {} by {}".format(bugName, patch_name))
# output += 'fix {} '.format(bugName)
return output
# patch_names = os.listdir(join(DATA_PATH,'manybugs',bugName,'patched'))
# patch_names = [i for i in patch_names if not i.endswith('.DS_Store')]
# if len(originalBugs) != 1:
# members = []
#
# for member in set([i.split('-')[0] for i in patch_names]):
# members.append([i for i in patch_names if i.startswith(member)])
#
# patch_names= list(itertools.product(*members))
# patch_names
# times = 0
# for patch_name in patch_names:
# if isinstance(patch_name, tuple):
# for i in patch_name:
# copyPatch(bugName, client, container, originalBugs, i, preId)
# else:
# copyPatch(bugName, client, container, originalBugs, patch_name, preId)
#
# patch_result = client.containers.build(container)
# if not patch_result.successful:
# output += '@False@F '
# continue
# output += '@True@'
#
# post_test_outcomes = {}
# post_failure_cases, post_failure, total, post_test_outcomes = test_all(bug, container, client,validTests)
#
# output += ','.join(post_failure) + ' '
# if len(post_failure) == 0:
# # times += 1
# fix = 'success'
# # print("fix {} by {}".format(bugName, patch_name))
# output += 'fix {} '.format(bugName)
#
# output += 'times:{}, '.format(times) + fix
print(output)
return output
except Exception as e:
logging.error(e)
# continue
finally:
# ''
cmd = 'docker stop {}'.format(container.id)
out, e = shellGitCheckout(cmd)
# docker stop $(docker ps -q)
def validateCore(t):
bugName, port = t
container = None
@@ -143,7 +327,7 @@ def validateCore(t):
pass
else:
client.bugs.build(bug)
fix = 'failure'
output = ''
output += 'bugName:' + bugName + ', '
container = client.containers.provision(bug)
@@ -169,43 +353,10 @@ def validateCore(t):
# cmd = cmd.format('passing.tests.txt')
# o = client.containers.exec(container=container, command=cmd, context='/experiment/')
originalBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), preId)
for ob in originalBugs:
filepath = ob.split('diffs')[-1]
cmd = 'cp diffs' + filepath + ' src' + filepath.replace('-' + preId, '')
client.containers.exec(container=container, command=cmd, context='/experiment/')
validTests = readTestSuite(join(DATA_PATH, 'manybugs', bugName, 'test.sh'))
client.containers.build(container)
pre_failure_cases, pre_failure, total, pre_test_outcomes = test_all(bug, container, client,validTests)
if pre_failure == 0:
logging.error(bugName + ' no failed test initially')
return ''
output += '@fail:' + ','.join(pre_failure) + '@total:' + str(total) + ', ' + '@newtotal:' + str(len(validTests)) + ', '
output = checkTemplates(bugName,preId,postId,container,client,output,bug)
# output = checkDataset(bugName,preId,postId,container,client,output,bug)
fixBugs = get_filepaths(join(DATA_PATH, 'manybugs', bugName, 'diffs'), postId)
for ob in fixBugs:
filepath = ob.split('diffs')[-1]
cmd = 'cp diffs' + filepath + ' src' + filepath.replace('-' + postId, '')
client.containers.exec(container=container, command=cmd, context='/experiment/')
times = 0
name = ob
patch_result = client.containers.build(container)
if patch_result.successful:
failure_cases, failure, total, test_outcomes = test_all(bug, container, client,validTests)
if failure == 0:
times += 1
output += ' fixed by {}'.format(name)
else:
output += ' {}'.format(failure_cases)
else:
output += ' {}'.format('build error')
output += ' times:{}'.format(times)
if times > 0:
output += ' success'
else:
output += ' failure'
# client.containers.build(container)
# diff_files = get_diff(bug.name, client, container)
# patch_result = patch_application(client, container, diff_files)
@@ -274,7 +425,8 @@ def validateCore(t):
try:
client.shutdown()
except Exception as e:
logging.error(e)
e
# logging.error(e)
# docker stop $(docker ps -q)
@@ -306,12 +458,25 @@ def patch_validate():
if isinstance(v,logging.Logger):
v.setLevel(logging.ERROR)
buglist = listdir(join(DATA_PATH,'manybugs_sos'))
# buglist = listdir(join(DATA_PATH,'manybugs_sos'))
buglist = ['manybugs:gmp:14166-14167', 'manybugs:gzip:2009-08-16-3fe0caeada-39a362ae9d',
'manybugs:gzip:2009-10-09-1a085b1446-118a107f2d', 'manybugs:gzip:2010-02-19-3eb6091d69-884ef6d16c',
'manybugs:libtiff:2005-12-21-3b848a7-3edb9cd', 'manybugs:libtiff:2006-02-23-b2ce5d8-207c78a',
'manybugs:libtiff:2006-03-03-a72cf60-0a36d7f', 'manybugs:libtiff:2006-03-03-eec4c06-ee65c74',
'manybugs:libtiff:2007-07-13-09e8220-f2d989d', 'manybugs:libtiff:2007-11-02-371336d-865f7b2',
'manybugs:libtiff:2009-02-05-764dbba-2e42d63', 'manybugs:libtiff:2009-08-28-e8a47d4-023b6df',
'manybugs:libtiff:2010-11-27-eb326f9-eec7ec0', 'manybugs:lighttpd:1948-1949',
'manybugs:lighttpd:2254-2259', 'manybugs:lighttpd:2661-2662', 'manybugs:lighttpd:2785-2786',
'manybugs:php:2011-03-25-8138f7de40-3acdca4703', 'manybugs:php:2011-04-02-70075bc84c-5a8c917c37',
'manybugs:php:2011-11-19-eeba0b5681-d3b20b4058', 'manybugs:php:2011-12-04-1e6a82a1cf-dfa08dc325',
'manybugs:php:2011-12-10-74343ca506-52c36e60c4', 'manybugs:php:2012-02-08-ff63c09e6f-6672171672']
# buglist = ['manybugs:gzip:2010-02-19-3eb6091d69-884ef6d16c']
# for i in range(0,len(bugList)):
bugList = []
port = 6000
for b in buglist:
for b in sosbugs:
if b== '.DS_Store':
continue
t = b, port
@@ -331,7 +496,7 @@ def patch_validate():
results = parallelRunMerge(validateCore, bugList)
# #
print(results)
with open(join(DATA_PATH, 'mayBugsValidateNew'), 'w',
with open(join(DATA_PATH, 'manyBugsValidateNewInitial'), 'w',
encoding='utf-8') as writeFile:
# if levelPatch == 0:
writeFile.write('\n'.join(results))
@@ -431,7 +596,7 @@ def patch_validate_mine():
from bugzoo import Patch, Client
def test_all(bug, container, client,validTests):
def test_all_(bug, container, client,validTests):
test_outcomes = {} # type: Dict[TestCase, TestOutcome]
failure_cases = []
failure = []
@@ -447,6 +612,21 @@ def test_all(bug, container, client,validTests):
return failure_cases, failure, total, test_outcomes
def test_all(bug, container, client):
test_outcomes = {} # type: Dict[TestCase, TestOutcome]
failure_cases = []
failure = 0
total = len(bug.tests._tests)
for test in bug.tests:
test_outcomes[test] = client.containers.test(container, test)
# if test.expected_outcome != test_outcomes[test].passed:
if test_outcomes[test].passed != True:
failure += 1
failure_cases.append(test.command)
break
return failure_cases, failure, total, test_outcomes
def fixTests(t):
bugName, port = t
container = None