/root/autotest/client/tests/kvm/control

654阅读 0评论2012-01-04 niexining
分类:Python/Ruby

  1. AUTHOR = """
  2. uril@redhat.com (Uri Lublin)
  3. drusso@redhat.com (Dror Russo)
  4. mgoldish@redhat.com (Michael Goldish)
  5. dhuff@redhat.com (David Huff)
  6. aeromenk@redhat.com (Alexey Eromenko)
  7. mburns@redhat.com (Mike Burns)
  8. """
  9. TIME = 'MEDIUM'
  10. NAME = 'KVM test'
  11. TEST_TYPE = 'client'
  12. TEST_CLASS = 'Virtualization'
  13. TEST_CATEGORY = 'Functional'

  14. DOC = """
  15. Executes the KVM test framework on a given host. This module is separated in
  16. minor functions, that execute different tests for doing Quality Assurance on
  17. KVM (both kernelspace and userspace) code.

  18. For online docs, please refer to
  19. """

  20. import sys, os, logging
  21. from autotest_lib.client.common_lib import cartesian_config
  22. from autotest_lib.client.virt import virt_utils

  23. # set English environment (command output might be localized, need to be safe)
  24. os.environ['LANG'] = 'en_US.UTF-8'

  25. str = """
  26. # This string will be parsed after build.cfg. Make any desired changes to the
  27. # build configuration here. For example:
  28. #release_tag = 84
  29. """

  30. parser = cartesian_config.Parser()
  31. kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm')
  32. parser.parse_file(os.path.join(kvm_test_dir, "build.cfg"))
  33. parser.parse_string(str)
  34. if not virt_utils.run_tests(parser, job):
  35.     logging.error("KVM build step failed, exiting.")
  36.     sys.exit(1)

  37. str = """
  38. # This string will be parsed after tests.cfg. Make any desired changes to the
  39. # test configuration here. For example:
  40. #display = sdl
  41. #install, setup: timeout_multiplier = 3
  42. """

  43. parser = cartesian_config.Parser()
  44. parser.parse_file(os.path.join(kvm_test_dir, "tests.cfg"))

  45. if args: # 这个args哪儿冒出来的?
  46.     # We get test parameters from command line
  47.     for arg in args:
  48.         try:
  49.             (key, value) = re.findall("^(\w+)=(.*)", arg)[0]
  50.             if key == "only":
  51.                 str += "only %s\n" % value
  52.             elif key == "no":
  53.                 str += "no %s\n" % value
  54.             else:
  55.                 str += "%s = %s\n" % (key, value)
  56.         except IndexError:
  57.             pass
  58. parser.parse_string(str)

  59. virt_utils.run_tests(parser, job) # 还有这个job
上一篇:python Tk 为您报时
下一篇:精通 Python十一点