Dev stoping criteria (#108)

* no-mp not uset and redundant

* Add timeout

* Unused args reremoved timeout readded

* no-mp not uset and redundant

* Add timeout

* Unused args reremoved timeout readded

* Move import to the top op op op
This commit is contained in:
feliam 2017-03-28 14:48:23 -03:00 committed by GitHub
parent db6370bf87
commit dbb63cfa34
4 changed files with 20 additions and 21 deletions

View File

@ -54,7 +54,6 @@ def parse_arguments():
parser.add_argument('--names', type=str, default=None, help='File with function addresses to replace with known models')
parser.add_argument('programs', type=str, nargs='+', metavar='PROGRAM',
help='Programs to analyze (arguments after ?)' )
parser.add_argument('--no-mp', action='store_true', help='Disable multiprocess')
parsed = parser.parse_args(sys.argv[1:])
if parsed.procs <= 0 :
@ -149,7 +148,7 @@ def main():
logger.info('Loading program: {}'.format(args.programs))
logger.info('Workspace: {}'.format(m.workspace))
m.run()
m.run(args.timeout)
m.dump_stats()

View File

@ -106,7 +106,6 @@ class Executor(object):
self.max_states = options.get('maxstates', 0)
self.max_storage = options.get('maxstorage', 0)
self.replay_path = options.get('replay', None) #(dest, cond, origin)
self._dump_every = options.get('dumpafter', 0)
self._profile = cProfile.Profile()
self.profiling = options.get('dumpstats', False)
@ -127,7 +126,6 @@ class Executor(object):
self._running = manager.Value('i', 0 )
self._count = manager.Value('i', 0 )
self._shutdown = manager.Value('i', 0)
#self.timeout = manager.Event()
self._visited = manager.list()
self._errors = manager.list()
self._all_branches = manager.list()
@ -151,9 +149,6 @@ class Executor(object):
#Normally...
if len(saved_states) == 0 :
self.putState( initial )
else:
#If we are continuin from a set of saved states replay is not supported
assert self.replay_path is None
def dump_stats(self):
if not self.profiling:
@ -592,7 +587,6 @@ class Executor(object):
policy_order=self.policy_order
policy=self.policy
replay_path = self.replay_path
count = 0
current_state = None

View File

@ -10,6 +10,8 @@ import functools
from multiprocessing import Manager, Pool
from multiprocessing import Process
from threading import Timer
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import SymbolTableSection
@ -552,7 +554,7 @@ class Manticore(object):
self._assertions[pc] = ' '.join(line.split(' ')[1:])
def run(self):
def run(self, timeout=0):
'''
Runs analysis.
'''
@ -589,12 +591,18 @@ class Manticore(object):
self._running = True
if timeout > 0:
t = Timer(timeout, self.terminate)
t.start()
try:
self._start_workers(self._num_processes)
self._join_workers()
finally:
self._running = False
if timeout > 0:
t.cancel()
def terminate(self):
'''

View File

@ -33,26 +33,24 @@ class IntegrationTest(unittest.TestCase):
self.assertTrue(secs_used < timeout)
sys.stderr.write("\n")
@unittest.skip('TODO(mark); skipping so we can move on with our lives and merge x86_new. ask felipe to fix later.')
def testArguments(self):
def testTimeout(self):
dirname = os.path.dirname(__file__)
filename = os.path.abspath(os.path.join(dirname, 'binaries/arguments_linux_amd64'))
self.assertTrue(filename.startswith(os.getcwd()))
filename = filename[len(os.getcwd())+1:]
SE = os.path.join(dirname, '../main.py')
data = file(filename,'rb').read()
self.assertEqual(len(data), 767152)
self.assertEqual(hashlib.md5(data).hexdigest() , '00fb23e47831a1054ca4a74656035472')
workspace = '%s/workspace'%self.test_dir
self._runWithTimeout(['python', SE,
'--log', '%s/output.log'%self.test_dir,
'--workspace', workspace,
'--proc', '4',
filename,
'+++++++++'])
data = file('%s/visited.txt'%workspace,'r').read()
data = '\n'.join(sorted(set(data.split('\n'))))
self.assertEqual(hashlib.md5(data).hexdigest() , '757e3cb387a163987d9265f15970f595')
t = time.time()
po = subprocess.call(['python', '-m', 'manticore',
'--log', '%s/output.log'%self.test_dir,
'--workspace', workspace,
'--timeout', '1',
'--procs', '4',
filename,
'+++++++++'])
self.assertTrue(time.time()-t < 20)
@unittest.skip('TODO(mark); skipping so we can move on with our lives and merge x86_new. ask felipe to fix later.')