Skip to content

Commit 0861e57

Browse files
committed
tools/fileinfo/features: Add a test for limiting memory (--max-memory).
1 parent c3830e7 commit 0861e57

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed
75.4 KB
Binary file not shown.
+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from regression_tests import *
2+
3+
4+
class TestAnalysisWhenNoLimit(Test):
5+
"""Checks that fileinfo correctly analyzes file when there is no memory
6+
limit.
7+
8+
Test for https://github.com/avast-tl/retdec/issues/270
9+
"""
10+
11+
settings = TestSettings(
12+
tool='fileinfo',
13+
input='ack.ex',
14+
)
15+
16+
def test_correctly_analyzes_file(self):
17+
assert self.fileinfo.succeeded
18+
19+
self.assertEqual(
20+
self.fileinfo.output['SHA256'],
21+
'35f7b82373b66579d782fa61732da86717631eff95876b799a9549661709fd8b'
22+
)
23+
24+
25+
class TestAnalysisWhenSufficient(Test):
26+
"""Checks that fileinfo correctly analyzes file when there is a sufficient
27+
memory limit.
28+
29+
Test for https://github.com/avast-tl/retdec/issues/270
30+
"""
31+
32+
settings = TestSettings(
33+
tool='fileinfo',
34+
args=[
35+
'--max-memory=104857600', # 100 MB
36+
'--max-memory-half-ram',
37+
],
38+
input='ack.ex',
39+
)
40+
41+
def test_correctly_analyzes_file(self):
42+
assert self.fileinfo.succeeded
43+
44+
self.assertEqual(
45+
self.fileinfo.output['SHA256'],
46+
'35f7b82373b66579d782fa61732da86717631eff95876b799a9549661709fd8b'
47+
)
48+
49+
50+
class TestAnalysisWhenInsufficientLimit(Test):
51+
"""Checks that fileinfo fails to analyze the file when the memory limit is
52+
not sufficient.
53+
54+
Test for https://github.com/avast-tl/retdec/issues/270
55+
"""
56+
57+
settings = TestSettings(
58+
tool='fileinfo',
59+
args='--max-memory=100', # 100 bytes
60+
input='ack.ex',
61+
)
62+
63+
def test_fails_to_analyze_file(self):
64+
assert not self.fileinfo.succeeded, 'fileinfo succeeded but should have failed'

0 commit comments

Comments
 (0)