Skip to content

Commit aad8631

Browse files
authored
Fix running tests (#598)
* test: Fix missing testlog ```console $ cd test && python3 all_tests.py Traceback (most recent call last): File "…/pyelftools/test/all_tests.py", line 29, in <module> sys.exit(main()) ^^^^^^ File "…/pyelftools/test/all_tests.py", line 21, in main testlog.error('Error: Please run me from the root dir of pyelftools!') ^^^^^^^ NameError: name 'testlog' is not defined ``` Signed-off-by: Philipp Hahn <[email protected]> * test: Run test with locale C Otherwise the output of `readelf` might be translated and comparison with the English output from `readelf.py` will fail. ```console $ LC_ALL=de_DE.UTF-8 ./test/run_readelf_tests.py Test file 'test/testfiles_for_readelf/aarch64-pac-bti.elf' .......................FAIL ....for file test/testfiles_for_readelf/aarch64-pac-bti.elf ....for option "-e" ....Output #1 is readelf, Output #2 is pyelftools @@ Mismatch on line #0: >>elf-header:<< >>elf header:<< ([('equal', 0, 3, 0, 3), ('replace', 3, 4, 3, 4), ('equal', 4, 11, 4, 11)]) ``` Signed-off-by: Philipp Hahn <[email protected]> --------- Signed-off-by: Philipp Hahn <[email protected]>
1 parent 96d64eb commit aad8631

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

test/all_tests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def run_test_script(path, *args):
1818

1919
def main():
2020
if not is_in_rootdir():
21-
testlog.error('Error: Please run me from the root dir of pyelftools!')
22-
return 1
21+
sys.exit('Error: Please run me from the root dir of pyelftools!')
2322
run_test_script('test/run_all_unittests.py')
2423
run_test_script('test/run_examples_test.py')
2524
run_test_script('test/run_readelf_tests.py', '--parallel')

test/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def run_exe(exe_path, args=[], echo=False):
2020
popen_cmd.insert(0, sys.executable)
2121
if echo:
2222
print('[cmd]', ' '.join(popen_cmd))
23-
proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
23+
env = dict(os.environ, LC_ALL="C")
24+
proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
2425
proc_stdout = proc.communicate()[0]
2526
return proc.returncode, proc_stdout.decode('latin-1')
2627

0 commit comments

Comments
 (0)