/tools/xm-test/tests/network/04_network_local_udp_pos.py

https://gitlab.com/wkyu/gxen
Python | 76 lines | 45 code | 15 blank | 16 comment | 14 complexity | f44b670c3de6d1f3aad889810c4fb301 MD5 | raw file
  1. #!/usr/bin/python
  2. # Copyright (C) International Business Machines Corp., 2006
  3. # Author: <dykman@us.ibm.com>
  4. # UDP tests on local interfaces.
  5. # - creates a single guest domain
  6. # - sets up a single NIC
  7. # - conducts hping udp tests to the local loopback and IP address
  8. # hping2 127.0.0.1 -2 -c 1 -d $size
  9. # hping2 $local_IP -2 -c 1 -d $size
  10. # where $size = 1, 48, 64, 512, 1440, 1448, 1500, 1505,
  11. # 4096, 4192, 32767, 65507, 65508
  12. trysizes = [ 1, 48, 64, 512, 1440, 1448, 1500, 1505, 4096, 4192,
  13. 32767, 65495 ]
  14. from XmTestLib import *
  15. rc = 0
  16. # Test creates 1 domain, which requires 2 ips: 1 for the domains and 1 for
  17. # aliases on dom0
  18. if xmtest_netconf.canRunNetTest(2) == False:
  19. SKIP("Don't have enough free configured IPs to run this test")
  20. domain = XmTestDomain()
  21. domain.newDevice(XenNetDevice, "eth0")
  22. try:
  23. console = domain.start()
  24. except DomainError, e:
  25. if verbose:
  26. print "Failed to create test domain because:"
  27. print e.extra
  28. FAIL(str(e))
  29. try:
  30. console.setHistorySaveCmds(value=True)
  31. # First do loopback
  32. lofails=""
  33. for size in trysizes:
  34. out = console.runCmd("hping2 127.0.0.1 -E /dev/urandom -2 -q -c 20 "
  35. + "--fast -d " + str(size) + " -N " + str(size))
  36. if out["return"]:
  37. lofails += " " + str(size)
  38. print out["output"]
  39. # Next comes eth0
  40. eth0fails=""
  41. netdev = domain.getDevice("eth0")
  42. ip = netdev.getNetDevIP()
  43. for size in trysizes:
  44. out = console.runCmd("hping2 " + ip + " -E /dev/urandom -2 -q -c 20 "
  45. + "--fast -d " + str(size) + " -N " + str(size))
  46. if out["return"]:
  47. eth0fails += " " + str(size)
  48. print out["output"]
  49. except ConsoleError, e:
  50. FAIL(str(e))
  51. except NetworkError, e:
  52. FAIL(str(e))
  53. domain.stop()
  54. # Tally up failures
  55. failures=""
  56. if len(lofails):
  57. failures += "UDP hping2 over loopback failed for size" + lofails + ". "
  58. if len(eth0fails):
  59. failures += "UDP hping2 over eth0 failed for size" + eth0fails + "."
  60. if len(failures):
  61. FAIL(failures)