ia64/xen-unstable

changeset 9631:9fcfdab04aa9

Factor out the parsing of XAUTHORITY, so that it can be used by the unit test,
and fix that test to use it.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Thu Apr 06 14:22:52 2006 +0100 (2006-04-06)
parents edeeddb1bbf9
children fb174770f426
files tools/python/xen/xm/create.py tools/python/xen/xm/tests/test_create.py
line diff
     1.1 --- a/tools/python/xen/xm/create.py	Thu Apr 06 14:21:45 2006 +0100
     1.2 +++ b/tools/python/xen/xm/create.py	Thu Apr 06 14:22:52 2006 +0100
     1.3 @@ -850,6 +850,18 @@ def make_domain(opts, config):
     1.4      opts.info("Started domain %s" % (dom))
     1.5      return int(sxp.child_value(dominfo, 'domid'))
     1.6  
     1.7 +
     1.8 +def get_xauthority():
     1.9 +    xauth = os.getenv("XAUTHORITY")
    1.10 +    if not xauth:
    1.11 +        home = os.getenv("HOME")
    1.12 +        if not home:
    1.13 +            import posix, pwd
    1.14 +            home = pwd.getpwuid(posix.getuid())[5]
    1.15 +        xauth = home + "/.Xauthority"
    1.16 +    return xauth
    1.17 +
    1.18 +
    1.19  def parseCommandLine(argv):
    1.20      gopts.reset()
    1.21      args = gopts.parse(argv)
    1.22 @@ -864,14 +876,7 @@ def parseCommandLine(argv):
    1.23          gopts.vals.display = os.getenv("DISPLAY")
    1.24  
    1.25      if not gopts.vals.xauthority:
    1.26 -        xauth = os.getenv("XAUTHORITY")
    1.27 -        if not xauth:
    1.28 -            home = os.getenv("HOME")
    1.29 -            if not home:
    1.30 -                import posix, pwd
    1.31 -                home = pwd.getpwuid(posix.getuid())[5]
    1.32 -            xauth = home + "/.Xauthority"
    1.33 -        gopts.vals.xauthority = xauth
    1.34 +        gopts.vals.xauthority = get_xauthority()
    1.35  
    1.36      # Process remaining args as config variables.
    1.37      for arg in args:
     2.1 --- a/tools/python/xen/xm/tests/test_create.py	Thu Apr 06 14:21:45 2006 +0100
     2.2 +++ b/tools/python/xen/xm/tests/test_create.py	Thu Apr 06 14:22:52 2006 +0100
     2.3 @@ -51,6 +51,7 @@ class test_create(unittest.TestCase):
     2.4                   'path'      : '.:/etc/xen',
     2.5                   'builder'   : 'linux',
     2.6                   'nics'      : -1,
     2.7 +                 'xauthority': xen.xm.create.get_xauthority(),
     2.8                   })
     2.9  
    2.10  
    2.11 @@ -99,6 +100,8 @@ on_crash    = 'destroy'
    2.12                   'interface'   : 'eth0',
    2.13                   'path'        : '.:/etc/xen',
    2.14                   'builder'     : 'linux',
    2.15 +
    2.16 +                 'xauthority'  : xen.xm.create.get_xauthority(),
    2.17                 })
    2.18  
    2.19  
    2.20 @@ -138,6 +141,8 @@ cpu_weight = 0.75
    2.21                   'path'       : '.:/etc/xen',
    2.22                   'builder'    : 'linux',
    2.23                   'nics'       : -1,
    2.24 +
    2.25 +                 'xauthority' : xen.xm.create.get_xauthority(),
    2.26                   })
    2.27              
    2.28  
    2.29 @@ -188,6 +193,8 @@ ne2000=0
    2.30                   'dhcp'        : 'off',
    2.31                   'interface'   : 'eth0',
    2.32                   'path'        : '.:/etc/xen',
    2.33 +
    2.34 +                 'xauthority'  : xen.xm.create.get_xauthority(),
    2.35                 })
    2.36  
    2.37