04_SendHandle.py 969 B

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