Author: gnichols
Date: 2012-08-23 18:44:20 +0000 (Thu, 23 Aug 2012)
New Revision: 1362
Removed:
trunk/tests/tape/runtest.sh
Modified:
trunk/tests/tape/Makefile
trunk/tests/tape/tape.py
trunk/v7/udevDeviceDetector.py
Log:
843613 - tape test should not use HA
Modified: trunk/tests/tape/Makefile
===================================================================
--- trunk/tests/tape/Makefile 2012-08-23 18:28:23 UTC (rev 1361)
+++ trunk/tests/tape/Makefile 2012-08-23 18:44:20 UTC (rev 1362)
@@ -15,13 +15,12 @@
.PHONY: all install download clean
-FILES=runtest.sh tape.py
+FILES=tape.py
run: $(FILES) build
- ./runtest.sh
build: $(BUILT_FILES)
- chmod a+x ./runtest.sh ./tape.py
+ chmod a+x ./tape.py
clean:
@@ -30,6 +29,3 @@
# Include Common Makefile
include $(DESTDIR)/usr/share/v7/lib/v7-make.include
-
-
-
Deleted: trunk/tests/tape/runtest.sh
===================================================================
--- trunk/tests/tape/runtest.sh 2012-08-23 18:28:23 UTC (rev 1361)
+++ trunk/tests/tape/runtest.sh 2012-08-23 18:44:20 UTC (rev 1362)
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-v7-run-simple-test ${TEST:-$(basename $PWD)} ./tape.py
Modified: trunk/tests/tape/tape.py
===================================================================
--- trunk/tests/tape/tape.py 2012-08-23 18:28:23 UTC (rev 1361)
+++ trunk/tests/tape/tape.py 2012-08-23 18:44:20 UTC (rev 1362)
@@ -1,9 +1,9 @@
#!/usr/bin/python
-# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material
-# is made available to anyone wishing to use, modify, copy, or
-# redistribute it subject to the terms and conditions of the GNU General
+# Copyright (c) 2006 Red Hat, Inc. All rights reserved. This copyrighted material
+# is made available to anyone wishing to use, modify, copy, or
+# redistribute it subject to the terms and conditions of the GNU General
# Public License v.2.
-#
+#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
@@ -20,95 +20,86 @@
import string
import sys
import commands
+import re
from v7.test import Test
from v7.command import Command, V7CommandException
-from v7.hal import Hal
from v7.tags import DeviceClass, TestTag
+from v7.udevDeviceDetector import UdevDeviceDetector
-class TapeTest(Test):
-
+class TapeTest(Test):
+
def __init__(self):
Test.__init__(self, name="tape")
self.deviceClass = DeviceClass.sequential
-
+
def tags(self):
return [TestTag.noninteractive, TestTag.certification]
-
+
def plan(self, planner):
tests = list()
- devices = planner.getHalDeviceDetector().getDevices()
+ devices = planner.getUdevDeviceDetector().getDevices()
for device in devices:
- if 'tape' in device.getProperty("storage.drive_type") == 7
or device.getProperty("info.linux.driver") == 'st' or
device.getProperty("info.linux.driver")[0:4] == 'tape':
+ if 'tape' in device.getProperty("SUBSYSTEM") and
re.compile("\/dev\/st\d+$").match(device.getProperty("DEVNAME")):
test = self.makeCopy()
test.setDevice(device)
tests.append(test)
return tests
-
+
def getRequiredRPMs(self):
return ["mt-st"]
def getTapeDeviceName(self):
-
+
if self.getLogicalDeviceName():
- return self.getLogicalDeviceName()
-
+ return self.getLogicalDeviceName()
+
#otherwise
if not self.udi:
print "Error: no UDI or logical device name for tape"
return None
-
+
#otherwise
print "Using UDI to find the correct device name ."
- # first, try linux.sysfs_path
try:
- hal = Hal()
- device = hal.getDevice(self.udi)
+ device = UdevDeviceDetector().getDevice(self.udi)
if device:
- sysfsPath = "%s/tape" %
device.getProperty("linux.sysfs_path")
- # was: ls -l %s | rev | sed 's/\// /g' | awk '{print
$1}' | rev
- return Command("ls -l %s" %
sysfsPath).getString(regex="[^/]+$")
-
- # otherwise, find .device_file in child UDI
- for device in hal.getDevices():
- # removed "and "rtibm" in device.getUDI()" - this
might work elsewhere
- if self.udi in device.getProperty("info.parent") :
- return device.getProperty("linux.device_file")[5:]
-
+ return device.getProperty("DEVNAME")
+
except V7CommandException, exception:
print "Error: could not determine tape device name"
print exception
return None
-
-
+
+
def run(self):
tapeDevice = self.getTapeDeviceName()
if not tapeDevice:
return 1
-
+
print "Testing tape device %s" % tapeDevice
-
+
# set default block size to 32k (64 x 512byte = 32k)
bs=64
- # rewind the tape incase the tape is not rewinded.
- os.system("mt -f /dev/%s rewind 2>/dev/null" % tapeDevice)
- if os.system("tar -Pcb %s -f /dev/%s /usr" % (bs,tapeDevice)) is 0:
- print "Write data done. Start comparing ..."
- if os.system("tar -Pdb %s -f /dev/%s /usr" % (bs,tapeDevice)) is
0:
- print "Tape test on device %s passed." % tapeDevice
- return 0
+ try:
+ # rewind the tape incase the tape is not rewinded.
+ Command("mt -f %s rewind 2>/dev/null" % tapeDevice).run()
+ if Command("tar -Pcb %s -f %s /usr" % (bs, tapeDevice)).echo() is
0:
+ print "Write data done. Start comparing ..."
+ if Command("tar -Pdb %s -f %s /usr" % (bs, tapeDevice)).echo()
is 0:
+ print "Tape test on device %s passed." % tapeDevice
+ return 0
+ else:
+ print "Error: Data comparison failed !"
+ return 1
else:
- print "Error: Data comparison failed !"
+ print "Error: Write data Error !"
return 1
- else:
- print "Error: Write data Error !"
+ except V7CommandException, exception:
+ print exception
return 1
if __name__ == "__main__":
test = TapeTest()
returnValue = test.do(sys.argv)
sys.exit(returnValue)
-
-
-
-
Modified: trunk/v7/udevDeviceDetector.py
===================================================================
--- trunk/v7/udevDeviceDetector.py 2012-08-23 18:28:23 UTC (rev 1361)
+++ trunk/v7/udevDeviceDetector.py 2012-08-23 18:44:20 UTC (rev 1362)
@@ -10,7 +10,7 @@
from v7.deviceDetector import DeviceDetector
from v7.tags import Constants
from v7.documentbase import DocumentWrapper
-from v7.command import Command
+from v7.command import Command, V7CommandException
class UdevDeviceDetector(DeviceDetector):
"A class for working with udev."
@@ -19,15 +19,14 @@
self.enabled = True
self.recordSeperator = "\n"
self.allDevicesCommand = "udevadm info --export-db"
- self.getDeviceCommand = "udevadm info --query=all --path %s"
-
- def getDevice(self,udi):
+ self.getDeviceCommand = "udevadm info --query=all --path %s"
+
+ def getDevice(self, udi):
"Return a Device object for the given UDI."
properties = None
try:
udevadm = Command(self.getDeviceCommand % udi)
- record = udevadm.getString(singleLine=False)
- lines = record.split("\n")
+ lines = udevadm.getStringList(regex=".*")
stringNumber=0
properties = dict()
for line in lines:
@@ -36,12 +35,12 @@
print "Error: could not find udev device %s" % udi
print e
return None
-
+
if properties:
return UdevDevice(properties)
# otherwise
return None
-
+
def __getProperty(self, line, properties, stringNumber):
docWrapper = DocumentWrapper()
line = docWrapper.removeBadCharacters(line)
@@ -59,16 +58,16 @@
stringNumber += 1
elif type == "P":
properties[Constants.info_dot_udi] = attribute
-
+
return stringNumber
-
- def getDevices(self):
+
+ def getDevices(self):
self.devices = list()
try:
pipe = Command(self.allDevicesCommand)
pipe.start()
properties = dict()
- stringNumber = 0
+ stringNumber = 0
while 1:
line = pipe.readline()
if line:
@@ -86,7 +85,7 @@
break
except Exception, e:
if self.debug != Constants.off:
- print "Warning: udev device detector could not load devices"
+ print "Warning: udev device detector could not load devices"
print e
pass
return self.devices