if __name__ == '__main__':
+ if sys.argv[1] == '--test':
+ process_file(sys.argv[2], 0x400503)
+ sys.exit(0)
+
if len(sys.argv) < 3:
print('Expected usage: {0} <address> <executable>'.format(sys.argv[0]))
sys.exit(1)
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
-
-
-
-
-
-
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
-
-
-
-
-
-
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
-
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
print(' name=%s' % top_DIE.get_full_path())
if __name__ == '__main__':
- for filename in sys.argv[1:]:
- process_file(filename)
-
-
-
-
-
+ if sys.argv[1] == '--test':
+ for filename in sys.argv[2:]:
+ process_file(filename)
testlog.info('.......ERROR - reference output cannot be read! - %s' % e)
return False
- rc, example_out = run_exe(example_path, ['./examples/sample_exe64.elf'])
+ rc, example_out = run_exe(example_path, ['--test',
+ './examples/sample_exe64.elf'])
if rc != 0:
testlog.info('.......ERROR - example returned error code %s' % rc)
return False
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
+from __future__ import print_function
import os, sys, subprocess, tempfile
# This module should not import elftools before setup_syspath() is called!
sys.path.insert(0, '.')
-def run_exe(exe_path, args=[]):
+def run_exe(exe_path, args=[], echo=False):
""" Runs the given executable as a subprocess, given the
list of arguments. Captures its return code (rc) and stdout and
returns a pair: rc, stdout_str
popen_cmd = [exe_path] + args
if os.path.splitext(exe_path)[1] == '.py':
popen_cmd.insert(0, sys.executable)
+ if echo:
+ print('[cmd]', ' '.join(popen_cmd))
proc = subprocess.Popen(popen_cmd, stdout=subprocess.PIPE)
proc_stdout = proc.communicate()[0]
from elftools.common.py3compat import bytes2str