02_Socket.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import os, sys, mmap
  2. from regression import Regression
  3. loader = os.environ['PAL_LOADER']
  4. regression = Regression(loader, "Socket")
  5. regression.add_check(name="TCP Socket Creation",
  6. check=lambda res: "TCP Creation 1 OK" in res[0].log)
  7. regression.add_check(name="TCP Socket Connection",
  8. check=lambda res: "TCP Connection 1 OK" in res[0].log)
  9. regression.add_check(name="TCP Socket Transmission",
  10. check=lambda res: "TCP Write 1 OK" in res[0].log and
  11. "TCP Read 1: Hello World 1" in res[0].log and
  12. "TCP Write 2 OK" in res[0].log and
  13. "TCP Read 2: Hello World 2" in res[0].log)
  14. regression.add_check(name="UDP Socket Creation",
  15. check=lambda res: "UDP Creation 1 OK" in res[0].log)
  16. regression.add_check(name="UDP Socket Connection",
  17. check=lambda res: "UDP Connection 1 OK" in res[0].log)
  18. regression.add_check(name="UDP Socket Transmission",
  19. check=lambda res: "UDP Write 1 OK" in res[0].log and
  20. "UDP Read 1: Hello World 1" in res[0].log and
  21. "UDP Write 2 OK" in res[0].log and
  22. "UDP Read 2: Hello World 2" in res[0].log)
  23. regression.add_check(name="Bound UDP Socket Transmission",
  24. check=lambda res: "UDP Write 3 OK" in res[0].log and
  25. "UDP Read 3: Hello World 1" in res[0].log and
  26. "UDP Write 4 OK" in res[0].log and
  27. "UDP Read 4: Hello World 2" in res[0].log)
  28. rv = regression.run_checks()
  29. if rv: sys.exit(rv)