sbsv2/raptor/test/unit_suite/raptor_meta_unit.py
changeset 18 de5b887c98f7
parent 13 c327db0664bb
child 28 b8fa7dfeeaa1
equal deleted inserted replaced
14:eb060913c963 18:de5b887c98f7
     1 #
     1 #
     2 # Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 # Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 # All rights reserved.
     3 # All rights reserved.
     4 # This component and the accompanying materials are made available
     4 # This component and the accompanying materials are made available
     5 # under the terms of the License "Eclipse Public License v1.0"
     5 # under the terms of the License "Eclipse Public License v1.0"
     6 # which accompanies this distribution, and is available
     6 # which accompanies this distribution, and is available
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
   492 				self.assertEquals(testVariables.get(stdvar), aTestParameters.get(testParameter))
   492 				self.assertEquals(testVariables.get(stdvar), aTestParameters.get(testParameter))
   493 			else:
   493 			else:
   494 				self.assertTrue(testOptions.has_key(testParameter))
   494 				self.assertTrue(testOptions.has_key(testParameter))
   495 				self.assertEquals(testOptions.get(testParameter), aTestParameters.get(testParameter))
   495 				self.assertEquals(testOptions.get(testParameter), aTestParameters.get(testParameter))
   496 
   496 
       
   497 
   497 	def testBldInfExtensions(self):
   498 	def testBldInfExtensions(self):
   498 		bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs')
   499 		bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs')
   499 		bldInfMakefilePathTestRoot = str(self.__makefilePathTestRoot)+'/metadata/project/bld.infs'			
   500 		bldInfMakefilePathTestRoot = str(self.__makefilePathTestRoot)+'/metadata/project/bld.infs'			
       
   501 		if 'SRCROOT' in os.environ:
       
   502 			srcroot = os.environ['SRCROOT']
       
   503 		else:
       
   504 			srcroot = os.environ['SRCROOT'] = "x:/somesrcroot"
       
   505 		
   500 		depfiles = []
   506 		depfiles = []
   501 		bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('extensions.inf'),
   507 		bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('extensions.inf'),
   502 											  self.__gnucpp, depfiles=depfiles, log=self.raptor)
   508 											  self.__gnucpp, depfiles=depfiles, log=self.raptor)
   503 		
   509 		
   504 		extensions = bldInfObject.getExtensions(self.ARMV5)
   510 		extensions = bldInfObject.getExtensions(self.ARMV5)
   505 		
   511 				
   506 		self.__testExtension(extensions[0],
   512 		self.__testExtension(extensions[0],
   507 							'test/dummyextension1.mk',
   513 							'test/dummyextension1.mk',
   508 							{'TARGET':'dummyoutput1.exe',
   514 							{'TARGET':'dummyoutput1.exe',
   509 							'SOURCES':'dummysource11.cpp dummysource12.cpp dummysource13.cpp',
   515 							'SOURCES':'dummysource11.cpp dummysource12.cpp dummysource13.cpp',
   510 							'DEPENDENCIES':'dummylib11.lib dummylib12.lib',
   516 							'DEPENDENCIES':'dummylib11.lib dummylib12.lib',
   511 							'TOOL':'dummytool1.exe',
   517 							'TOOL':'dummytool1.exe',
   512 							'OPTION11':'option11value',
   518 							'OPTION11':'option11value',
   513 							'OPTION12':'$(MAKE_VAR)',
   519 							'OPTION12':'$(MAKE_VAR)',
   514 							'STDVAR_TO_ROOT':"",
   520 							'STDVAR_TO_ROOT':srcroot,
   515 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   521 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   516 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}		
   522 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}		
   517 							)
   523 							)
   518 		
   524 		
   519 		self.__testExtension(extensions[1],
   525 		self.__testExtension(extensions[1],
   522 							'SOURCES':'dummysource21.cpp dummysource22.cpp dummysource23.cpp',
   528 							'SOURCES':'dummysource21.cpp dummysource22.cpp dummysource23.cpp',
   523 							'DEPENDENCIES':'dummylib21.lib dummylib22.lib',
   529 							'DEPENDENCIES':'dummylib21.lib dummylib22.lib',
   524 							'TOOL':'dummytool2.exe',
   530 							'TOOL':'dummytool2.exe',
   525 							'OPTION21':'option21value',
   531 							'OPTION21':'option21value',
   526 							'OPTION22':'$(MAKE_VAR)',
   532 							'OPTION22':'$(MAKE_VAR)',
   527 							'STDVAR_TO_ROOT':"",
   533 							'STDVAR_TO_ROOT':srcroot,
   528 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   534 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   529 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}
   535 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}
   530 							)
   536 							)
   531 		
   537 		
   532 		self.__testExtension(extensions[2],
   538 		self.__testExtension(extensions[2],
   535 							'SOURCES':'dummysource31.cpp dummysource32.cpp dummysource33.cpp',
   541 							'SOURCES':'dummysource31.cpp dummysource32.cpp dummysource33.cpp',
   536 							'DEPENDENCIES':'dummylib31.lib dummylib32.lib',
   542 							'DEPENDENCIES':'dummylib31.lib dummylib32.lib',
   537 							'TOOL':'dummytool3.exe',
   543 							'TOOL':'dummytool3.exe',
   538 							'OPTION31':'option31value',
   544 							'OPTION31':'option31value',
   539 							'OPTION32':'$(MAKE_VAR)',
   545 							'OPTION32':'$(MAKE_VAR)',
   540 							'STDVAR_TO_ROOT':"",
   546 							'STDVAR_TO_ROOT':srcroot,
   541 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   547 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   542 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}
   548 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}
   543 							)
   549 							)
   544 		
   550 		
   545 		testExtensions = bldInfObject.getTestExtensions(self.ARMV5)
   551 		testExtensions = bldInfObject.getTestExtensions(self.ARMV5)
   550 							'SOURCES':'dummytestsource11.cpp dummytestsource12.cpp dummytestsource13.cpp',
   556 							'SOURCES':'dummytestsource11.cpp dummytestsource12.cpp dummytestsource13.cpp',
   551 							'DEPENDENCIES':'dummytestlib11.lib dummytestlib12.lib',
   557 							'DEPENDENCIES':'dummytestlib11.lib dummytestlib12.lib',
   552 							'TOOL':'dummytesttool1.exe',
   558 							'TOOL':'dummytesttool1.exe',
   553 							'OPTIONTEST11':'optiontest11value',
   559 							'OPTIONTEST11':'optiontest11value',
   554 							'OPTIONTEST12':'$(MAKE_VAR)',
   560 							'OPTIONTEST12':'$(MAKE_VAR)',
   555 							'STDVAR_TO_ROOT':"",
   561 							'STDVAR_TO_ROOT':srcroot,
   556 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   562 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   557 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}		
   563 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}		
   558 							)
   564 							)
   559 
   565 
   560 		self.__testExtension(testExtensions[1],
   566 		self.__testExtension(testExtensions[1],
   563 							'SOURCES':'dummytestsource21.cpp dummytestsource22.cpp dummytestsource23.cpp',
   569 							'SOURCES':'dummytestsource21.cpp dummytestsource22.cpp dummytestsource23.cpp',
   564 							'DEPENDENCIES':'dummytestlib21.lib dummytestlib22.lib',
   570 							'DEPENDENCIES':'dummytestlib21.lib dummytestlib22.lib',
   565 							'TOOL':'dummytesttool2.exe',
   571 							'TOOL':'dummytesttool2.exe',
   566 							'OPTIONTEST21':'optiontest21value',
   572 							'OPTIONTEST21':'optiontest21value',
   567 							'OPTIONTEST22':'$(MAKE_VAR)',
   573 							'OPTIONTEST22':'$(MAKE_VAR)',
   568 							'STDVAR_TO_ROOT':"",
   574 							'STDVAR_TO_ROOT':srcroot,
   569 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   575 							'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot,
   570 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}		
   576 							'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot}		
   571 							)
   577 							)
   572 		
   578 	
       
   579 	def testBadBldInfs(self):
       
   580 		bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs')
       
   581 		depfiles=[]
       
   582 		
       
   583 		class BadBldInfLogger(object):
       
   584 			"mock logger to capture Error messages from the parser."
       
   585 			
       
   586 			def __init__(self):
       
   587 				self.errors = []
       
   588 				self.debugOutput = False
       
   589 				
       
   590 			def Error(self, format, *extras, **attributes):
       
   591 				self.errors.append( ((format % extras), attributes) )
       
   592 		
       
   593 			def Debug(self, format, *extras, **attributes):
       
   594 				pass
       
   595 				
       
   596 		logger = BadBldInfLogger()
       
   597 		
       
   598 		# this bld.inf has END lines with no matching START
       
   599 		bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('bad_lone_end.inf'),
       
   600 											  self.__gnucpp, depfiles=depfiles, 
       
   601 											  log=logger)
       
   602 		
       
   603 		# the PRJ_EXTENSIONS section is bad for ARMV5
       
   604 		extensions = bldInfObject.getExtensions(self.ARMV5)
       
   605 		#
       
   606 		self.assertEquals(len(logger.errors), 1)
       
   607 		err = logger.errors[0]
       
   608 		self.assertEquals(err[0], "unmatched END statement in PRJ_EXTENSIONS section")
       
   609 		self.assertTrue("bldinf" in err[1])
       
   610 		self.assertTrue(err[1]["bldinf"].endswith("bad_lone_end.inf"))
       
   611 		
       
   612 		# the PRJ_TESTEXTENSIONS section is bad for WINSCW
       
   613 		testextensions = bldInfObject.getTestExtensions(self.WINSCW)
       
   614 		#
       
   615 		self.assertEquals(len(logger.errors), 2)
       
   616 		err = logger.errors[1]
       
   617 		self.assertEquals(err[0], "unmatched END statement in PRJ_TESTEXTENSIONS section")
       
   618 		self.assertTrue("bldinf" in err[1])
       
   619 		self.assertTrue(err[1]["bldinf"].endswith("bad_lone_end.inf"))
       
   620 			
   573 	def testBldInfIncludes(self):
   621 	def testBldInfIncludes(self):
   574 		bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs/includes')
   622 		bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs/includes')
   575 		depfiles=[]
   623 		depfiles=[]
   576 		bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('top_level.inf'),
   624 		bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('top_level.inf'),
   577 											  self.__gnucpp, depfiles=depfiles, log=self.raptor)
   625 											  self.__gnucpp, depfiles=depfiles, log=self.raptor)