summaryrefslogtreecommitdiff
path: root/tests/format
diff options
context:
space:
mode:
Diffstat (limited to 'tests/format')
-rw-r--r--tests/format/elf/non_existing_binary.py4
-rw-r--r--tests/format/elf/oob_section_name.py17
-rw-r--r--tests/format/elf/overlapping_areas.py30
-rw-r--r--tests/format/elf/strings.py32
-rw-r--r--tests/format/errors.py17
5 files changed, 71 insertions, 29 deletions
diff --git a/tests/format/elf/non_existing_binary.py b/tests/format/elf/non_existing_binary.py
index a6eddd3..c984344 100644
--- a/tests/format/elf/non_existing_binary.py
+++ b/tests/format/elf/non_existing_binary.py
@@ -19,6 +19,6 @@ class TestNonExistingBinary(ChrysalideTestCase):
cnt = FileContent('non_existing_binary')
self.assertIsNone(cnt)
- with self.assertRaisesRegex(TypeError, 'The argument must be an instance of BinContent.'):
+ with self.assertRaisesRegex(TypeError, 'argument 1 must be pychrysalide.analysis.BinContent, not None'):
- fmt = ElfFormat(cnt, None, None)
+ fmt = ElfFormat(cnt)
diff --git a/tests/format/elf/oob_section_name.py b/tests/format/elf/oob_section_name.py
index a478ec7..64d7dc3 100644
--- a/tests/format/elf/oob_section_name.py
+++ b/tests/format/elf/oob_section_name.py
@@ -30,7 +30,20 @@ class TestNonExistingBinary(ChrysalideTestCase):
fullname = sys.modules[cls.__module__].__file__
dirpath = os.path.dirname(fullname)
- os.system('make -C %s oob_section_name 2>&1 > /dev/null' % dirpath)
+ os.system('make -C %s oob_section_name > /dev/null 2>&1' % dirpath)
+
+
+ @classmethod
+ def tearDownClass(cls):
+
+ super(TestNonExistingBinary, cls).tearDownClass()
+
+ cls.log('Delete built binaries...')
+
+ fullname = sys.modules[cls.__module__].__file__
+ dirpath = os.path.dirname(fullname)
+
+ os.system('make -C %s clean > /dev/null 2>&1' % dirpath)
def testOOBSectionName(self):
@@ -44,5 +57,5 @@ class TestNonExistingBinary(ChrysalideTestCase):
cnt = FileContent(fullname[:baselen] + 'oob_section_name')
self.assertIsNotNone(cnt)
- fmt = ElfFormat(cnt, None, None)
+ fmt = ElfFormat(cnt)
self.assertIsInstance(fmt, ElfFormat)
diff --git a/tests/format/elf/overlapping_areas.py b/tests/format/elf/overlapping_areas.py
index 4c78625..5e3ba07 100644
--- a/tests/format/elf/overlapping_areas.py
+++ b/tests/format/elf/overlapping_areas.py
@@ -16,6 +16,7 @@
from chrysacase import ChrysalideTestCase
from pychrysalide.analysis import LoadedBinary
from pychrysalide.analysis.contents import FileContent
+from pychrysalide.format.elf import ElfFormat
from threading import Event
import os
import sys
@@ -34,7 +35,20 @@ class TestOverlappingAreas(ChrysalideTestCase):
fullname = sys.modules[cls.__module__].__file__
dirpath = os.path.dirname(fullname)
- os.system('make -C %s overlapping_areas 2>&1 > /dev/null' % dirpath)
+ os.system('make -C %s overlapping_areas > /dev/null 2>&1' % dirpath)
+
+
+ @classmethod
+ def tearDownClass(cls):
+
+ super(TestOverlappingAreas, cls).tearDownClass()
+
+ cls.log('Delete built binaries...')
+
+ fullname = sys.modules[cls.__module__].__file__
+ dirpath = os.path.dirname(fullname)
+
+ os.system('make -C %s clean > /dev/null 2>&1' % dirpath)
def testOOBSectionName(self):
@@ -48,15 +62,9 @@ class TestOverlappingAreas(ChrysalideTestCase):
cnt = FileContent(fullname[:baselen] + 'overlapping_areas')
self.assertIsNotNone(cnt)
- binary = LoadedBinary(cnt)
-
- def disass_done(binary):
- worker.set()
-
- binary.connect('disassembly-done', disass_done)
-
- worker = Event()
+ fmt = ElfFormat(cnt)
+ self.assertIsInstance(fmt, ElfFormat)
- binary.analyse()
+ binary = LoadedBinary(fmt)
- worker.wait()
+ binary.analyze_and_wait()
diff --git a/tests/format/elf/strings.py b/tests/format/elf/strings.py
index 0e09d75..71d365e 100644
--- a/tests/format/elf/strings.py
+++ b/tests/format/elf/strings.py
@@ -9,6 +9,7 @@ from chrysacase import ChrysalideTestCase
from pychrysalide.analysis.contents import FileContent
from pychrysalide.analysis import LoadedBinary
from pychrysalide.arch import RawInstruction
+from pychrysalide.format.elf import ElfFormat
from threading import Event
import os
import sys
@@ -27,7 +28,20 @@ class TestElfString(ChrysalideTestCase):
fullname = sys.modules[cls.__module__].__file__
dirpath = os.path.dirname(fullname)
- os.system('make -C %s strings 2>&1 > /dev/null' % dirpath)
+ os.system('make -C %s strings > /dev/null 2>&1' % dirpath)
+
+
+ @classmethod
+ def tearDownClass(cls):
+
+ super(TestElfString, cls).tearDownClass()
+
+ cls.log('Delete built binaries...')
+
+ fullname = sys.modules[cls.__module__].__file__
+ dirpath = os.path.dirname(fullname)
+
+ os.system('make -C %s clean > /dev/null 2>&1' % dirpath)
def testElfStrings(self):
@@ -41,19 +55,13 @@ class TestElfString(ChrysalideTestCase):
cnt = FileContent(fullname[:baselen] + 'strings')
self.assertIsNotNone(cnt)
- binary = LoadedBinary(cnt)
- self.assertIsNotNone(binary)
-
- def disass_done(binary):
- worker.set()
+ fmt = ElfFormat(cnt)
+ self.assertIsInstance(fmt, ElfFormat)
- binary.connect('disassembly-done', disass_done)
-
- worker = Event()
-
- binary.analyse()
+ binary = LoadedBinary(fmt)
+ self.assertIsNotNone(binary)
- worker.wait()
+ binary.analyze_and_wait()
expected = {
'hello_arm_str' : False,
diff --git a/tests/format/errors.py b/tests/format/errors.py
index 36b7129..4ee38f1 100644
--- a/tests/format/errors.py
+++ b/tests/format/errors.py
@@ -27,7 +27,20 @@ class TestFormatErrors(ChrysalideTestCase):
fullname = sys.modules[cls.__module__].__file__
dirpath = os.path.dirname(fullname)
- os.system('make -C %s%self strings 2>&1 > /dev/null' % (dirpath, os.sep))
+ os.system('make -C %s%self strings > /dev/null 2>&1' % (dirpath, os.sep))
+
+
+ @classmethod
+ def tearDownClass(cls):
+
+ super(TestFormatErrors, cls).tearDownClass()
+
+ cls.log('Delete built binaries...')
+
+ fullname = sys.modules[cls.__module__].__file__
+ dirpath = os.path.dirname(fullname)
+
+ os.system('make -C %s%self clean > /dev/null 2>&1' % (dirpath, os.sep))
def testBasic(self):
@@ -49,7 +62,7 @@ class TestFormatErrors(ChrysalideTestCase):
baselen = len(fullname) - len(filename)
cnt = FileContent(fullname[:baselen] + 'elf' + os.sep + 'strings')
- fmt = ElfFormat(cnt, None, None)
+ fmt = ElfFormat(cnt)
for i in range(errlen):