[llvm-commits] CVS: llvm/test/QMTestDB/QMTest/llvm.py
John Criswell
criswell at cs.uiuc.edu
Wed Aug 20 15:43:01 PDT 2003
Changes in directory llvm/test/QMTestDB/QMTest:
llvm.py updated: 1.1 -> 1.2
---
Log message:
Added CTest: a test class which compiles a program into LLVM assembly language
and then attempts to assemble the output into LLVM bytecode.
---
Diffs of the changes:
Index: llvm/test/QMTestDB/QMTest/llvm.py
diff -u llvm/test/QMTestDB/QMTest/llvm.py:1.1 llvm/test/QMTestDB/QMTest/llvm.py:1.2
--- llvm/test/QMTestDB/QMTest/llvm.py:1.1 Tue Aug 19 22:06:54 2003
+++ llvm/test/QMTestDB/QMTest/llvm.py Wed Aug 20 15:42:18 2003
@@ -820,6 +820,7 @@
environment=os.environ
oldpath=environment['PATH']
environment['PATH'] = buildroot + '/tools/' + buildtype + ':' + srcroot + '/test/Scripts:' + environment['PATH']
+ environment['QMV_llvmgcc'] = context['llvmgcc']
#
# Create the script that will run the test.
@@ -938,6 +939,88 @@
# This method removes the resource once it is no longer needed.
#
def CleanUp(self, result):
+ return
+
+##############################################################################
+#
+# 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):
+
+ #
+ # 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
More information about the llvm-commits
mailing list