Skip to content

Commit a8d0244

Browse files
committed
Fix obtaining of architecture in DecompilerTest.
After commit 871f39a, the architecture is obtained from the config. However, the commit has forgotten to (1) lowercase the architecture (the code expects architecture to be lowercased) and (2) fix the mocking of architecture in tests. This commit fixes several failing unit tests.
1 parent 2fd44f5 commit a8d0244

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

regression_tests/tools/decompiler_test.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,11 @@ def _decomp_arch(self):
250250
return self._get_arch_from_out_config()
251251

252252
def _get_arch_from_out_config(self):
253-
arch = self.out_config.json.get('architecture', {})
254-
return arch.get('name')
253+
arch = self.out_config.json.get('architecture', {}).get('name')
254+
if arch is None:
255+
return None
256+
257+
return arch.lower()
255258

256259
def _run_compiled_output_file(self, input, timeout):
257260
"""Runs the compiled output C file with the given input and timeout and

tests/tools/decompiler_test_tests.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from unittest import mock
99

1010
from regression_tests.parsers.config_parser import Config
11-
from regression_tests.parsers.fileinfo_output_parser import FileinfoOutput
1211
from regression_tests.test_settings import TestSettings
1312
from regression_tests.tools.decompiler import Decompiler
1413
from regression_tests.tools.decompiler_test import DecompilerTest
@@ -136,18 +135,12 @@ def scenario_out_c_is_fixed_for_arch_when_input_is_c(self, arch):
136135

137136
def scenario_out_c_is_fixed_for_arch_when_input_is_binary(self, arch):
138137
self.test = self.create(TestSettings(input='file.exe'))
139-
# For binary files, the architecture is obtained from fileinfo (writers
140-
# of regression tests do not usually specify the architecture for
141-
# binary files because such a specification is useless).
142-
#
143-
# We also test that the architecture is parsed properly.
144-
self.decompiler.fileinfo_outputs = [
145-
FileinfoOutput(
146-
'\n...\nArchitecture: {} (some irrelevant arch info)\n...'.format(
147-
arch
148-
)
149-
)
150-
]
138+
# For binary files, the architecture is obtained from the config
139+
# (writers of regression tests do not usually specify the architecture
140+
# for binary files because such a specification is useless).
141+
self.decompiler.out_config.json = {
142+
'architecture': {'name': arch},
143+
}
151144

152145
self._check_out_c_gets_fixed()
153146

0 commit comments

Comments
 (0)