04_SendHandle.py 993 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env python2
  2. import os, sys, mmap
  3. from regression import Regression
  4. loader = os.environ['PAL_LOADER']
  5. regression = Regression(loader, "SendHandle")
  6. def check_times(target, lines, times):
  7. count = 0
  8. for line in lines:
  9. if target == line:
  10. count += 1
  11. return count == times
  12. regression.add_check(name="Send and Receive Handles across Processes",
  13. check=lambda res: check_times("Send Handle OK", res[0].log, 3) and
  14. check_times("Receive Handle OK", res[0].log, 3))
  15. regression.add_check(name="Send Pipe Handle",
  16. check=lambda res: check_times("Receive Pipe Handle: Hello World", res[0].log, 1))
  17. regression.add_check(name="Send Socket Handle",
  18. check=lambda res: check_times("Receive Socket Handle: Hello World", res[0].log, 1))
  19. regression.add_check(name="Send File Handle",
  20. check=lambda res: check_times("Receive File Handle: Hello World", res[0].log, 1))
  21. rv = regression.run_checks()
  22. if rv: sys.exit(rv)