Author: gnichols
Date: 2010-08-06 01:46:05 +0000 (Fri, 06 Aug 2010)
New Revision: 625
Modified:
trunk/tests/video/video.py
Log:
586941 - v7 on RHEL6 requires rpms not in RHEL6: system-config-display
Modified: trunk/tests/video/video.py
===================================================================
--- trunk/tests/video/video.py 2010-08-06 01:36:10 UTC (rev 624)
+++ trunk/tests/video/video.py 2010-08-06 01:46:05 UTC (rev 625)
@@ -14,16 +14,13 @@
# Author: Irina Boverman
#
-import os
-import sys
-import string
-import commands
-import shutil
+import os, re, sys, string, commands, shutil
# sys.path.append("/home/gnichols/devel/v7")
from v7.test import Test
from v7.command import Command, V7CommandException
from v7.tags import DeviceClass
+from v7.redhatrelease import RedHatRelease
FAILED = 1
PASSED = 0
@@ -57,6 +54,7 @@
self.runOn = "pci.device_subclass == 0 and pci.device_class == 3 "
self.requires = ""
self.deviceClass = DeviceClass.display
+ self.redHatRelease = RedHatRelease()
def plan(self, devices):
# HAL discovery
@@ -71,36 +69,67 @@
return tests
def getRequiredRPMs(self):
- return ["xorg-x11-apps", "system-config-display"]
+ rpms = ["xorg-x11-apps"]
+ if "Red Hat" in self.redHatRelease.getProduct() and self.redHatRelease.getVersion() < 6:
+ rpms.append("system-config-display") # for system-config-display
+ else:
+ rpms.append("xorg-x11-server-Xorg") # for X
+ rpms.append("xorg-x11-xinit") # for startx
+ return rpms
def settool(self):
# Adapt for tool name changes
- (status, self.Xconfig_tool) = commands.getstatusoutput("rpm -q system-config-display > /dev/null && " +
+ if "Red Hat" in self.redHatRelease.getProduct() and self.redHatRelease.getVersion() < 6:
+ (status, self.Xconfig_tool) = commands.getstatusoutput("rpm -q system-config-display > /dev/null && " +
"echo system-config-display || " +
"echo redhat-config-xfree86")
- if status != 0:
- print "FAILED video setup"
- return status
+ if status != 0:
+ print "Error: could not locate X configuration tool"
+ return False
+ else:
+ self.Xconfig_tool = None
+
+ return True
def getfile(self):
- status = os.system(self.Xconfig_tool + " -o " + self.Xconfigfile + " --noui > /dev/null")
- if status != 0:
- print "FAILED to obtain config file"
- return status
+ if self.Xconfig_tool:
+ status = os.system(self.Xconfig_tool + " -o " + self.Xconfigfile + " --noui > /dev/null")
+ if status != 0:
+ print "Error: could not obtain config file"
+ return False
+ else: # check the log
+ self.Xconfigfile = None
+ logPath = "/var/log/Xorg.0.log"
+ if os.path.exists(logPath):
+ log = open(logPath)
+ pattern = re.compile("\(==\) Using config file: \"(?P<filepath>[^\"]+)\"")
+ for line in log.readlines():
+ match = pattern.search(line)
+ if match:
+ self.Xconfigfile = match.group("filepath")
+ print "Using config file " + self.Xconfigfile
+ break
+ log.close()
+ if not self.Xconfigfile:
+ print "No config file found - using Default Config"
+ return True
def setdepth(self):
- (status, self.depth) = commands.getstatusoutput("grep DefaultDepth " + self.Xconfigfile +
+ if self.Xconfigfile:
+ (status, self.depth) = commands.getstatusoutput("grep DefaultDepth " + self.Xconfigfile +
" | awk ' { print $2; } '")
- if status != 0:
- print "FAILED to obtain DefaultDepth"
- return status
- try:
- self.depth = int(self.depth)
- except:
- print "FAILED to obtain depth"
- status = 1
- return status
+ if status != 0:
+ print "Error: could not obtain default depth from config file"
+ return False
+ try:
+ self.depth = int(self.depth)
+ print "Depth set to %u" % self.depth
+ except:
+ print "Error: could not convert depth %s to integer" % self.depth
+ self.depth = None
+ return False
+ return True
def setflag(self):
# Adapt for flag changes
@@ -108,17 +137,30 @@
"echo -xf86config || echo -config")
if status != 0:
print "FAILED to obtain config flag"
- return status
+ return False
+ print "Depth flag: " + self.Xconfig_flag
+ return True
def startx(self):
try: os.remove(self.tmpFile)
- except: None
-
- status = os.system("startx ./x11perftest -- :2 %s %s -depth %s &> /dev/null" % (
- self.Xconfig_flag, self.Xconfigfile,
- str(self.depth)
- ))
+ except: pass
+ startxCommand = "startx ./x11perftest -- :2 "
+ if self.Xconfigfile:
+ startxCommand += "%s %s " % (self.Xconfig_flag, self.Xconfigfile)
+ if self.depth:
+ startxCommand += "-depth %u " % self.depth
+
+ try:
+ print "Running: " + startxCommand
+ startx = Command(startxCommand + " &> /dev/null")
+ startx.echo()
+ except V7CommandException, e:
+ print "Error: startx failed;"
+ print e
+ print startx.printErrors()
+ return False
+
# copy the x11perf log into the output file
if os.path.exists("/var/log/Xorg.0.log"):
shutil.copy("/var/log/Xorg.0.log", ".")
@@ -134,27 +176,27 @@
else:
break
xlog.close();
-
- if status != 0:
- print "FAILED to execute startx"
- return status
+ return True
def xstatus(self):
- resultFile = open(self.tmpFile)
- result = 1 # error
- while 1:
- line = resultFile.readline()
- if line:
- result = string.atoi(line)
- else:
- break
- resultFile.close()
- if result is not 0:
- sys.stdout.write("Error: ")
- print "x11perf returned %d" % result
- return result
-
+ try:
+ resultFile = open(self.tmpFile)
+ result = 1 # error
+ while 1:
+ line = resultFile.readline()
+ if line:
+ result = string.atoi(line)
+ else:
+ break
+ resultFile.close()
+ if result is not 0:
+ sys.stdout.write("Error: x11perf returned %d" % result)
+ return False
+ except IOError:
+ print "Error: x11perf did not run"
+ return False
+ return True
def checkDepthAndResolution(self):
success = True
# try to get the current screen resolution and color depth first
@@ -229,21 +271,21 @@
# print "\nError: no displays connected"
print e
# return FAILED
- return PASSED
+
+ return True
def run(self):
print "Starting video test"
- status = FAILED
- result = "FAILED"
- if (self.checkConnections() == PASSED and self.settool() == PASSED and self.getfile() == PASSED and
- self.setdepth() == PASSED and self.setflag() == PASSED and
- self.startx() == PASSED and self.xstatus() == PASSED and
+ result = FAILED
+ if (self.checkConnections() and self.settool() and self.getfile() and
+ self.setdepth() and self.setflag() and self.startx() and self.xstatus() and
self.checkDepthAndResolution()):
self.logDriverInfo()
- status = PASSED
- result = "passed"
- print "Video test on device %s %s" % (self.interface, result)
- return status
+ result = PASSED
+ print "Video test on device %s passed." % (self.interface)
+ else:
+ print "Video test on device %s FAILED." % (self.interface)
+ return result
if __name__ == "__main__":
videoTest = VideoTest()