Echo Writes Code

test_bobadump.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from argparse import ArgumentParser
from bobadump import BobaDump

def main():
  arguments = parse_arguments()
  dumper = BobaDump(arguments.binary)
  output = dumper.run(arguments.sample)

  assert 'Full header count: 2' in output, '"Full header count" was wrong'
  assert 'User header count: 1' in output, '"User header count" was wrong'
  assert 'Size of each header: 16 bytes' in output, '"Size of each header" was wrong'
  assert 'Schema entry count: 1' in output, '"Schema entry count" was wrong'
  assert 'Size of each schema entry: 8 bytes' in output, '"Size of each schema entry" was wrong'

  assert 'User block 0' in output, 'Did not find "User block 0"'
  assert 'User block 1' not in output, 'Found unexpected "User block 1"'

  assert 'Signature: 0x434f4445' in output, '"Signature" of sample block was wrong'
  assert 'Data size: 4 bytes' in output, '"Data size" of sample block was wrong'
  assert 'User data[0]: 0x0' in output, '"User data[0]" of sample block was wrong'
  assert 'User data[1]: 0x0' in output, '"User data[1]" of sample block was wrong'
  assert 'Data starts at offset: 40' in output, '"Data starts at offset" of sample block was wrong'

def parse_arguments():
  parser = ArgumentParser()
  parser.add_argument('--binary')
  parser.add_argument('--sample')
  return parser.parse_args()

if __name__ == '__main__':
  main()