pyelftools icon indicating copy to clipboard operation
pyelftools copied to clipboard

test/run_readelf_tests.py failed due to 32bit system and 64bit readelf-binary

Open shibumi opened this issue 10 years ago • 9 comments

There is a problem with 32bit systems and the run_readelf_tests.py. Your readelf binary in test/external_tools/readelf is 64bit due to this the run_readelf_tests.py failed. I copied my readelf binary to this location but this causes a failing test, because youre hardcoded expectations are not equal to the output of the readelf 32bit binary.

Fail-Log with 64bit readelf binary on 32bit system:

Test file 'test/testfiles_for_readelf/update32.o.elf'
Traceback (most recent call last):
  File "test/run_readelf_tests.py", line 214, in <module>
    sys.exit(main())
  File "test/run_readelf_tests.py", line 203, in main
    verbose=options.verbose)
  File "test/run_readelf_tests.py", line 60, in run_test_on_file
    rc, stdout = run_exe(exe_path, args)
  File "/tmp/yaourt-tmp-user/aur-python2-pyelftools/src/pyelftools-0.23/test/utils.py", line 30, in run_exe
    proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception

Fail-Log with 32bit readelf binary on 32bit system:

user@trudy ..python2-pyelftools/src/pyelftools-0.23 % python2 test/run_readelf_tests.py
Test file 'test/testfiles_for_readelf/exe_simple32.elf'
Test file 'test/testfiles_for_readelf/exe_simple64.elf'
.......................FAIL
....for option "--debug-dump=frames"
....Output #1 is readelf, Output #2 is pyelftools
@@ Mismatch on line #1:
>>00000000 0000000000000014 ffffffff cie<<
>>00000000 0000000000000014 00000000ffffffff cie<<
 ([('equal', 0, 26, 0, 26), ('insert', 26, 26, 26, 34), ('equal', 26, 38, 34, 46)])
@@ Output #1 dumped to file: /tmp/out1_cuI3KG.stdout
@@ Output #2 dumped to file: /tmp/out2_FUr_dM.stdout
.......................FAIL
....for option "--debug-dump=frames-interp"
....Output #1 is readelf, Output #2 is pyelftools
@@ Mismatch on line #1:
>>00000000 0000000000000014 ffffffff cie "" cf=1 df=-8 ra=16<<
>>00000000 0000000000000014 00000000ffffffff cie "" cf=1 df=-8 ra=16<<
 ([('equal', 0, 26, 0, 26), ('insert', 26, 26, 26, 34), ('equal', 26, 58, 34, 66)])
@@ Output #1 dumped to file: /tmp/out1_WiRZEN.stdout
@@ Output #2 dumped to file: /tmp/out2_qwsiW9.stdout
Conclusion: FAIL
python2 test/run_readelf_tests.py  6.34s user 0.64s system 96% cpu 7.250 total

shibumi avatar Feb 19 '15 16:02 shibumi

I don't typically use a 32-bit system. Patches welcome to make this work on both

eliben avatar Feb 19 '15 16:02 eliben

maybe you should use the system-wide readelf binary and mark readelf as dependency. This way would be smarter as shipping an own readelf binary..

shibumi avatar Feb 19 '15 17:02 shibumi

Probably also more agreeable with the GPL that way as well

vadmium avatar Feb 19 '15 21:02 vadmium

if we want to fix this issue via patch this would be pretty horrible because we need for every readelf binary out there other expectations.. or we would ship a second 32bit readelf binary with the package. there must be another way to verify the right output of pyreadelf

shibumi avatar Feb 20 '15 01:02 shibumi

I did use the system binary before, and it was an absolute nightmare because each system has a different version of readelf/binutils, in which there are maddening small differences in output for the same file. Accounting for all of that is madness - this is just testing we're talking about here.

eliben avatar Feb 20 '15 13:02 eliben

This problem also happens for Debian i386 builds: https://bugs.debian.org/860630

thinred avatar Apr 23 '17 16:04 thinred

... and it seems that for amd64 too. Sorry for spam.

thinred avatar Apr 23 '17 17:04 thinred

Sorry, folks. I'm not the one who prepared those Debian packages :-) Feel free to submit a PR that fixes it in some way.

eliben avatar Apr 23 '17 22:04 eliben

I did :). I didn't expect you to fix it, it's just informational. I disabled the readelf tests altogether as a (temporary?) fix.

thinred avatar Apr 24 '17 05:04 thinred