[llvm-commits] CVS: llvm/test/QMTestDB/QMTest/llvm.py
John Criswell
criswell at cs.uiuc.edu
Sat Sep 6 10:16:49 PDT 2003
Changes in directory llvm/test/QMTestDB/QMTest:
llvm.py updated: 1.3 -> 1.4
---
Log message:
Checkin of autoconf-style object root.
Added new resource and test classes for future tests.
Cleaned up the LLI tests (I think).
---
Diffs of the changes:
Index: llvm/test/QMTestDB/QMTest/llvm.py
diff -u llvm/test/QMTestDB/QMTest/llvm.py:1.3 llvm/test/QMTestDB/QMTest/llvm.py:1.4
--- llvm/test/QMTestDB/QMTest/llvm.py:1.3 Fri Aug 22 11:24:25 2003
+++ llvm/test/QMTestDB/QMTest/llvm.py Sat Sep 6 10:14:12 2003
@@ -677,10 +677,9 @@
tmpdir=context['tmpdir']
#
- # Construct the pathname of the source file and object file.
+ # Construct the pathname of the source file.
#
srcfile=srcroot + '/' + self.assembly_file
- bcpath=tmpdir + '/' + 'temp.bc'
#
# Construct the pathnames to the various utilities.
@@ -698,12 +697,6 @@
else:
result.Fail ('Assembler Terminated Abnormally')
- #
- # Cleanup the bytecode file.
- #
- if ((os.access(bcpath,os.F_OK)) == 1):
- os.remove (bcpath)
-
return
@@ -753,12 +746,12 @@
#
# Construct the pathnames to the various utilities.
#
- lli = buildroot + '/tools/Debug/lli'
+ lli = buildroot + '/tools/Debug/lli -force-interpreter=false '
#
# Execute the program.
#
- estatus=os.system (lli + ' ' + srcfile + ' > /dev/null 2>&1')
+ estatus=os.system (lli + ' ' + srcfile + ' < /dev/null')
if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
result.Fail('LLI failed to execute bytecode')
@@ -934,6 +927,98 @@
##############################################################################
#
+# Class: CTest
+#
+# Description:
+# This test verifies that the specified C program can be compiled
+# into LLVM assembly code which can then be assembled into LLVM byte
+# code.
+#
+##############################################################################
+class CTest(qm.test.test.Test):
+
+ description="Verifies that LLVM can compile C code into LLVM bytecode"
+
+ #
+ # List of arguments that the objects accepts for test configuration.
+ #
+ arguments = [
+ qm.fields.TextField(name='srcfile',
+ title='C Source Code File',
+ description='C Source Code File to Convert to LLVM Bytecode'),
+ ]
+
+
+ #devnull = ' > /dev/null 2>&1'
+ devnull = ''
+
+ def Run (self, context, result):
+
+ #
+ # Set the core dump size
+ #
+ resource.setrlimit (resource.RLIMIT_CORE, (context['coresize'],-1))
+
+ #
+ # 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
+ llvmsrc=tmpdir + '/' + os.path.basename (self.srcfile) + '.ll'
+ llvmobj=tmpdir + '/' + os.path.basename (self.srcfile) + '.bc'
+
+ #
+ # Construct the pathnames to the various utilities.
+ #
+ cc = context['llvmgcc']
+ as = buildroot + '/tools/' + context['buildtype'] + '/as'
+
+ #
+ # Construct the command to generate the LLVM assembly and byte
+ # code.
+ #
+ ccmd = cc + ' -S ' + srcfile + ' -o ' + llvmsrc + self.devnull
+ acmd = as + ' -f ' + llvmsrc + ' -o /dev/null 2>&1 /dev/null'
+
+ #
+ # Assemble the program into C code and then compile it.
+ #
+ estatus=os.system (ccmd)
+ if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
+ fail = 1
+ result.Fail('Compiling C code failed')
+ else:
+ estatus=os.system (acmd)
+ if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
+ fail = 1
+ result.Fail('Compiling code failed')
+ else:
+ fail = 0
+
+ #
+ # Cleanup the files.
+ #
+ if ((os.access(llvmsrc,os.F_OK)) == 1):
+ os.remove (llvmsrc)
+ else:
+ if (fail == 0):
+ result.Fail ('Object file not generated')
+
+ return
+
+
+##############################################################################
+# RESOURCES
+##############################################################################
+
+##############################################################################
+#
# Class: MakeResource
#
# Description:
@@ -1014,112 +1099,101 @@
def CleanUp(self, result):
return
+
##############################################################################
#
-# Class: CTest
+# Class: BytecodeResource
#
# Description:
-# This test verifies that the specified C program can be compiled
-# into LLVM assembly code which can then be assembled into LLVM byte
-# code.
+# This resource takes the specified source file and builds a bytecode
+# file from it.
#
##############################################################################
-class CTest(qm.test.test.Test):
-
- description="Verifies that LLVM can compile C code into LLVM bytecode"
- #
- # List of arguments that the objects accepts for test configuration.
- #
+class BytecodeResource(qm.test.resource.Resource):
arguments = [
qm.fields.TextField(name='srcfile',
- title='C Source Code File',
- description='C Source Code File to Convert to LLVM Bytecode'),
+ title='Source File',
+ description='Name of the file to assemble into bytecode.'),
+ qm.fields.TextField(name='bcfilename',
+ title='Bytecode Filename',
+ description='Name of the bytecode file to be generated.'),
]
+ srcroot=''
+ buildroot=''
+ tmpdir=''
- #devnull = ' > /dev/null 2>&1'
- devnull = ''
-
- def Run (self, context, result):
-
+ #
+ # Method: SetUp()
+ #
+ # Description:
+ # This method creates an instance of this resource.
+ # Specifically, it will create the necessary bytecode file from
+ # the specified source file.
+ #
+ def SetUp(self, context, result):
#
# Set the core dump size
#
resource.setrlimit (resource.RLIMIT_CORE, (context['coresize'],-1))
#
- # 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
- llvmsrc=tmpdir + '/' + os.path.basename (self.srcfile) + '.ll'
- llvmobj=tmpdir + '/' + os.path.basename (self.srcfile) + '.bc'
-
- #
- # Construct the pathnames to the various utilities.
+ # Determine the pathnames to the source code and object code.
#
- cc = context['llvmgcc']
- as = buildroot + '/tools/' + context['buildtype'] + '/as'
+ self.srcroot = context['srcroot']
+ self.buildroot = context['buildroot']
+ self.tmpdir = context['tmpdir']
#
- # Construct the command to generate the LLVM assembly and byte
- # code.
+ # Now create the source file pathname.
#
- ccmd = cc + ' -S ' + srcfile + ' -o ' + llvmsrc + self.devnull
- acmd = as + ' -f ' + llvmsrc + ' -o /dev/null 2>&1 /dev/null'
+ srcpath = self.srcroot + '/' + self.srcfile
+ bcpath = self.tmpdir + '/' + self.bcfilename
#
- # Assemble the program into C code and then compile it.
+ # Find the pathname of the assembler.
#
- estatus=os.system (ccmd)
- if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
- fail = 1
- result.Fail('Compiling C code failed')
- else:
- estatus=os.system (acmd)
- if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
- fail = 1
- result.Fail('Compiling code failed')
- else:
- fail = 0
+ as = self.buildroot + '/tools/Debug/as'
#
- # Cleanup the files.
+ # Use the LLVM assembler to create the bytecode file.
#
- if ((os.access(llvmsrc,os.F_OK)) == 1):
- os.remove (llvmsrc)
- else:
- if (fail == 0):
- result.Fail ('Object file not generated')
+ exstatus=os.spawnl (os.P_WAIT, as, as, srcpath, '-o=' + bcpath)
+ if (exstatus != 0):
+ result.Fail('Failed to assemble ' + srcpath)
+ return
+ return
+ #
+ # Method: CleanUp()
+ #
+ # Description:
+ # This method removes the resource once it is no longer needed.
+ #
+ def CleanUp(self, result):
+ os.remove (self.tmpdir + '/' + self.bcfilename)
return
##############################################################################
#
-# Class: BytecodeResource
+# Class: NativecodeResource
#
# Description:
-# This resource takes the specified source file and builds a bytecode
-# file from it.
+# This resource takes the specified source file and compiles it into
+# a native program using the standard C or C++ compiler.
#
##############################################################################
-class BytecodeResource(qm.test.resource.Resource):
+class NativecodeResource(qm.test.resource.Resource):
arguments = [
qm.fields.TextField(name='srcfile',
title='Source File',
description='Name of the file to assemble into bytecode.'),
- qm.fields.TextField(name='bcfilename',
- title='Bytecode Filename',
- description='Name of the bytecode file to be generated.'),
+ qm.fields.TextField(name='libs',
+ title='Libraries',
+ description='Libraries to link into the program.'),
]
srcroot=''
@@ -1131,14 +1205,10 @@
#
# Description:
# This method creates an instance of this resource.
- # Specifically, it will create the necessary bytecode file from
- # the specified source file.
+ # Specifically, it will create the compile the program and link
+ # it with the specified libraries.
#
def SetUp(self, context, result):
- #
- # Set the core dump size
- #
- resource.setrlimit (resource.RLIMIT_CORE, (context['coresize'],-1))
#
# Determine the pathnames to the source code and object code.
@@ -1148,15 +1218,25 @@
self.tmpdir = context['tmpdir']
#
+ # Split the pathname into it's basename and suffix.
+ #
+ (base, suffix) = os.path.splitext (self.srcfile)
+
+ #
# Now create the source file pathname.
#
srcpath = self.srcroot + '/' + self.srcfile
- bcpath = self.tmpdir + '/' + self.bcfilename
+ objpath = self.tmpdir + '/' + base
#
- # Find the pathname of the assembler.
+ # Determine which compiler to use.
#
- as = self.buildroot + '/tools/Debug/as'
+ if (suffix == '.c'):
+ cc = context['cc']
+ cflags = context['cflags']
+ else:
+ cc = context['cpp']
+ cflags = context['cppflags']
#
# Use the LLVM assembler to create the bytecode file.
More information about the llvm-commits
mailing list