sbsv2/raptor/test/common/raptor_tests.py
changeset 18 de5b887c98f7
parent 13 c327db0664bb
child 28 b8fa7dfeeaa1
equal deleted inserted replaced
14:eb060913c963 18:de5b887c98f7
     1 #
     1 #
     2 # Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 # Copyright (c) 2009-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".
   601 		self.regexlinefilter = None
   601 		self.regexlinefilter = None
   602 		
   602 		
   603 		# paths in --what output are tailored to the host OS, hence slashes are converted appropriately
   603 		# paths in --what output are tailored to the host OS, hence slashes are converted appropriately
   604 		# .whatlog output is used verbatim from the build/TEM/EM output
   604 		# .whatlog output is used verbatim from the build/TEM/EM output
   605 		self.hostossensitive = True
   605 		self.hostossensitive = True
       
   606 		
       
   607 		# Indicate whether output is expected to appear only once. If so, set it to True
       
   608 		self.output_expected_only_once = False 
   606 	
   609 	
   607 	def posttest(self):
   610 	def posttest(self):
   608 		outlines = self.output.splitlines()
   611 		outlines = self.output.splitlines()
       
   612 		if self.output_expected_only_once:
       
   613 			outlines_left = list(outlines) 
   609 		
   614 		
   610 		ok = True
   615 		ok = True
   611 		seen = []
   616 		seen = []
   612 		
   617 		
   613 		# check for lines that we expected to see, optionally filtered
   618 		# check for lines that we expected to see, optionally filtered
   618 			if self.hostossensitive and self.onWindows:
   623 			if self.hostossensitive and self.onWindows:
   619 					line = line.replace("/", "\\")
   624 					line = line.replace("/", "\\")
   620 				
   625 				
   621 			if line in outlines:
   626 			if line in outlines:
   622 				seen.append(line)
   627 				seen.append(line)
       
   628 				if self.output_expected_only_once:
       
   629 					outlines_left.remove(line) 
   623 			else:
   630 			else:
   624 				print "OUTPUT NOT FOUND:", line
   631 				print "OUTPUT NOT FOUND:", line
   625 				ok = False
   632 				ok = False
   626 		
   633 		
   627 		# and check for extra lines that we didn't expect, optionally filtered
   634 		# and check for extra lines that we didn't expect, optionally filtered
   629 			if self.regexlinefilter and not self.regexlinefilter.match(line):
   636 			if self.regexlinefilter and not self.regexlinefilter.match(line):
   630 				continue
   637 				continue
   631 			if not line in seen:
   638 			if not line in seen:
   632 				print "UNEXPECTED OUTPUT:", line
   639 				print "UNEXPECTED OUTPUT:", line
   633 				ok = False
   640 				ok = False
       
   641 		
       
   642 		# and check for lines that we expected to see only once
       
   643 		if self.output_expected_only_once:
       
   644 			for line in outlines_left:
       
   645 				print "OUTPUT MORE THAN ONCE:", line
       
   646 				ok = False
       
   647 
   634 			
   648 			
   635 		# do the base class things too
   649 		# do the base class things too
   636 		return (SmokeTest.posttest(self) and ok)	
   650 		return (SmokeTest.posttest(self) and ok)	
   637 
   651 
   638 # derived class for tests that also need to make sure that certain files
   652 # derived class for tests that also need to make sure that certain files