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