sbsv2/raptor/test/unit_suite/raptor_meta_unit.py
branchwip
changeset 135 0092642f198e
parent 32 fdfc59a2ae7e
child 458 79718b9711e8
equal deleted inserted replaced
134:2648751b64b4 135:0092642f198e
   254 		self.__testBldInfTestCode(bldInfTestRoot, 'test_mmps.inf',
   254 		self.__testBldInfTestCode(bldInfTestRoot, 'test_mmps.inf',
   255 				[bldInfObject.testManual, bldInfObject.testAuto], [1, 1])
   255 				[bldInfObject.testManual, bldInfObject.testAuto], [1, 1])
   256 	
   256 	
   257 	def __testExport(self, aExportObject, aSource, aDestination, aAction):			
   257 	def __testExport(self, aExportObject, aSource, aDestination, aAction):			
   258 		self.assertEquals(aExportObject.getSource(), aSource)
   258 		self.assertEquals(aExportObject.getSource(), aSource)
   259 		self.assertEqualsOrContains(aExportObject.getDestination(), aDestination)
   259 		self.assertEqualsOrContainsPath(aExportObject.getDestination(), aDestination)
   260 		self.assertEquals(aExportObject.getAction(), aAction)
   260 		self.assertEquals(aExportObject.getAction(), aAction)
   261 	
   261 	
   262 	def assertEqualsOrContains(self, aPathStringOrPathStringList, aPathString):
   262 	def assertEqualsOrContainsPath(self, aRequirement, aCandidate):
   263 		# If aPathStringOrPathStringList is a list, which it might well be, we should
   263 		# If aRequirement is a list, which it might well be, we should
   264 		# assert that aPathString is contained in it
   264 		# assert that aPathString is contained in it
   265 		# If aPathStringOrPathStringList is not a list, it will be a string, and 
   265 		# If aRequirement not a list, it will be a string, and 
   266 		# we should assert equality of the strings
   266 		# we should assert equality of the strings
   267 		if isinstance(aPathStringOrPathStringList, list):
   267 		# On windows we shouldn't care about the case of the drive letter.
   268 			self.assert_(aPathString in aPathStringOrPathStringList)
   268 
       
   269 		if isinstance(aRequirement, list):
       
   270 			pathsequal = False
       
   271 			for r in aRequirement:
       
   272 				pathsequal = path_compare_notdrivelettercase(r,aCandidate) or pathsequal
       
   273 			self.assertTrue(pathsequal)
   269 		else:
   274 		else:
   270 			self.assertEquals(aPathStringOrPathStringList, aPathString)
   275 			self.assertTrue(path_compare_notdrivelettercase(aRequirement,aCandidate))
   271 		
   276 		
   272 	def testBldInfExports(self):
   277 	def testBldInfExports(self):
   273 		bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs')
   278 		bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs')
   274 		bldInfMakefilePathTestRoot = str(self.__makefilePathTestRoot) + '/metadata/project/'
   279 		bldInfMakefilePathTestRoot = str(self.__makefilePathTestRoot) + '/metadata/project/'
   275 		
   280 		
   644 			def test(self, raptor):
   649 			def test(self, raptor):
   645 				m = raptor_meta.MMPRaptorBackend(raptor, self.mmpfilename, "")
   650 				m = raptor_meta.MMPRaptorBackend(raptor, self.mmpfilename, "")
   646 				m.deffile = self.deffilekeyword
   651 				m.deffile = self.deffilekeyword
   647 				m.nostrictdef = self.nostrictdef
   652 				m.nostrictdef = self.nostrictdef
   648 				f = m.resolveDefFile(self.target, self.platform)
   653 				f = m.resolveDefFile(self.target, self.platform)
   649 				del m
   654 				
   650 				if self.resolveddeffile == f:
   655 				return path_compare_notdrivelettercase(self.resolveddeffile,f)
   651 					return True
       
   652 				return False
       
   653 		
   656 		
   654 		defFileTests = []
   657 		defFileTests = []
   655 		
   658 		
   656 		for testPlat in self.testPlats:			
   659 		for testPlat in self.testPlats:			
   657 			epocroot = str(testPlat['EPOCROOT'])
   660 			epocroot = str(testPlat['EPOCROOT'])
   732 					False,
   735 					False,
   733 					testPlat)
   736 					testPlat)
   734 				])
   737 				])
   735 		
   738 		
   736 		for t in defFileTests:
   739 		for t in defFileTests:
   737 			self.assertEquals(t.test(self.raptor), True)
   740 			result = t.test(self.raptor)
       
   741 			self.assertEquals(result, True)
   738 	
   742 	
   739 	def dummyMetaReader(self):
   743 	def dummyMetaReader(self):
   740 		"make raptor_meta.MetaReader.__init__ into a none operation"
   744 		"make raptor_meta.MetaReader.__init__ into a none operation"
   741 		self.savedInit = raptor_meta.MetaReader.__init__
   745 		self.savedInit = raptor_meta.MetaReader.__init__
   742 
   746 
   839 		for result in resultsDictList:
   843 		for result in resultsDictList:
   840 			moduleName = mockBackend.ModuleName(result["bldinf"])
   844 			moduleName = mockBackend.ModuleName(result["bldinf"])
   841 			self.assertEquals(moduleName, result["result"])
   845 			self.assertEquals(moduleName, result["result"])
   842 
   846 
   843 		self.restoreMetaReader()
   847 		self.restoreMetaReader()
       
   848 
       
   849 
       
   850 def path_compare_notdrivelettercase(aRequirement, aCandidate):
       
   851 	if sys.platform.startswith("win"):
       
   852 		if aRequirement[1] == ":":
       
   853 			aRequirement = aRequirement[0].lower() + aRequirement[1:]
       
   854 			aCandidate = aCandidate[0].lower() + aCandidate[1:]
       
   855 
       
   856 	return aRequirement == aCandidate
       
   857 
   844 		
   858 		
   845 # run all the tests
   859 # run all the tests
   846 
   860 
   847 from raptor_tests import SmokeTest
   861 from raptor_tests import SmokeTest
   848 
   862