05_Process.py 1.8 KB

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