Dev fix decree (#98)
* Re enable skipped test * Re enable skipped test * Hack so we can use upstream Elftool * pr comments * pr comments - staticmethod * pr comments - implicit > explicit
This commit is contained in:
@@ -40,10 +40,22 @@ class Binary(object):
|
||||
|
||||
|
||||
from elftools.elf.elffile import ELFFile
|
||||
import StringIO
|
||||
class CGCElf(Binary):
|
||||
|
||||
@staticmethod
|
||||
def _cgc2elf(filename):
|
||||
#hack begin so we can use upstream Elftool
|
||||
with open(filename, 'rb') as fd:
|
||||
stream = StringIO.StringIO(fd.read())
|
||||
stream.write('\x7fELF')
|
||||
stream.name = fd.name
|
||||
return stream
|
||||
|
||||
def __init__(self, filename):
|
||||
super(CGCElf, self).__init__(filename)
|
||||
self.elf = ELFFile(file(filename))
|
||||
stream = self._cgc2elf(filename)
|
||||
self.elf = ELFFile(stream)
|
||||
self.arch = {'x86':'i386','x64':'amd64'}[self.elf.get_machine_arch()]
|
||||
|
||||
assert 'i386' == self.arch
|
||||
|
||||
@@ -80,7 +80,6 @@ class IntegrationTest(unittest.TestCase):
|
||||
self.assertEqual(hashlib.md5(data).hexdigest() , 'c52d7d471ba5c94fcf59936086821a6b')
|
||||
|
||||
|
||||
@unittest.skip('TODO(mark); skipping so we can move on with our lives and merge x86_new. ask felipe to fix later.')
|
||||
def testDecree(self):
|
||||
dirname = os.path.dirname(__file__)
|
||||
filename = os.path.abspath(os.path.join(dirname, 'binaries/cadet_decree_x86'))
|
||||
@@ -91,13 +90,14 @@ class IntegrationTest(unittest.TestCase):
|
||||
self.assertEqual(len(data), 1828)
|
||||
self.assertEqual(hashlib.md5(data).hexdigest() , '8955a29d51c1edd39b0e53794ebcf464')
|
||||
workspace = '%s/workspace'%self.test_dir
|
||||
self._runWithTimeout(['python', SE,
|
||||
self._runWithTimeout(['python', '-m', 'manticore',
|
||||
'--log', '%s/output.log'%self.test_dir,
|
||||
'--workspace', workspace,
|
||||
'--timeout', '20',
|
||||
'--proc', '4',
|
||||
'--policy', 'uncovered',
|
||||
filename])
|
||||
|
||||
data = file('%s/visited.txt'%workspace,'r').read()
|
||||
visited = len(set(data.split('\n')))
|
||||
self.assertTrue(visited > 100 )
|
||||
|
||||
Reference in New Issue
Block a user