Author: gnichols
Date: 2012-09-19 15:38:04 +0000 (Wed, 19 Sep 2012)
New Revision: 1377
Removed:
trunk/tests/expresscard/runtest.sh
Modified:
trunk/tests/expresscard/Makefile
trunk/tests/expresscard/expresscard.py
Log:
843605 - expresscard test should not use HAL
Modified: trunk/tests/expresscard/Makefile
===================================================================
--- trunk/tests/expresscard/Makefile 2012-09-06 15:43:38 UTC (rev 1376)
+++ trunk/tests/expresscard/Makefile 2012-09-19 15:38:04 UTC (rev 1377)
@@ -15,17 +15,15 @@
.PHONY: all install download clean
-FILES=$(METADATA) runtest.sh expresscard.py
+FILES=expresscard.py
run: $(FILES) build
- ./runtest.sh
build: $(BUILT_FILES)
- chmod a+x ./runtest.sh ./expresscard.py
+ chmod a+x ./expresscard.py
clean:
rm -f $(BUILT_FILES)
# Include Common Makefile
include $(DESTDIR)/usr/share/v7/lib/v7-make.include
-
Modified: trunk/tests/expresscard/expresscard.py
===================================================================
--- trunk/tests/expresscard/expresscard.py 2012-09-06 15:43:38 UTC (rev 1376)
+++ trunk/tests/expresscard/expresscard.py 2012-09-19 15:38:04 UTC (rev 1377)
@@ -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,116 +20,105 @@
import string
import signal
import sys
-import commands
+import commands
import re
import time
import dbus
import curses
from v7.tags import Constants, DeviceClass
-from v7.hal import Hal
-from v7.procDeviceDetector import ProcDeviceDetector
from v7.test import Test
from v7.device import Device
from v7.usbTest import USBTestBase
+from v7.command import Command
class ExpressCardTest(USBTestBase):
def __init__(self):
USBTestBase.__init__(self, name="expresscard")
self.deviceClass = DeviceClass.expresscard
-
-
+ self.lspciCommand = "lspci -D"
+
+ def getRequiredRPMs(self):
+ return ["pciutils"]
+
def plan(self, planner):
tests = list()
- isXenGuest = False
- hasUSB = False
- hasBattery = False
- hasPCIE = False
- # run if there's a device with info.product == usb and it's not a Xen
guest.
- devices = planner.getHalDeviceDetector().getDevices()
- for device in devices:
- if device.getProperty("info.product") == "Computer" and
device.getProperty("smbios.bios.vendor") == "Xen":
- isXenGuest = True
- if device.getProperty("info.bus") == "usb":
- hasUSB = True
- if 'battery' in device.getProperty("info.category"):
- hasBattery = True
- if device.getProperty("info.linux.driver") in
["pcieport-driver", "pcieport"]:
- hasPCIE = True
- if hasUSB and hasBattery and hasPCIE and not isXenGuest:
- test = self.makeCopy()
- tests.append(test)
+ # manually planned for now
return tests
def getPCIDevices(self):
-
- self.deviceDetector = Hal()
- devices = self.deviceDetector.getDevices()
+ devices = list()
+ pattern =
re.compile("(?P<id>[0-9a-f]{4}:[0-9a-f]{2}:[0-9a-f]{2}\.[0-9a-f])
(?P<name>.*$)")
+ try:
+ pipe = Command(self.lspciCommand)
+ pipe.start()
+ while 1:
+ line = pipe.readline()
+ if not line or line.strip() == "":
+ break
+ match = pattern.match(line)
+ # every list is a tuple containing information like:
+ # ('00:00.0','Host bridge: Intel Corporation Core Processor
DRAM Controller (rev 02)')
+ dev = match.groups()
+ devices.append(dev)
+ except Exception, e:
+ print "Error: could not read PCI device from lspci command"
+ print e
+ return None
+
return devices
-
- def checkAllPCIPlugged(self):
+ def checkAllPCIUnplugged(self):
devices = self.getPCIDevices()
+ if not devices:
+ return None
self.pluggedInPCIDevices = list()
- returnValue = True
for dev in devices:
- found = self.deviceDetector.getPCIBusAndID(dev)
- if found:
- (domAndBus, devAndFn, deviceID) = found
- self.pluggedInPCIDevices.append(deviceID)
- if domAndBus and devAndFn:
- try:
- print " %s appears to be attached on PCI bus: %s:%s"
% (self.deviceDetector.getProduct(dev), domAndBus, devAndFn)
- except KeyError:
- pass
+ (id, name) = dev
+ if id:
+ self.pluggedInPCIDevices.append(id)
+ print " %s appears to be attached on PCI bus: %s" % (name,
id)
def addNewPCIPlugged(self, verifiedDevices):
devices = self.getPCIDevices()
+ if not devices:
+ return None
for dev in devices:
- found = self.deviceDetector.getPCIBusAndID(dev)
- if found:
- (domAndBus, devAndFn, deviceID) = found
- if (not deviceID in self.pluggedInPCIDevices) and domAndBus and
devAndFn:
- if deviceID in verifiedDevices:
- print "\n Note: Same device been plugged into the same
slot.\n"
- return None
- else:
- deviceName = self.deviceDetector.getProduct(dev)
- if deviceName == "":
- deviceName = deviceID
- print "\n Device attached to PCI bus: \
- \n %s appears to be attached on PCI bus: %s:%s"
% (self.deviceDetector.getProduct(dev), domAndBus, devAndFn)
- return (domAndBus, devAndFn, deviceID)
+ (id, name) = dev
+ # should execute checkAllPCIUnplugged() first
+ if id and not id in self.pluggedInPCIDevices:
+ if id in verifiedDevices:
+ print "\n Note: Same device been plugged into the same
slot.\n"
+ return None
+ else:
+ print "\n Device attached to PCI bus: \
+ \n %s appears to be attached on PCI bus: %s" %
(name, id)
+ return id
return None
- def confirmPCIUnplugged(self, searchDeviceID):
+ def confirmPCIUnplugged(self, searchID):
devices = self.getPCIDevices()
+ if not devices:
+ return True
for dev in devices:
- found = self.deviceDetector.getPCIBusAndID(dev)
- if found:
- (domAndBus, devAndFn, deviceID) = found
- if deviceID == searchDeviceID:
- return False
+ (id, name) = dev
+ if id == searchID:
+ return False
+
return True
-
def pciInfo(self):
"""return detailed PCI info"""
pciinfo = commands.getoutput("lspci -vvvv")
return pciinfo
- def halInfo(self):
- """return current HAL info"""
- halinfo = commands.getoutput("lshal")
- return halinfo
+ def udevInfo(self):
+ """return current udev info"""
+ udevinfo = commands.getoutput("udevadm info --export-db")
+ return udevinfo
- def kudzuInfo(self):
- """return current Kudzu info"""
- kudzuinfo = commands.getoutput("kudzu -p")
- return kudzuinfo
-
def contextDiff(self, context1, context2):
"""compare two "files" and return the diff
parts"""
tmpFile1 = "/tmp/v7ExpressCardTmpFile1"
@@ -161,11 +150,8 @@
print ("\n---- Current USB devices ----")
self.checkAllUSBPortsUnplugged()
- # load the pciehp module on RHEL5 in case it's not loaded yet
- print("\nChecking pciehp module...")
- self.loadKernelModule("pciehp")
print ("\n---- Current PCI devices ----")
- self.checkAllPCIPlugged()
+ self.checkAllPCIUnplugged()
# ask user how many ExpressCard slots are there ?
while True:
self.input = self.prompt("How many ExpressCard slots are there ?
")
@@ -191,13 +177,13 @@
self.count = self.count - 1
self.pciInfoOld = self.pciInfo()
- self.halInfoOld = self.halInfo()
+ self.udevInfoOld = self.udevInfo()
if not self.promptContinue("Please plug in an ExpressCard
device"):
result = Constants.ABORT
return FAILED
# gather new HW info
self.pciInfoNew = self.pciInfo()
- self.halInfoNew = self.halInfo()
+ self.udevInfoNew = self.udevInfo()
foundUSB = None
if self.count > 0 or not testedUSB:
@@ -216,43 +202,43 @@
# confirm USB
if foundUSB:
- (busNumber, portNumber, deviceID) = foundUSB
- if self.confirmUSBPortUnplugged(deviceID):
+ deviceID = foundUSB
+ if self.confirmUSBPortUnplugged(searchID=deviceID):
print "Confirmed USB device %s" % deviceID
verifiedDevices.append(deviceID)
self.pluggedInDevices.append(deviceID)
confirmed = True
testedUSB = True
if foundPCIE:
- (busNumber, portNumber, deviceID) = foundPCIE
- if self.confirmPCIUnplugged(deviceID):
+ deviceID = foundPCIE
+ if self.confirmPCIUnplugged(searchID=deviceID):
print "Confirmed PCIE device %s" % deviceID
verifiedDevices.append(deviceID)
self.pluggedInPCIDevices.append(deviceID)
confirmed = True
testedPCIE = True
- if not foundPCIE and not foundUSB:
+ if not foundPCIE and not foundUSB:
print "Error: Did not confirm the device !"
print "Please re-try"
# print out the detailed HW info for reviewers
pciDiff = self.contextDiff(self.pciInfoOld, self.pciInfoNew)
- halDiff = self.contextDiff(self.halInfoOld, self.halInfoNew)
+ udevDiff = self.contextDiff(self.udevInfoOld, self.udevInfoNew)
print "\n========== Detailed HW info ========== \
\n---------- lspci ---------- \
\n%s \
\n-------------------------------------- \
- \n---------- HAL ---------- \
+ \n---------- udev ---------- \
\n%s \
\n-------------------------------------- \
\n======================================\n"\
- % (pciDiff, halDiff)
+ % (pciDiff, udevDiff)
if returnValue == PASSED:
result = "passed"
else:
- returnValue = FAILED
+ returnValue = FAILED
result = "failed"
print "ExpressCard test %s" % result
return returnValue
Deleted: trunk/tests/expresscard/runtest.sh
===================================================================
--- trunk/tests/expresscard/runtest.sh 2012-09-06 15:43:38 UTC (rev 1376)
+++ trunk/tests/expresscard/runtest.sh 2012-09-19 15:38:04 UTC (rev 1377)
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-v7-run-simple-test ${TEST:-$(basename $PWD)} ./expresscard.py