04_SendHandle.py 951 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/python
  2. import os, sys, mmap
  3. from regression import Regression
  4. loader = '../src/pal'
  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. regression.run_checks()