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

John Criswell criswell at cs.uiuc.edu
Tue Oct 7 15:56:01 PDT 2003


Changes in directory llvm/test/QMTest:

llvm.py updated: 1.14 -> 1.15

---
Log message:

Added an option to ExecProgram() that allows a caller to specify an output
filename.  This is useful for TestRunner tests.
Modified TestRunner so that it uses ExecProgram.  Errors should be easier
to catch now, and fork/exec time should be smaller.
Renamed the output files of TestRunner tests so that they don't conflict
with Feature tests with similar names (i.e. basictest).



---
Diffs of the changes:  (+13 -9)

Index: llvm/test/QMTest/llvm.py
diff -u llvm/test/QMTest/llvm.py:1.14 llvm/test/QMTest/llvm.py:1.15
--- llvm/test/QMTest/llvm.py:1.14	Tue Oct  7 14:12:32 2003
+++ llvm/test/QMTest/llvm.py	Tue Oct  7 15:55:15 2003
@@ -34,12 +34,15 @@
 #	0 - The program executed successfully.
 #	1 - The program failed.
 #
-def ExecProgram (args, env = os.environ):
+def ExecProgram (args, env = os.environ, outfile=''):
 
 	#
 	# Create a pipe to the new program.
 	#
-	(parent_in, child_out) = os.pipe ()
+	if (outfile == ''):
+		(parent_in, child_out) = os.pipe ()
+	else:
+		child_out = os.open (outfile, os.O_WRONLY | os.O_CREAT, 0700)
 
 	#
 	# Create a new child process.
@@ -49,8 +52,8 @@
 		#
 		# Construct new stdout, and stderr.
 		#
-		os.dup2 (1, child_out);
-		os.dup2 (2, child_out);
+		os.dup2 (child_out, 1);
+		os.dup2 (child_out, 2);
 
 		#
 		# Execute the specified program.
@@ -958,7 +961,7 @@
 		#
 		# Create a new directory based upon the test's name.
 		#
-		tmpdir = tmpdir + '/' + os.path.basename (self.srcfile)
+		tmpdir = tmpdir + '/tr' + os.path.basename (self.srcfile)
 		if ((os.access(tmpdir,os.F_OK)) == 0):
 			try:
 				os.mkdir (tmpdir)
@@ -1012,11 +1015,12 @@
 		#
 		# Execute the script using TestRunner.
 		#
-		command = 'cd ' + tmpdir + ';/bin/sh ' + scriptfile + ' > ' + outputfile + ' 2>&1'
-
-		estatus=os.system (command)
-		if ((os.WIFEXITED(estatus)) and (os.WEXITSTATUS(estatus) != 0)):
+		mypath = os.getcwd ()
+		os.chdir (tmpdir)
+		if (ExecProgram (('/bin/sh', scriptfile), environment, outputfile)):
 			result.Fail('Script: ' + scriptfile + '\n    Output: ' + outputfile)
+
+		os.chdir (mypath)
 
 		#
 		# Restore the PATH environment variable





More information about the llvm-commits mailing list