05_Process.py 1.9 KB

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