Author: gnichols
Date: 2010-01-29 14:56:06 +0000 (Fri, 29 Jan 2010)
New Revision: 350
Modified:
trunk/tests/cdrom/cdrom.py
trunk/tests/dvd/dvd.py
Log:
555898 - optical tests should provide a method to force/override the read-only, write, re-write code path decision
Modified: trunk/tests/cdrom/cdrom.py
===================================================================
--- trunk/tests/cdrom/cdrom.py 2010-01-29 14:52:35 UTC (rev 349)
+++ trunk/tests/cdrom/cdrom.py 2010-01-29 14:56:06 UTC (rev 350)
@@ -124,10 +124,13 @@
if not self.initializeDeviceInfo():
return FAILED
- print "\n Your CD/DVD device /dev/%s supports %s " % (self.getLogicalDeviceName(), self.showSupportedMedia())
- print " We will check these features. "
- print " You need to prepare following media(disks) for this test: \n"
- self.askForDisk(self.supportedMedia[0])
+ print "Your device /dev/%s supports %s " % (self.getLogicalDeviceName(), self.showSupportedMedia())
+ if self.promptConfirm( "Would you like to test %s media?" % self.printMediaName(self.supportedMedia[0])):
+ media = self.supportedMedia[0]
+ else:
+ media = self.convertMediaName(self.prompt("What media would you like to test?", map(self.printMediaName, self.supportedMedia)))
+ print "Required media:"
+ self.askForDisk(media)
# if auto or self-test mode
if self.getMode() != Constants.normal:
@@ -135,17 +138,18 @@
return 0
# otherwise, normal test mode
- self.prompt("\n Press ENTER when you are ready ! Or press Ctrl-C to quit !")
+ if not self.promptConfirm("continue?"):
+ return FAILED
# test cdrom/cd-r/cd-rw
- if self.supportedMedia[0] == "cdrom" and self.testDisk(message="data CD", readWriteMode="read", type="cdrom"):
+ if media == "cdrom" and self.testDisk(message="data CD", readWriteMode="read", type="cdrom"):
return PASSED
- if self.supportedMedia[0] == "cdr" and self.testDisk(message="blank CD-R", readWriteMode="write", type="cdrom"):
+ if media == "cdr" and self.testDisk(message="blank CD-R", readWriteMode="write", type="cdrom"):
return PASSED
- if self.supportedMedia[0] == "cdrw" and self.testDisk(message="good CD-RW", readWriteMode="rewrite", type="cdrom"):
+ if media == "cdrw" and self.testDisk(message="good CD-RW", readWriteMode="rewrite", type="cdrom"):
return PASSED
# OTHERWISE
Modified: trunk/tests/dvd/dvd.py
===================================================================
--- trunk/tests/dvd/dvd.py 2010-01-29 14:52:35 UTC (rev 349)
+++ trunk/tests/dvd/dvd.py 2010-01-29 14:56:06 UTC (rev 350)
@@ -43,84 +43,14 @@
self.deviceClass = DeviceClass.optical
self.fileSourceDir = "/usr/share" # ranges from 970MB-3.5GB
- def askForDisks(self):
-
- # given that self.supportedMediaTypes is in order of preference,
- # find the most preferred media type to test for "-" and "+" incarnations
- dvdMode = None
- dvdPlusMode = None
- for media in self.supportedMedia:
- if "plus" in media:
- if dvdPlusMode is None:
- dvdPlusMode = media
- elif dvdMode is None:
- dvdMode = media
-
- # DVD-/+ both ?
- if dvdMode is None or dvdPlusMode is None:
- dvdBoth = False
- else:
- dvdBoth = True
-
- if dvdBoth:
- if dvdMode == "dvdrw":
- print " --- one good DVD-RW or DVD+RW disk "
- elif dvdMode == "dvdr":
- print " --- one blank DVD-R or DVD+R disk "
- else:
- print "\n +++ Error: Unknown dvdMode.\n"
- return False
- elif dvdMode:
- if dvdMode == "dvd":
- print " --- one DVD data disk which contains more than 800MiB of data. "
- print " (e.g. one RHEL5 install DVD disk) "
- elif dvdMode == "dvdr":
- print " --- one blank DVD-R disk "
- elif dvdMode == "dvdrw":
- print " --- one good DVD-RW disk "
- else:
- print "\n +++ Error: Unknown dvdMode.\n"
- return False
- elif dvdPlusMode:
- if dvdPlusMode == "dvdplusr":
- print " --- one blank DVD-R or DVD+R disk "
- elif dvdPlusMode == "dvdplusrw":
- print " --- one good DVD-RW or DVD+RW disk "
- else:
- print "\n +++ Error: Unknown dvdPlusMode.\n"
- else:
- print "\n"
- sys.stdout.flush()
- return (dvdBoth, dvdMode, dvdPlusMode)
+ def getMediaChoice(self):
+ # default to the most-capable media
+ self.mediaChoice = self.supportedMedia[0]
+ if not self.promptConfirm("Would you like to test %s media?" % self.printMediaName(self.mediaChoice)):
+ choice = self.prompt("Please choose the media to be tested: ", map(self.printMediaName, self.supportedMedia))
+ self.mediaChoice = self.convertMediaName(choice)
- def getMediaChoice(self):
- (bothPlusAndMinusMedia, dvdMode, dvdPlusMode) = self.askForDisks()
- # if support both dvd- and dvd+
- if bothPlusAndMinusMedia:
- print "\n"
- print " Your DVD drive /dev/%s supports both %s and %s . " % (self.getLogicalDeviceName(),dvdMode,dvdPlusMode)
- print " To save the testing time, only one of them is required to be tested . "
- print " ( Of course you can choose to test both of them :-) )"
-
- self.mediaChoices = [dvdMode, dvdPlusMode, "both"]
- if self.getMode() == Constants.normal:
- while True:
- choice = self.prompt("Which media would you like to test?", self.mediaChoices)
- if choice in self.mediaChoices:
- self.mediaChoice = choice
- return self.mediaChoice
- else:
- print "please choose one of:"
- print self.mediaChoices
-
- # otherwise
- if dvdMode:
- self.mediaChoice = dvdMode
- elif dvdPlusMode:
- rself.mediaChoice = dvdPlusMode
- else:
- print "Error: could not determine media to test"
def checkMediaSize(self, size):
if size < 800000 :
@@ -210,20 +140,14 @@
return FAILED
# show features we found
- print "\n Your CD/DVD device /dev/%s supports %s " % (self.getLogicalDeviceName(), self.showSupportedMedia())
- print " We will check these features. "
- print " You need to prepare following media(disks) for this test: \n"
+ print "Your CD/DVD device /dev/%s supports %s " % (self.getLogicalDeviceName(), self.showSupportedMedia())
-
self.getMediaChoice()
# if auto or self-test mode
if self.getMode() != Constants.normal:
print "Warning: Auto test mode - TESTS NOT RUN"
return 0
-
- # otherwise, normal test mode
- self.prompt("\n Press ENTER when you are ready ! Or press Ctrl-C to quit !")
# test DVD- only
returnValue = True # assume pass
@@ -238,17 +162,9 @@
returnValue = self.testDisk(message="blank DVD+R", readWriteMode="write", type="dvdplus")
elif self.mediaChoice == "dvdplusrw":
returnValue = self.testDisk(message="good DVD+RW", readWriteMode="rewrite", type="dvdplus")
- # test both DVD- and DVD+
- elif self.mediaChoice == "both":
- if self.mediaChoices[0] == "dvdr":
- if not self.testDisk(message="blank DVD-R", readWriteMode="write", type="dvd") or not self.testDisk(message="blank DVD+R", readWriteMode="write", type="dvdplus"):
- print "\n +++ DVD-R test failed.\n"
- return 1 # return non-zero to HTS means failure
- else:
- if not self.testDisk(message="good DVD-RW", readWriteMode="rewrite", type="dvd") or not self.testDisk(message="good DVD+RW", readWriteMode="rewrite", type="dvdplus"):
- print "\n +++ DVD-RW test failed.\n"
- return 1 # return non-zero to HTS means failure
-
+ else:
+ print "Error: unknown media type : %s" % self.mediaChoice
+ return FAILED
if returnValue:
return PASSED