1'''
2This is an example validator to be used with oem commands that allow you to
3upload data afterwards that you wish to validate locally.
4'''
5import sys
6
7def eprint(msg):
8  '''
9  A helper function for logging error messages to fuzzy_fastboot
10  Use this function as you would "print()"
11  '''
12  sys.stderr.write(msg + '\n')
13
14
15def main():
16  '''
17  Data is sent back to the parent fuzzy_fastboot process through the stderr pipe.
18
19  If this script has a non-zero return code, anything written to STDERR is part of
20  the error message that will logged by FF to explain why this validation failed.
21
22  Feel free to print to to STDOUT with print() as usual to print info to console
23  '''
24  script, command, fname = sys.argv
25  eprint("Messages here will go to the parent testers logs")
26  eprint("Hello world")
27  print("This goes to stdout as expected")
28  with open(fname, "rb") as fd:
29    # Do some validation on the buffer
30    pass
31
32  # non-zero return code signals error
33  return -1
34
35
36if __name__ == "__main__":
37  sys.exit(main())
38