From 2253600389a2bee154cce8b2a077da90a4512abf Mon Sep 17 00:00:00 2001 From: Philipp Hahn Date: Wed, 19 Feb 2025 17:14:39 +0100 Subject: [PATCH 1/2] test: Fix missing testlog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ```console $ cd test && python3 all_tests.py Traceback (most recent call last): File "…/pyelftools/test/all_tests.py", line 29, in 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 --- test/all_tests.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/all_tests.py b/test/all_tests.py index b7f60fce..30295307 100755 --- a/test/all_tests.py +++ b/test/all_tests.py @@ -18,8 +18,7 @@ def run_test_script(path, *args): def main(): if not is_in_rootdir(): - testlog.error('Error: Please run me from the root dir of pyelftools!') - return 1 + sys.exit('Error: Please run me from the root dir of pyelftools!') run_test_script('test/run_all_unittests.py') run_test_script('test/run_examples_test.py') run_test_script('test/run_readelf_tests.py', '--parallel') From 35d8a9bc7c04c69e2c23b7cba03d82ee92b0534c Mon Sep 17 00:00:00 2001 From: Philipp Hahn Date: Mon, 24 Feb 2025 13:05:51 +0100 Subject: [PATCH 2/2] 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 --- test/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/utils.py b/test/utils.py index f90f653b..fc456873 100644 --- a/test/utils.py +++ b/test/utils.py @@ -20,7 +20,8 @@ def run_exe(exe_path, args=[], echo=False): popen_cmd.insert(0, sys.executable) if echo: print('[cmd]', ' '.join(popen_cmd)) - proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + env = dict(os.environ, LC_ALL="C") + proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env) proc_stdout = proc.communicate()[0] return proc.returncode, proc_stdout.decode('latin-1')