Skip to content

Commit

Permalink
disasm.py start to include an embedded test suite, including test tha…
Browse files Browse the repository at this point in the history
…t fails
  • Loading branch information
markjenkins committed May 8, 2020
1 parent 27ab71b commit a26ef35
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions High_level_prototypes/disasm.py
Expand Up @@ -1323,6 +1323,16 @@ def dissassemble_knight_binary(
def get_stage0_knight_defs_filename():
return path_join(dirname(__file__), 'defs')

def run_test_suite():
from io import BytesIO, StringIO
inputfilebytes = BytesIO()
inputfilebytes.write(b'00000000 ff ff |..|\n00000002\n')
inputfilebytes.seek(0)
dissassemble_knight_binary(
inputfilebytes, StringIO(),
)
inputfilebytes.close()

if __name__ == "__main__":
argparser = ArgumentParser()

Expand Down Expand Up @@ -1375,13 +1385,22 @@ def get_stage0_knight_defs_filename():
help="For the Knight.py cherrypy debugger, don't break up newlines"
)

argparser.add_argument(
"--run-test-suite",
default=False, action="store_true"
)

argparser.add_argument(
"inputfile", help="file to disassemble",
type=FileType("rb")
)

args = argparser.parse_args()

if args.run_test_suite:
test_suite_result = run_test_suite()
exit(test_suite_result)

# safety check on args.max_data_bytes_per_line to ensure the value
# used is > 0
max_data_bytes_per_line = max(1, args.max_data_bytes_per_line)
Expand Down

0 comments on commit a26ef35

Please sign in to comment.