daemon_args = ['--helper-dir', os.path.join(os.getcwd(), 'src',
'helpers')]
klass.tool_path = 'tools/udisks'
- print('Testing binaries from local build tree')
+ print 'Testing binaries from local build tree'
klass.check_build_tree_config()
else:
- print('Testing installed system binaries')
+ print 'Testing installed system binaries'
daemon_path = None
for l in open('/usr/share/dbus-1/system-services/org.freedesktop.UDisks.service'):
if l.startswith('Exec='):
daemon_args = []
klass.tool_path = 'udisks'
- print('daemon path: ' + daemon_path)
+ print 'daemon path:', daemon_path
klass.device = klass.setup_vdev()
while timeout >= 0:
try:
return fn(*args)
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
if e._dbus_error_name != 'org.freedesktop.UDisks.Error.Busy':
raise
- sys.stderr.write('[busy] ')
+ print >> sys.stderr, '[busy] ',
time.sleep(0.3)
timeout -= 1
# expand make variables
subst_re = re.compile('\${([a-zA-Z_]+)}')
- for (k, v) in make_vars.items():
+ for (k, v) in make_vars.iteritems():
while True:
m = subst_re.search(v)
if m:
for d in (os.path.join(make_vars['localstatedir'], 'run', 'udisks'),
os.path.join(make_vars['localstatedir'], 'lib', 'udisks')):
if not os.path.exists(d):
- sys.stderr.write('The directory %s does not exist; please create it before running these tests.\n' % d)
+ print >> sys.stderr, 'The directory %s does not exist; please create it before running these tests.' % d
sys.exit(0)
@classmethod
'''
# ensure that the scsi_debug module is loaded
if os.path.isdir('/sys/module/scsi_debug'):
- sys.stderr.write('The scsi_debug module is already loaded; please remove before running this test.\n')
+ print >> sys.stderr, 'The scsi_debug module is already loaded; please remove before running this test.'
sys.exit(1)
assert subprocess.call(['modprobe', 'scsi_debug', 'dev_size_mb=%i' % (
# let's be 100% sure that we pick a virtual one
assert open('/sys/block/%s/device/model' % devs[0]).read().strip() == 'scsi_debug'
- print('Set up test device: ' + dev)
+ print 'Set up test device:', dev
return dev
@classmethod
def tearDown(self):
if subprocess.call(['umount', self.device], stderr=subprocess.PIPE) == 0:
- sys.stderr.write('[cleanup unmount] ')
+ print >> sys.stderr, '[cleanup unmount] ',
shutil.rmtree (self.workdir)
def test_zero(self):
if type != 'swap' and subprocess.call(['which', 'mkfs.' + type],
stdout=subprocess.PIPE) != 0:
- sys.stderr.write('[no mkfs.%s, skip] ' % type)
+ print >> sys.stderr, '[no mkfs.%s, skip] ' % type,
# check correct D-Bus exception
try:
self.fs_create(None, type, [])
self.fail('Expected failure for missing mkfs.' + type)
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assertEqual(e._dbus_error_name,
'org.freedesktop.UDisks.Error.FilesystemToolsMissing',
str(e))
return
# do checks with command line tools (mkfs/mount/umount)
- sys.stderr.write('[cli] ')
+ print >> sys.stderr, '[cli]',
self._do_mkfs_check(type)
if type != 'minix':
self.mkfs('ext3')
# do checks with DK-Disks D-BUS operations
- sys.stderr.write('[ud] ')
+ print >> sys.stderr, '[ud] ',
self._do_dbus_fs_check(type)
if type != 'minix':
self._do_dbus_fs_check(type, 'test%stst' % type)
if ret == 32:
# missing fs driver
- sys.stderr.write('[missing kernel driver, skip] ')
+ print >> sys.stderr, '[missing kernel driver, skip] ',
return
self.assertEqual(ret, 0)
# mount
try:
mount_path = iface.FilesystemMount('', [])
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assertEqual(e._dbus_error_name,
'org.freedesktop.UDisks.Error.FilesystemDriverMissing',
str(e))
- sys.stderr.write('[missing kernel driver, skip] ')
+ print >> sys.stderr, '[missing kernel driver, skip] ',
return
if label:
self._do_schema('apm', 'Apple_Unix_SVR2', 'Foo', 'allow_write',
exp_default_partitions=2) # Apple creates bootstrap stuff by default
self.fail('creating apple partition at offset 0 should fail due to default bootstrap partitions')
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assert_("Can't have overlapping partitions." in str(e))
self._do_schema('apm', 'Apple_Unix_SVR2', 'Foo', 'allow_write',
# create /dev/md5p2 and following
#self.partition_iface().PartitionCreate(0, 10000000, type2, '',
# [flag], [], '', [])
- #print (self.fdisk_list())
+ #print self.fdisk_list()
# the device is not a partition, so calls should fail
self.assertRaises(dbus.DBusException,
hd = '/dev/sda'
if not os.path.exists(hd):
- sys.stderr.write('[skip] ')
+ print >> sys.stderr, '[skip]',
return
has_smart = subprocess.call(['skdump', '--can-smart', hd],
has_smart)
if has_smart:
- sys.stderr.write('[avail] ')
+ print >> sys.stderr, '[avail] ',
# wait for SMART data to be read
while props.Get(I_D, 'DriveAtaSmartTimeCollected') == 0:
- sys.stderr.write('[wait for data] ')
+ print >> sys.stderr, '[wait for data] ',
time.sleep(0.5)
info = self.get_info(devname=hd)
try:
self.partition_iface().DriveAtaSmartInitiateSelftest('bogus', [])
self.fail('bogus mode succeeded')
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assertEqual(e._dbus_error_name, 'org.freedesktop.UDisks.Error.Failed')
else:
- sys.stderr.write('[N/A] ')
+ print >> sys.stderr, '[N/A] ',
self.assertEqual(info['ATA SMART'], 'not available')
self.assertEqual(props.Get(I_D, 'DriveAtaSmartTimeCollected'), 0)
self.assertEqual(props.Get(I_D, 'DriveAtaSmartBlob'), [])
try:
self.partition_iface().DriveAtaSmartInitiateSelftest('short', [])
self.fail('device did not report to have SMART capabilities')
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assert_('does not support ATA SMART' in str(e))
def test_simulate(self):
global hd_smart_blob
if not hd_smart_blob:
- sys.stderr.write('[skip] ')
+ print >> sys.stderr, '[skip]',
return
props = self.partition_props()
try:
self.partition_iface().DriveAtaSmartRefreshData([])
self.fail('expected "Device does not support ATA SMART"')
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assert_('does not support ATA SMART' in str(e))
try:
self.partition_iface().DriveAtaSmartInitiateSelftest('short', [])
self.fail('fake device is not expected to have SMART capabilities')
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assert_('does not support ATA SMART' in str(e))
# load the blob
try:
self.partition_iface().FilesystemMount('', [])
self.fail('.FilesystemMount() succeeded while inhibited')
- except dbus.DBusException as e:
+ except dbus.DBusException, e:
self.assert_(e._dbus_error_name.endswith('Error.Inhibited'))
# Inhibit() another time