effcee-example-driver.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python3
  2. # Copyright 2017 The Effcee Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. """Execute the effcee-example program, where the arguments are
  16. the location of the example program, the input file, and a
  17. list of check rules to match against the input.
  18. Args:
  19. effcee-example: Path to the effcee-example executable
  20. input_file: Data file containing the input to match
  21. check1 .. checkN: Check rules to match
  22. """
  23. import subprocess
  24. import sys
  25. def main():
  26. cmd = sys.argv[1]
  27. input_file = sys.argv[2]
  28. checks = sys.argv[3:]
  29. args = [cmd]
  30. args.extend(checks)
  31. print(args)
  32. with open(input_file) as input_stream:
  33. sys.exit(subprocess.call(args, stdin=input_stream))
  34. sys.exit(1)
  35. if __name__ == '__main__':
  36. main()