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

Brian Gaeke gaeke at cs.uiuc.edu
Thu Nov 20 18:01:00 PST 2003


Changes in directory llvm/test/QMTest:

llvm.py updated: 1.22 -> 1.23

---
Log message:

Assume that MachineCodeTest will pass if the assembly file is created,
OR if it is NOT created and the error message looks like LLC can't find
the backend.


---
Diffs of the changes:  (+18 -27)

Index: llvm/test/QMTest/llvm.py
diff -u llvm/test/QMTest/llvm.py:1.22 llvm/test/QMTest/llvm.py:1.23
--- llvm/test/QMTest/llvm.py:1.22	Thu Nov 20 13:55:40 2003
+++ llvm/test/QMTest/llvm.py	Thu Nov 20 18:00:15 2003
@@ -366,59 +366,50 @@
 		                    title='LLVM Assembly Code File',
 		                    description='LLVM Assembly Code File to Convert to Native Assembly Code'),
 	]
+        def runLLC(self, llcpath, bcfile, asmfile):
+                command = llcpath + ' ' + bcfile + ' ' + '-f -o ' + asmfile
+                input, output = os.popen4 (command)
+                outputstr = output.read ()
+                input.close ()
+                output.close ()
+                return outputstr.strip ()
 
 	def Run (self, context, result):
-
-		#
 		# Set the core dump size
-		#
 		coresize=int(context['coresize'])
 		resource.setrlimit (resource.RLIMIT_CORE, (coresize,coresize))
 
-		#
 		# Fetch the source and build root directories from the context.
-		#
 		srcroot=context['srcroot']
 		buildroot=context['buildroot']
 		tmpdir=context['tmpdir']
 
-		#
 		# Construct the pathname of the source file and object file.
-		#
 		srcfile=srcroot + '/' + self.srcfile
 		bcfile=tmpdir + '/feature-mc-' + os.path.basename (self.srcfile)
-		objfile=tmpdir + '/feature-mc-' + os.path.basename (self.srcfile) + '.s'
+		asmfile=bcfile + '.s'
 
-		#
 		# Construct the pathnames to the various utilities.
-		#
 		as   = buildroot + '/tools/' + context['buildtype'] + '/llvm-as'
 		llc  = buildroot + '/tools/' + context['buildtype'] + '/llc'
 
-		#
 		# Assemble the bytecode file.
-		#
 		if (ExecProgram ((as, srcfile, '-f', '-o', bcfile))):
 			result.Fail ('Failed to assemble ' + srcfile + ' to file ' + bcfile)
 			return
 
-		#
 		# Use the LLVM assembler to assemble the program.
-		#
-		if (ExecProgram ((llc, bcfile, '-f', '-o', objfile))):
-			fail = 1
-			result.Fail('Failed to compile ' + bcfile + ' to native asm code.')
-		else:
-			fail = 0
-
-		#
-		# Cleanup the file if it exists.
-		#
-		if ((os.access(objfile,os.F_OK)) == 1):
-			os.remove (objfile)
+		llcout = self.runLLC (llc, bcfile, asmfile)
+                
+		# Fail the test if the asm file was not created, and
+		# the error message looks like something other than
+		# "can't find the backend".
+		if os.access (asmfile, os.F_OK) == 1:
+			os.remove (asmfile)
 		else:
-			if (fail == 0):
-				result.Fail ('Native assembly file ' + objfile + ' was not created')
+			pat = re.compile ('must use the -march option')
+			if pat.match (llcout) == None:
+				result.Fail ('Native assembly file ' + asmfile + ' was not created')
 
 		return
 





More information about the llvm-commits mailing list