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

John Criswell criswell at cs.uiuc.edu
Tue Oct 7 14:13:01 PDT 2003


Changes in directory llvm/test/QMTest:

llvm.py updated: 1.13 -> 1.14

---
Log message:

Adjusted tests so that they compile the LLVM assembly code into bytecode,
if necessary.
Modified some tests so that they use ExecProgram().  Hopefully this will
flag failures when programs terminate abnormally.
All of the tests now take a pathname relative to llvm.



---
Diffs of the changes:  (+42 -32)

Index: llvm/test/QMTest/llvm.py
diff -u llvm/test/QMTest/llvm.py:1.13 llvm/test/QMTest/llvm.py:1.14
--- llvm/test/QMTest/llvm.py:1.13	Fri Oct  3 14:21:02 2003
+++ llvm/test/QMTest/llvm.py	Tue Oct  7 14:12:32 2003
@@ -133,11 +133,9 @@
 		#
 		# Use the LLVM assembler to assemble the program.
 		#
-		cmd = as + ' ' + srcfile + ' -d -f -o ' + bcpath + self.devnull
-		estatus=os.system (cmd)
-		if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
+		if (ExecProgram ((as, srcfile, '-d', '-f', '-o', bcpath))):
 			fail = 1
-			result.Fail()
+			result.Fail('Failed to assemble ' + srcfile)
 
 		#
 		# Cleanup the bytecode file.
@@ -193,22 +191,29 @@
 		#
 		# Construct the pathname of the source file and object file.
 		#
-		srcfile=tmpdir + '/' + self.srcfile
-		objfile=tmpdir + '/' + self.srcfile + '.tc'
+		srcfile=srcroot + '/' + self.srcfile
+		bcfile=tmpdir + '/' + os.path.basename (self.srcfile)
+		objfile=tmpdir + '/' + os.path.basename (self.srcfile) + '.tc'
 
 		#
 		# Construct the pathnames to the various utilities.
 		#
+		as  = buildroot + '/tools/' + context['buildtype'] + '/llvm-as'
 		dis = buildroot + '/tools/' + context['buildtype'] + '/llvm-dis'
 
 		#
 		# Use the LLVM assembler to assemble the program.
 		#
-		cmd = dis + ' ' + srcfile + ' -c -o ' + objfile + self.devnull
-		estatus=os.system (cmd)
-		if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
+		if (ExecProgram ((as, srcfile, '-f', '-o', bcfile))):
+			result.Fail ('Failed to assemble ' + srcfile)
+			return
+
+		#
+		# Use the LLVM disassembler to convert the program to C code.
+		#
+		if (ExecProgram ((dis, bcfile, '-f', '-c', '-o', objfile))):
 			fail = 1
-			result.Fail()
+			result.Fail ('Failed to convert ' + bcfile + ' to C code.')
 		else:
 			fail = 0
 
@@ -417,8 +422,8 @@
 	#
 	arguments = [
 		qm.fields.TextField(name='srcfile',
-		                    title='LLVM Bytecode File',
-		                    description='LLVM Bytecode File to Convert to Machine Code'),
+		                    title='LLVM Assembly Code File',
+		                    description='LLVM Assembly Code File to Convert to Machine Code'),
 	]
 
 	devnull = ' > /dev/null 2>&1'
@@ -441,20 +446,29 @@
 		#
 		# Construct the pathname of the source file and object file.
 		#
-		srcfile=tmpdir + '/' + self.srcfile
-		objfile=tmpdir + '/' + self.srcfile + '.s'
+		srcfile=srcroot + '/' + self.srcfile
+		bcfile=tmpdir + '/feature-' + os.path.basename (self.srcfile)
+		objfile=tmpdir + '/feature-' + self.srcfile + '.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.
 		#
-		exstatus=os.spawnl (os.P_WAIT, llc, llc, srcfile, '-f', '-o=' + objfile)
+		exstatus=os.spawnl (os.P_WAIT, llc, llc, bcfile, '-f', '-o=' + objfile)
 		if (exstatus != 0):
-			result.Fail()
+			result.Fail('Failed to compile ' + bcfile + ' to native asm code.')
 
 		#
 		# Cleanup the file if it exists.
@@ -491,6 +505,11 @@
 	opt='opt'
 
 	#
+	# LLVM Directories
+	#
+	tmpdir=''
+
+	#
 	# Method: Run
 	#
 	# Description:
@@ -508,6 +527,7 @@
 		#
 		srcroot=context['srcroot']
 		buildroot=context['buildroot']
+		self.tmpdir = context['tmpdir']
 
 		#
 		# Construct the pathname of the source file.
@@ -561,14 +581,7 @@
 		#
 		p=' | '
 
-		#
-		# Assemble and optimize the given program.  Then, disassemble
-		# it and reassemble it again.
-		#
-		# This should provide a bytecode file that cannot be optimized
-		# any further.
-		#
-		estatus = os.system (as + ' < ' + file + p + opt + ' -q -inline -dce ' + flags + p + dis + p + as + ' > bc.1')
+		estatus = os.system (as + ' < ' + file + p + opt + ' -q -inline -dce ' + flags + p + dis + p + as + ' > ' + 'bc.1')
 		if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
 			result.Fail()
 			return;
@@ -576,7 +589,7 @@
 		#
 		# Now, attempt to optimize the the program again.
 		#
-		estatus=os.system (opt + ' -q ' + flags + ' < bc.1 > bc.2')
+		estatus=os.system (opt + ' -q ' + flags + ' < ' + 'bc.1 > ' + 'bc.2')
 		if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
 			result.Fail()
 			return
@@ -584,6 +597,9 @@
 		#
 		# If the two programs are identical, then we have failed!
 		#
+		# This should provide a bytecode file that cannot be optimized
+		# any further.
+		#
 		status1 = os.spawnl (os.P_WAIT, dis, dis, 'bc.1', '-f', '-o=ll.1');
 		status2 = os.spawnl (os.P_WAIT, dis, dis, 'bc.2', '-f', '-o=ll.2');
 		if ((status1 != 0) or (status2 != 0)):
@@ -613,11 +629,6 @@
 #	disassemble a given LLVM assembly file to ensure that the assembler
 #	and disassembler work properly.
 #
-# Note:
-#	This class is restricted to running programs in llvm/test/Feature.
-#	Eventually it will be modified to run them from anywhere within the
-#	LLVM source tree.
-#
 ##############################################################################
 class TestAsmDisasm(qm.test.test.Test):
 
@@ -649,7 +660,6 @@
 		#
 		srcroot=context['srcroot']
 		buildroot=context['buildroot']
-		testdir=srcroot + '/test/Feature'
 
 		#
 		# Determine the path to the assembler and disassembler
@@ -660,7 +670,7 @@
 		#
 		# Find the name of the file to assemble.
 		#
-		input=testdir + '/' + self.srcfile
+		input=srcroot + '/' + self.srcfile
 
 		#
 		# Construct output filenames.





More information about the llvm-commits mailing list