-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'issue-270-limiting-overall-memory'.
- Loading branch information
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from regression_tests import * | ||
|
||
|
||
class TestDefaultLimit(Test): | ||
"""Checks that retdec-decompiler.sh correctly decompiles a binary file when | ||
there is the default memory limit (half of system RAM). | ||
Test for https://github.com/avast-tl/retdec/issues/270 | ||
""" | ||
|
||
settings = TestSettings( | ||
input='ack.ex', | ||
) | ||
|
||
def test_correctly_decompiled_file(self): | ||
# The check whether the decompilation was successful is done | ||
# automatically during setUp(), so we only check that the default | ||
# memory limit has been set. | ||
# For fileinfo: | ||
self.assertIn('--max-memory-half-ram', self.decompiler.output) | ||
# For bin2llvmir and llvmir2hll: | ||
self.assertIn(' -max-memory-half-ram', self.decompiler.output) | ||
|
||
|
||
class TestCustomSufficientLimit(Test): | ||
"""Checks that retdec-decompiler.sh correctly decompiles a binary file when | ||
there is a custom memory limit (but sufficient). | ||
Test for https://github.com/avast-tl/retdec/issues/270 | ||
""" | ||
|
||
settings = TestSettings( | ||
input='ack.ex', | ||
args='--max-memory 107374182400', # 1 GB | ||
) | ||
|
||
def test_correctly_decompiled_file(self): | ||
# The check whether the decompilation was successful is done | ||
# automatically during setUp(), so we only check that the memory limit | ||
# has been set. | ||
# For fileinfo: | ||
self.assertIn('--max-memory 107374182400', self.decompiler.output) | ||
# For bin2llvmir and llvmir2hll: | ||
self.assertIn(' -max-memory 107374182400', self.decompiler.output) | ||
|
||
|
||
class TestCustomInsufficientLimit(Test): | ||
"""Checks that retdec-decompiler.sh fails to decompile a binary file when | ||
the maximal memory limit is too low. | ||
Test for https://github.com/avast-tl/retdec/issues/270 | ||
""" | ||
|
||
settings = TestSettings( | ||
input='ack.ex', | ||
args='--max-memory 100', # 100 bytes | ||
) | ||
|
||
def setUp(self): | ||
# Fail expected. | ||
pass | ||
|
||
def test_failed_to_decompile_file(self): | ||
self.assertNotEqual(self.decompiler.return_code, 0) | ||
|
||
|
||
class TestNoLimit(Test): | ||
"""Checks that retdec-decompiler.sh correctly decompiles a binary file when | ||
there is no memory limit. | ||
Test for https://github.com/avast-tl/retdec/issues/270 | ||
""" | ||
|
||
settings = TestSettings( | ||
input='ack.ex', | ||
args='--no-memory-limit', | ||
) | ||
|
||
def test_correctly_decompiled_file(self): | ||
# The check whether the decompilation was successful is done | ||
# automatically during setUp(), so we only check that no memory limit | ||
# has been set. | ||
# For fileinfo: | ||
self.assertNotIn('--max-memory', self.decompiler.output) | ||
# For bin2llvmir and llvmir2hll: | ||
self.assertNotIn(' -max-memory', self.decompiler.output) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from regression_tests import * | ||
|
||
|
||
class TestAnalysisWhenNoLimit(Test): | ||
"""Checks that fileinfo correctly analyzes file when there is no memory | ||
limit. | ||
Test for https://github.com/avast-tl/retdec/issues/270 | ||
""" | ||
|
||
settings = TestSettings( | ||
tool='fileinfo', | ||
input='ack.ex', | ||
) | ||
|
||
def test_correctly_analyzes_file(self): | ||
assert self.fileinfo.succeeded | ||
|
||
self.assertEqual( | ||
self.fileinfo.output['SHA256'], | ||
'35f7b82373b66579d782fa61732da86717631eff95876b799a9549661709fd8b' | ||
) | ||
|
||
|
||
class TestAnalysisWhenSufficient(Test): | ||
"""Checks that fileinfo correctly analyzes file when there is a sufficient | ||
memory limit. | ||
Test for https://github.com/avast-tl/retdec/issues/270 | ||
""" | ||
|
||
settings = TestSettings( | ||
tool='fileinfo', | ||
args=[ | ||
'--max-memory=104857600', # 100 MB | ||
'--max-memory-half-ram', | ||
], | ||
input='ack.ex', | ||
) | ||
|
||
def test_correctly_analyzes_file(self): | ||
assert self.fileinfo.succeeded | ||
|
||
self.assertEqual( | ||
self.fileinfo.output['SHA256'], | ||
'35f7b82373b66579d782fa61732da86717631eff95876b799a9549661709fd8b' | ||
) | ||
|
||
|
||
class TestAnalysisWhenInsufficientLimit(Test): | ||
"""Checks that fileinfo fails to analyze the file when the memory limit is | ||
not sufficient. | ||
Test for https://github.com/avast-tl/retdec/issues/270 | ||
""" | ||
|
||
settings = TestSettings( | ||
tool='fileinfo', | ||
args='--max-memory=100', # 100 bytes | ||
input='ack.ex', | ||
) | ||
|
||
def test_fails_to_analyze_file(self): | ||
assert not self.fileinfo.succeeded, 'fileinfo succeeded but should have failed' |