direct-io.hg

changeset 7930:d88b33abf533

Added another test. Fix the existing tests to close the written config file
before running the test upon it, to ensure that the file is flushed.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Mon Nov 21 13:03:45 2005 +0100 (2005-11-21)
parents 4f7b4ca2e30c
children 52a3c06be4f8
files tools/python/xen/xm/tests/test_create.py
line diff
     1.1 --- a/tools/python/xen/xm/tests/test_create.py	Mon Nov 21 13:00:36 2005 +0100
     1.2 +++ b/tools/python/xen/xm/tests/test_create.py	Mon Nov 21 13:03:45 2005 +0100
     1.3 @@ -34,31 +34,79 @@ class test_create(unittest.TestCase):
     1.4  
     1.5      def testCommandLine(self):
     1.6          (fd, fname) = tempfile.mkstemp()
     1.7 +        os.close(fd)
     1.8 +        self.t('-f %s kernel=/mykernel display=fakedisplay '
     1.9 +               'macaddr=ab:cd:ef:ed nics=0' % fname,
    1.10 +               { 'name'      : os.path.basename(fname),
    1.11 +                 'xm_file'   : fname,
    1.12 +                 'defconfig' : fname,
    1.13 +                 'kernel'    : '/mykernel',
    1.14 +                 'display'   : 'fakedisplay',
    1.15 +                 'macaddr'   : 'ab:cd:ef:ed',
    1.16 +                 'memory'    : 128,
    1.17 +                 'vcpus'     : 1,
    1.18 +                 'boot'      : 'c',
    1.19 +                 'dhcp'      : 'off',
    1.20 +                 'interface' : 'eth0',
    1.21 +                 'path'      : '.:/etc/xen',
    1.22 +                 'builder'   : 'linux',
    1.23 +                 })
    1.24 +
    1.25 +
    1.26 +    def testConfigFile(self):
    1.27 +        (fd, fname) = tempfile.mkstemp()
    1.28          try:
    1.29 -            self.t('-f %s kernel=/mykernel display=fakedisplay '
    1.30 -                   'macaddr=ab:cd:ef:ed nics=0' % fname,
    1.31 -                   { 'name'      : os.path.basename(fname),
    1.32 -                     'xm_file'   : fname,
    1.33 -                     'defconfig' : fname,
    1.34 -                     'kernel'    : '/mykernel',
    1.35 -                     'display'   : 'fakedisplay',
    1.36 -                     'macaddr'   : 'ab:cd:ef:ed',
    1.37 -                     'memory'    : 128,
    1.38 -                     'vcpus'     : 1,
    1.39 -                     'boot'      : 'c',
    1.40 -                     'dhcp'      : 'off',
    1.41 -                     'interface' : 'eth0',
    1.42 -                     'path'      : '.:/etc/xen',
    1.43 -                     'builder'   : 'linux',
    1.44 -                     })
    1.45 +            os.write(fd,
    1.46 +                     '''
    1.47 +kernel = "/boot/vmlinuz-xenU-smp"
    1.48 +memory = 768
    1.49 +name = "dom1"
    1.50 +vcpus = 4
    1.51 +nics = 1
    1.52 +disk = ['phy:/dev/virt-blkdev-backend/dom1,sda1,w',
    1.53 +'phy:/dev/virt-blkdev-backend/usr,sda2,r']
    1.54 +root = "/dev/sda1 ro"
    1.55 +extra = " profile=1 GATEWAY=10.0.1.254 NETMASK=255.255.0.0 IPADDR=10.0.134.1 HOSTNAME=dom1"
    1.56 +on_poweroff = 'destroy'
    1.57 +on_reboot   = 'destroy'
    1.58 +on_crash    = 'destroy'
    1.59 +                     ''')
    1.60          finally:
    1.61              os.close(fd)
    1.62  
    1.63 +        self.t('-f %s display=fakedisplay' % fname,
    1.64 +               { 'kernel'      : '/boot/vmlinuz-xenU-smp',
    1.65 +                 'memory'      : 768,
    1.66 +                 'name'        : 'dom1',
    1.67 +                 'vcpus'       : 4,
    1.68 +                 'nics'        : 1,
    1.69 +                 'root'        : '/dev/sda1 ro',
    1.70 +                 'extra'       : ' profile=1 GATEWAY=10.0.1.254 NETMASK=255.255.0.0 IPADDR=10.0.134.1 HOSTNAME=dom1',
    1.71 +                 'on_poweroff' : 'destroy',
    1.72 +                 'on_reboot'   : 'destroy',
    1.73 +                 'on_crash'    : 'destroy',
    1.74 +                 'disk'        : [['phy:/dev/virt-blkdev-backend/dom1',
    1.75 +                                   'sda1', 'w', None],
    1.76 +                                  ['phy:/dev/virt-blkdev-backend/usr',
    1.77 +                                   'sda2', 'r', None]],
    1.78 +
    1.79 +                 'xm_file'     : fname,
    1.80 +                 'defconfig'   : fname,
    1.81 +                 'display'     : 'fakedisplay',
    1.82 +
    1.83 +                 'boot'        : 'c',
    1.84 +                 'dhcp'        : 'off',
    1.85 +                 'interface'   : 'eth0',
    1.86 +                 'path'        : '.:/etc/xen',
    1.87 +                 'builder'     : 'linux',
    1.88 +               })
    1.89 +
    1.90  
    1.91      def testConfigFileAndCommandLine(self):
    1.92          (fd, fname) = tempfile.mkstemp()
    1.93 -        os.write(fd,
    1.94 -                 '''
    1.95 +        try:
    1.96 +            os.write(fd,
    1.97 +                     '''
    1.98  name       = "testname"
    1.99  memory     = 256
   1.100  ssidref    = 1
   1.101 @@ -66,30 +114,30 @@ kernel     = "/mykernel"
   1.102  maxmem     = 1024
   1.103  cpu        = 2
   1.104  cpu_weight = 0.75
   1.105 -                 ''')
   1.106 -        try:
   1.107 -            self.t('-f %s display=fakedisplay macaddr=ab:cd:ef:ed nics=0' %
   1.108 -              fname,
   1.109 -                   { 'name'       : 'testname',
   1.110 -                     'xm_file'    : fname,
   1.111 -                     'defconfig'  : fname,
   1.112 -                     'kernel'     : '/mykernel',
   1.113 -                     'display'    : 'fakedisplay',
   1.114 -                     'macaddr'    : 'ab:cd:ef:ed',
   1.115 -                     'memory'     : 256,
   1.116 -                     'maxmem'     : 1024,
   1.117 -                     'cpu'        : 2,
   1.118 -                     'ssidref'    : 1,
   1.119 -                     'cpu_weight' : 0.75,
   1.120 -                     'vcpus'      : 1,
   1.121 -                     'boot'       : 'c',
   1.122 -                     'dhcp'       : 'off',
   1.123 -                     'interface'  : 'eth0',
   1.124 -                     'path'       : '.:/etc/xen',
   1.125 -                     'builder'    : 'linux',
   1.126 -                     })
   1.127 +                     ''')
   1.128          finally:
   1.129              os.close(fd)
   1.130 +
   1.131 +        self.t('-f %s display=fakedisplay macaddr=ab:cd:ef:ed nics=0' %
   1.132 +          fname,
   1.133 +               { 'name'       : 'testname',
   1.134 +                 'xm_file'    : fname,
   1.135 +                 'defconfig'  : fname,
   1.136 +                 'kernel'     : '/mykernel',
   1.137 +                 'display'    : 'fakedisplay',
   1.138 +                 'macaddr'    : 'ab:cd:ef:ed',
   1.139 +                 'memory'     : 256,
   1.140 +                 'maxmem'     : 1024,
   1.141 +                 'cpu'        : 2,
   1.142 +                 'ssidref'    : 1,
   1.143 +                 'cpu_weight' : 0.75,
   1.144 +                 'vcpus'      : 1,
   1.145 +                 'boot'       : 'c',
   1.146 +                 'dhcp'       : 'off',
   1.147 +                 'interface'  : 'eth0',
   1.148 +                 'path'       : '.:/etc/xen',
   1.149 +                 'builder'    : 'linux',
   1.150 +                 })
   1.151              
   1.152  
   1.153  def test_suite():