[llvm-commits] CVS: llvm/test/QMTest/llvmdb.py

John Criswell criswell at cs.uiuc.edu
Fri Oct 3 13:40:13 PDT 2003


Changes in directory llvm/test/QMTest:

llvmdb.py added (r1.1)

---
Log message:

New test database class.
It will read tests straight out of their directories and figure out where
test they are.
Still experimental.



---
Diffs of the changes:

Index: llvm/test/QMTest/llvmdb.py
diff -c /dev/null llvm/test/QMTest/llvmdb.py:1.1
*** /dev/null	Fri Oct  3 13:39:50 2003
--- llvm/test/QMTest/llvmdb.py	Fri Oct  3 13:39:40 2003
***************
*** 0 ****
--- 1,240 ----
+ ##############################################################################
+ #
+ # File: llvmdb.py
+ #
+ # Description:
+ #	This file contains python classes that define a new test database
+ #	for the LLVM test suite.
+ #
+ ##############################################################################
+ 
+ import qm
+ import qm.test
+ import qm.test.test
+ import qm.fields
+ import qm.test.database
+ import qm.test.suite
+ import qm.attachment
+ 
+ import os
+ import stat
+ import filecmp
+ import resource
+ 
+ #
+ # Mapping between test directories and test names
+ #
+ RegressionMap={'Assembler':'llvm.AssembleTest',
+                'Analysis':'llvm.TestRunner',
+                'BugPoint':'llvm.TestRunner',
+                'C++Frontend':'llvm.CXXTest',
+                'CBackend':'llvm.LLToCTest',
+                'CFrontend':'llvm.CTest',	
+                'Jello':'llvm.LLITest',	
+                'LLC':'llvm.MachineCodeTest',	
+                'Linker':'llvm.TestRunner',	
+                'Other':'llvm.TestRunner',	
+                'TableGen':'llvm.TestRunner',	
+                'Transforms':'llvm.TestRunner',	
+                'Reoptimizer':'llvm.TestRunner',	
+                'Verifier':'llvm.VerifierTest'}
+ 
+ class llvmdb (qm.test.database.Database):
+ 
+ 	# Pathname to the test database
+ 	dbpath=''
+ 
+ 	def __init__ (self, path, arguments):
+ 		#
+ 		# Record the location of the test database.
+ 		#
+ 		self.dbpath = path
+ 		qm.test.database.Database.__init__ (self, path, arguments)
+ 		return
+ 
+ 	#
+ 	# Method: GetTest ()
+ 	#
+ 	# Description:
+ 	#	Retrieve a test from the test database.
+ 	#
+ 	def GetTest (self, test_id):
+ 		#
+ 		# Split the test into its name and set of suffixes and
+ 		# convert the test ID into a pathname.
+ 		#
+ 		#(baselabel, suffix1) = self.SplitLabel (test_id)
+ 		#if (suffix1 == 'tr'):
+ 			#(baselabel, suffix2) = self.SplitLabel (baselabel)
+ 			#testpath=self.LabelToPath(baselabel) + '.' + suffix2 + '.' + suffix1
+ 		#else:
+ 			#testpath=self.LabelToPath(baselabel) + '.' + suffix1
+ #
+ 		#testpath = 'test/' + testpath
+ 
+ 
+ 		#
+ 		# Try to figure out whether this test exists or not.
+ 		#
+ 		exts=['ll', 'llx', 'c', 'cpp', 'td', 'c.tr', 'cpp.tr']
+ 
+ 		testpath = self.dbpath + '/' + self.LabelToPath (test_id)
+ 		for ext in exts:
+ 			if (os.path.exists (testpath + '.' + ext)):
+ 				break
+ 		else:
+ 			raise qm.test.database.NoSuchTestError(self)
+ 
+ 		#
+ 		# Construct the pathname of the test relative to the LLVM source tree.
+ 		#
+ 		testpath = 'test/' + self.LabelToPath (test_id) + '.' + ext
+ 
+ 		#
+ 		# If the file ends in .llx or .tr, then it is a TestRunner (as opposed
+ 		# to # HomeStar Runner) test.
+ 		#
+ 		if ((ext == 'llx') or (ext == 'c.tr') or (ext == 'cpp.tr')):
+ 			return qm.test.database.TestDescriptor(self, test_id, 'llvm.TestRunner', {'srcfile':testpath})
+ 
+ 		#
+ 		# Get the first part of the test name.
+ 		#
+ 		(firstsuite,suite) = self.SplitLabelLeft (test_id)
+ 		if (firstsuite == 'Regression'):
+ 			(testtype, suite) = self.SplitLabelLeft (suite)
+ 			testtype = RegressionMap[testtype]
+ 			testargs = {'srcfile':testpath}
+ 
+ 		return qm.test.database.TestDescriptor(self, test_id, testtype, testargs)
+ 
+ 	#
+ 	# Method: GetSuite ()
+ 	#
+ 	# Description:
+ 	#	Retrieve a test suite from the database.
+ 	#
+ 	def GetSuite (self, suite_id):
+ 		#
+ 		# If the empty suite ID is given, default to whatever suite is in
+ 		# the current directory.
+ 		#
+ 		# Otherwise, convert the suite name into a pathname.
+ 		#
+ 		if (suite_id == ''):
+ 			suitepath=self.dbpath
+ 			suite_header = ''
+ 		else:
+ 			suitepath=self.LabelToPath (suite_id)
+ 			suite_header = suite_id + '.'
+ 
+ 		suitepath = self.dbpath + '/' + self.LabelToPath (suite_id)
+ 
+ 		#
+ 		# Get a list of the tests located in this directory.
+ 		#
+ 		tests=os.listdir (suitepath)
+ 		dirs = []
+ 		files = []
+ 		for path in tests:
+ 			fileinfo = os.stat (suitepath + '/' + path)
+ 			if (stat.S_ISDIR(fileinfo.st_mode)):
+ 				if ((path != 'CVS') and (path != 'QMTest') and (path != 'QMTestDB') and (path != 'newdb') and (path != 'Scripts') and (path != 'Programs') and (path != 'Feature') and (path != 'Fragments')):
+ 					dirs = dirs + [suite_header + path]
+ 			else:
+ 				if ((suite_id != '') and (path != 'Makefile') and (path != 'README.txt') and (path != '.cvsignore')):
+ 					(filebase, fileext) = os.path.splitext(path)
+ 					if (fileext == '.tr'):
+ 						(filebase, fileext) = os.path.splitext(filebase)
+ 					files = files + [suite_header + filebase]
+ 
+ 		#
+ 		# Load this suite
+ 		#
+ 		suite = qm.test.suite.Suite (self, suite_id, 0, files, dirs)
+ 		return suite
+ 		#raise qm.test.database.NoSuchSuiteError (suite_id)
+ 
+ 	def GetAttachmentStore (self):
+ 		return qm.attachment.FileAttachmentStore (self)
+ 
+ 	def GetSubdirectories (self, pathname):
+ 		pathname = self.dbpath + '/' + self.LabelToPath (pathname)
+ 
+ 		tests=os.listdir (pathname)
+ 		dirs = []
+ 		for path in tests:
+ 			fileinfo = os.stat (pathname + '/' + path)
+ 			if (stat.S_ISDIR(fileinfo.st_mode)):
+ 				if ((path != 'CVS') and (path != 'QMTest') and (path != 'QMTestDB') and (path != 'newdb') and (path != 'Scripts') and (path != 'Programs') and (path != 'Feature') and (path != 'Fragments')):
+ 					dirs = dirs + [path]
+ 
+ 		return dirs
+ 
+ 	def GetResourceIds(self, directory="", scan_subdirs=1):
+ 		return []
+ 
+ 	def GetSuiteIds(self, directory="", scan_subdirs=1):
+ 		#
+ 		# Adjust the directory name.
+ 		#
+ 		if (directory == ''):
+ 			dirpath = self.dbpath
+ 		else:
+ 			dirpath = self.dbpath + '/' + self.LabelToPath (directory)
+ 
+ 		#
+ 		# Get a list of the tests located in this directory.
+ 		#
+ 		tests=os.listdir (dirpath)
+ 		dirs = [directory]
+ 		files = []
+ 		for path in tests:
+ 			fileinfo = os.stat (dirpath + '/' + path)
+ 			if (stat.S_ISDIR(fileinfo.st_mode)):
+ 				if ((path != 'CVS') and (path != 'QMTest') and (path != 'QMTestDB') and (path != 'newdb') and (path != 'Scripts') and (path != 'Programs') and (path != 'Feature') and (path != 'Fragments')):
+ 					if (directory == ''):
+ 						dirs = dirs + [path]
+ 					else:
+ 						dirs = dirs + [directory + '.' + path]
+ 
+ 		if (scan_subdirs == 1):
+ 			for dirlabel in dirs:
+ 				dirs = dirs + self.GetTestIds (dirlabel, 1)
+ 		return dirs
+ 
+ 	def GetTestIds(self, directory="", scan_subdirs=1):
+ 		#
+ 		# Adjust the directory name.
+ 		#
+ 		if (directory == ''):
+ 			dirpath = self.dbpath
+ 		else:
+ 			dirpath = self.dbpath + '/' + self.LabelToPath (directory)
+ 
+ 		#
+ 		# Get a list of the tests located in this directory.
+ 		#
+ 		tests=os.listdir (dirpath)
+ 		dirs = [directory]
+ 		files = []
+ 		for path in tests:
+ 			fileinfo = os.stat (dirpath + '/' + path)
+ 			if (stat.S_ISDIR(fileinfo.st_mode)):
+ 				if ((path != 'CVS') and (path != 'QMTest') and (path != 'QMTestDB') and (path != 'newdb') and (path != 'Scripts') and (path != 'Programs') and (path != 'Feature') and (path != 'Fragments')):
+ 					if (directory == ''):
+ 						dirs = dirs + [path]
+ 					else:
+ 						dirs = dirs + [directory + '.' + path]
+ 			else:
+ 				if ((directory != '') and (path != 'Makefile')):
+ 					if (directory == ''):
+ 						files = files + [path]
+ 					else:
+ 						files = files + [directory + '.' + path]
+ 
+ 		if (scan_subdirs == 1):
+ 			for dirlabel in dirs:
+ 				files = files + self.GetTestIds (dirlabel, 1)
+ 		return files
+ 





More information about the llvm-commits mailing list