05_Process.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ## This test is specifically for the reference monitor code, not process creation in general.
  2. ## It is not well-tested right now, but keep the tests around for future work.
  3. import os, sys, mmap
  4. from regression import Regression
  5. loader = os.environ['PAL_SEC']
  6. if not os.path.exists(loader):
  7. print("Reference monitor mode is not available on this platform")
  8. exit(0)
  9. regression = Regression(loader, "Process")
  10. def check_times(target, lines, times):
  11. count = 0
  12. for line in lines:
  13. if target == line:
  14. count += 1
  15. return count == times
  16. regression.add_check(name="Process Creation",
  17. check=lambda res: check_times("Child Process Created", res[0].log, 3))
  18. regression.add_check(name="Process Creation Arguments",
  19. check=lambda res: check_times("argv[0] = Process", res[0].log, 3) and
  20. check_times("argv[1] = Child", res[0].log, 3))
  21. regression.add_check(name="Process Channel Transmission",
  22. check=lambda res: check_times("Process Write 1 OK", res[0].log, 3) and
  23. check_times("Process Read 1: Hello World 1", res[0].log, 3) and
  24. check_times("Process Write 2 OK", res[0].log, 3) and
  25. check_times("Process Read 2: Hello World 2", res[0].log, 3))
  26. regression.add_check(name="Multi-Process Broadcast Channel Transmission",
  27. check=lambda res: check_times("Broadcast Write OK", res[0].log, 1) and
  28. check_times("Broadcast Read: Hello World 1", res[0].log, 3))
  29. rv = regression.run_checks()
  30. ## dp : For now, let these tests fail. We should fix this.
  31. #if rv: sys.exit(rv)
  32. regression = Regression(loader, "Process2")
  33. regression.add_check(name="Process Creation without Executable",
  34. check=lambda res: check_times("Binary 1 Preloaded", res[0].log, 2) and
  35. check_times("Binary 2 Preloaded", res[0].log, 2))
  36. rv = regression.run_checks()
  37. #if rv: sys.exit(rv)