03_Process.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import os, sys, mmap
  2. from regression import Regression
  3. loader = os.environ['PAL_LOADER']
  4. regression = Regression(loader, "Process", timeout=8000)
  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="Process Creation",
  12. check=lambda res: check_times("Child Process Created", res[0].log, 3))
  13. regression.add_check(name="Process Creation Arguments",
  14. check=lambda res: check_times("argv[0] = Process", res[0].log, 3) and
  15. check_times("argv[1] = Child", res[0].log, 3))
  16. regression.add_check(name="Process Channel Transmission",
  17. check=lambda res: check_times("Process Write 1 OK", res[0].log, 3) and
  18. check_times("Process Read 1: Hello World 1", res[0].log, 3) and
  19. check_times("Process Write 2 OK", res[0].log, 3) and
  20. check_times("Process Read 2: Hello World 2", res[0].log, 3))
  21. def check_broadcast_result(res):
  22. if not check_times("Warning: broadcast stream is not open. "
  23. "Do you have a multicast route configured?",
  24. res[0].log, 0):
  25. print("Could not open broadcast stream. Dou you have a multicast route configured?")
  26. return (check_times("Broadcast Write OK", res[0].log, 1) and
  27. check_times("Broadcast Read: Hello World 1", res[0].log, 3))
  28. regression.add_check(name="Multi-Process Broadcast Channel Transmission",
  29. check=check_broadcast_result)
  30. rv = regression.run_checks()
  31. if rv: sys.exit(rv)
  32. regression = Regression(loader, "Process2")
  33. regression.add_check(name="Process Creation with a Different Binary",
  34. check=lambda res: check_times("User Program Started", res[0].log, 1))
  35. rv = regression.run_checks()
  36. if rv: sys.exit(rv)
  37. regression = Regression(loader, "Process3")
  38. regression.add_check(name="Process Creation without Executable",
  39. check=lambda res: check_times("Binary 1 Preloaded", res[0].log, 2) and
  40. check_times("Binary 2 Preloaded", res[0].log, 2))
  41. rv = regression.run_checks()
  42. if rv: sys.exit(rv)