04_Ipc.py 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/python
  2. import os, sys, mmap
  3. from regression import Regression
  4. loader = os.environ['PAL_LOADER']
  5. def prepare_files(args):
  6. with open("ipc_mapping.tmp", "w") as f:
  7. f.write("Hello World")
  8. os.ftruncate(f.fileno(), mmap.PAGESIZE)
  9. regression = Regression(loader, "Ipc", prepare_files)
  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="Create and Join Physical Memory Bulk Copy Store",
  17. check=lambda res: check_times("Create Physical Memory Store OK", res[0].log, 5) and
  18. check_times("Join Physical Memory Store OK", res[0].log, 5))
  19. regression.add_check(name="Map and Commit Anonymous Physical Memory",
  20. check=lambda res: "[Test 1] Physical Memory Commit OK" in res[0].log and
  21. "[Test 1] Physical Memory Map : Hello World" in res[0].log)
  22. regression.add_check(name="Transfer Anonymous Physical Memory as Copy-on-Write",
  23. check=lambda res: "[Test 1] Sender After Commit: Hello World, Alice" in res[0].log and
  24. "[Test 1] Sender Before Map : Alice, Hello World" in res[0].log and
  25. "[Test 1] Receiver After Map : Hello World, Bob" in res[0].log and
  26. "[Test 1] Sender After Map : Alice, Hello World" in res[0].log)
  27. regression.add_check(name="Map and Commit Untouched Physical Memory",
  28. check=lambda res: "[Test 2] Physical Memory Commit OK" in res[0].log and
  29. "[Test 2] Physical Memory Map : " in res[0].log and
  30. "[Test 2] Sender After Commit: Hello World, Alice" in res[0].log and
  31. "[Test 2] Sender Before Map : Alice, Hello World" in res[0].log and
  32. "[Test 2] Receiver After Map : Hello World, Bob" in res[0].log and
  33. "[Test 2] Sender After Map : Alice, Hello World" in res[0].log)
  34. regression.add_check(name="Map and Commit File-Backed Physical Memory",
  35. check=lambda res: "[Test 3] Physical Memory Commit OK" in res[0].log and
  36. "[Test 3] Physical Memory Map : Hello World" in res[0].log and
  37. "[Test 3] Sender After Commit: Hello World" in res[0].log and
  38. "[Test 3] Receiver After Map : Hello World, Bob" in res[0].log and
  39. "[Test 3] Sender After Map : Hello World" in res[0].log)
  40. regression.add_check(name="Map and Commit File-Backed Physical Memory Beyond File Size",
  41. check=lambda res: "[Test 4] Physical Memory Commit OK" in res[0].log and
  42. "[Test 4] Physical Memory Map : Memory Fault" in res[0].log)
  43. regression.add_check(name="Map and Commit Huge Physical Memory",
  44. check=lambda res: "[Test 5] Physical Memory Commit OK" in res[0].log and
  45. "[Test 5] Physical Memory Map : Hello World" in res[0].log)
  46. regression.run_checks()