• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1import logging
2from autotest_lib.client.common_lib import error
3from autotest_lib.client.virt import aexpect
4
5def run_pxe(test, params, env):
6    """
7    PXE test:
8
9    1) Snoop the tftp packet in the tap device.
10    2) Wait for some seconds.
11    3) Check whether we could capture TFTP packets.
12
13    @param test: KVM test object.
14    @param params: Dictionary with the test parameters.
15    @param env: Dictionary with test environment.
16    """
17    vm = env.get_vm(params["main_vm"])
18    vm.verify_alive()
19    timeout = int(params.get("pxe_timeout", 60))
20
21    logging.info("Try to boot from PXE")
22    output = aexpect.run_fg("tcpdump -nli %s" % vm.get_ifname(),
23                                   logging.debug, "(pxe capture) ", timeout)[1]
24
25    logging.info("Analyzing the tcpdump result...")
26    if not "tftp" in output:
27        raise error.TestFail("Couldn't find any TFTP packets after %s seconds" %
28                             timeout)
29    logging.info("Found TFTP packet")
30