02_Memory.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/python
  2. import os, sys, mmap
  3. from regression import Regression
  4. loader = os.environ['PAL_LOADER']
  5. try:
  6. sgx = os.environ['SGX_RUN']
  7. except KeyError:
  8. sgx = 0
  9. regression = Regression(loader, "Memory")
  10. regression.add_check(name="Memory Allocation",
  11. check=lambda res: "Memory Allocation OK" in res[0].log)
  12. regression.add_check(name="Memory Allocation with Address",
  13. check=lambda res: "Memory Allocation with Address OK" in res[0].log)
  14. regression.add_check(name="Memory Protection", flaky = sgx,
  15. check=lambda res: "Memory Allocation Protection (RW) OK" in res[0].log and
  16. "Memory Protection (R) OK" in res[0].log)
  17. regression.add_check(name="Memory Deallocation", flaky = sgx,
  18. check=lambda res: "Memory Deallocation OK" in res[0].log)
  19. def check_quota(res):
  20. for line in res[0].log:
  21. if line.startswith("Total Memory:"):
  22. return line != "Total Memory: 0"
  23. return False
  24. regression.add_check(name="Get Memory Total Quota", check=check_quota)
  25. regression.add_check(name="Get Memory Available Quota",
  26. check=lambda res: "Get Memory Available Quota OK" in res[0].log)
  27. rv = regression.run_checks()
  28. if rv: sys.exit(rv)