Skip to content

Commit

Permalink
Tests cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
eerimoq committed Oct 4, 2018
1 parent 7956e91 commit 0f33b4a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 65 deletions.
12 changes: 12 additions & 0 deletions tests/files/empty_main.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Header: "bincopy/empty_main.s19"
Execution start address: 0x00400400
Data ranges:

0x00400238 - 0x004002b4 (124 bytes)
0x004002b8 - 0x0040033e (134 bytes)
0x00400340 - 0x004003c2 (130 bytes)
0x004003d0 - 0x00400572 (418 bytes)
0x00400574 - 0x0040057d (9 bytes)
0x00400580 - 0x004006ac (300 bytes)
0x00600e10 - 0x00601038 (552 bytes)

18 changes: 18 additions & 0 deletions tests/files/empty_main_and_in.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Header: "bincopy/empty_main.s19"
Execution start address: 0x00400400
Data ranges:

0x00400238 - 0x004002b4 (124 bytes)
0x004002b8 - 0x0040033e (134 bytes)
0x00400340 - 0x004003c2 (130 bytes)
0x004003d0 - 0x00400572 (418 bytes)
0x00400574 - 0x0040057d (9 bytes)
0x00400580 - 0x004006ac (300 bytes)
0x00600e10 - 0x00601038 (552 bytes)

Header: "hello \x00\x00"
Execution start address: 0x00000000
Data ranges:

0x00000000 - 0x00000046 (70 bytes)

Binary file added tests/files/empty_main_and_in_header.info.txt
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/files/in_16bits_word.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Header: "HDR"
Data ranges:

0x003e8000 - 0x003e8020 (64 bytes)

84 changes: 19 additions & 65 deletions tests/test_bincopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,89 +1400,43 @@ def test_command_line_dump_commands_one_file(self):
self._test_command_line_ok(command, expected_output)

def test_command_line_info_one_file(self):
with open('tests/files/empty_main.info.txt', 'r') as fin:
expected_output = fin.read()

self._test_command_line_ok(
['bincopy', 'info', 'tests/files/empty_main.s19'],
"""\
Header: "bincopy/empty_main.s19"
Execution start address: 0x00400400
Data ranges:
0x00400238 - 0x004002b4 (124 bytes)
0x004002b8 - 0x0040033e (134 bytes)
0x00400340 - 0x004003c2 (130 bytes)
0x004003d0 - 0x00400572 (418 bytes)
0x00400574 - 0x0040057d (9 bytes)
0x00400580 - 0x004006ac (300 bytes)
0x00600e10 - 0x00601038 (552 bytes)
""")

expected_output)

def test_command_line_info_two_files(self):
with open('tests/files/empty_main_and_in.info.txt', 'r') as fin:
expected_output = fin.read()

self._test_command_line_ok(
['bincopy', 'info', 'tests/files/empty_main.s19', 'tests/files/in.s19'],
"""\
Header: "bincopy/empty_main.s19"
Execution start address: 0x00400400
Data ranges:
0x00400238 - 0x004002b4 (124 bytes)
0x004002b8 - 0x0040033e (134 bytes)
0x00400340 - 0x004003c2 (130 bytes)
0x004003d0 - 0x00400572 (418 bytes)
0x00400574 - 0x0040057d (9 bytes)
0x00400580 - 0x004006ac (300 bytes)
0x00600e10 - 0x00601038 (552 bytes)
Header: "hello \\x00\\x00"
Execution start address: 0x00000000
Data ranges:
0x00000000 - 0x00000046 (70 bytes)
""")
expected_output)

def test_command_line_info_two_files_with_header_encoding(self):
with open('tests/files/empty_main_and_in_header.info.txt', 'r') as fin:
expected_output = fin.read()

self._test_command_line_ok(
['bincopy',
'info',
['bincopy', 'info',
'--header-encoding', 'utf-8',
'tests/files/empty_main.s19',
'tests/files/in.s19'],
"""\
Header: "bincopy/empty_main.s19"
Execution start address: 0x00400400
Data ranges:
0x00400238 - 0x004002b4 (124 bytes)
0x004002b8 - 0x0040033e (134 bytes)
0x00400340 - 0x004003c2 (130 bytes)
0x004003d0 - 0x00400572 (418 bytes)
0x00400574 - 0x0040057d (9 bytes)
0x00400580 - 0x004006ac (300 bytes)
0x00600e10 - 0x00601038 (552 bytes)
Header: "hello \x00\x00"
Execution start address: 0x00000000
Data ranges:
0x00000000 - 0x00000046 (70 bytes)
""")

expected_output)

def test_command_line_info_one_file_16_bits_words(self):
with open('tests/files/in_16bits_word.info.txt', 'r') as fin:
expected_output = fin.read()

self._test_command_line_ok(
[
'bincopy', 'info',
'--word-size-bits', '16',
'tests/files/in_16bits_word.s19'
],
"""\
Header: "HDR"
Data ranges:
0x003e8000 - 0x003e8020 (64 bytes)
""")
expected_output)

def test_bad_word_size(self):
with self.assertRaises(bincopy.Error) as cm:
Expand Down

0 comments on commit 0f33b4a

Please sign in to comment.