[llvm-commits] CVS: llvm/test/QMTestDB/QMTest/llvm.py
John Criswell
criswell at cs.uiuc.edu
Tue Sep 30 14:04:01 PDT 2003
Changes in directory llvm/test/QMTestDB/QMTest:
llvm.py updated: 1.8 -> 1.9
---
Log message:
Added a test class that compiles C++ code into LLVM bytecode.
---
Diffs of the changes:
Index: llvm/test/QMTestDB/QMTest/llvm.py
diff -u llvm/test/QMTestDB/QMTest/llvm.py:1.8 llvm/test/QMTestDB/QMTest/llvm.py:1.9
--- llvm/test/QMTestDB/QMTest/llvm.py:1.8 Thu Sep 25 19:52:59 2003
+++ llvm/test/QMTestDB/QMTest/llvm.py Tue Sep 30 14:03:44 2003
@@ -1083,6 +1083,94 @@
return
+##############################################################################
+#
+# Class: CXXTest
+#
+# 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 CXXTest(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
+ #
+ 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
+ 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['llvmgxx']
+ as = buildroot + '/tools/' + context['buildtype'] + '/llvm-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
More information about the llvm-commits
mailing list