PATCH: Refine Host.UploadAndRun

Mark Mitchell mark at codesourcery.com
Thu Dec 1 06:49:34 UTC 2005


When using Host.UploadAndRun, the file was left on the target system.
Then, CompilerTest would delete it.  As a result, when running on a
local machine, for a compiler test, the object files, but not the
final executable would be retained after the test.  It makes no sense
to save one and not the other, and is often convenient to have the
executable around.

So, this patch changes UploadAndRun to upload the file, run it, and
then remove it.  (The point of removing the file is that the target
may well have limited disk space; it's not a good idea just to leave
the program on the target.)  Then, CompilerTest._RunExecutable doesn't
have to call DeleteFile.  Finally, for a LocalHost, UploadAndRun is
just Run -- because no uploading is required, and, as a result, no
deleting.

Applied. 

--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com

2005-11-30  Mark Mitchell  <mark at codesourcery.com>

	* qm/host.py (Host.UploadAndRun): Delete the file after running
	it.
	* qm/test/classes/local_host.py (LocalHost.UploadAndRun): New
	method.
	* qm/test/classes/compiler_test.py (CompilerTest._RunExecutable):
	Do not delete executables after running them.

Index: qm/host.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/host.py,v
retrieving revision 1.1
diff -c -5 -p -r1.1 host.py
*** qm/host.py	13 Jun 2005 22:41:18 -0000	1.1
--- qm/host.py	1 Dec 2005 06:42:59 -0000
*************** class Host(Extension):
*** 139,156 ****
          'timeout' -- As for 'Run'.
  
          returns -- As for 'Run'.
  
          The program is uploaded to the default directory on the remote
!         host.""" 
          
          self.UploadFile(path)
!         return self.Run(os.path.join(os.path.curdir,
!                                      os.path.basename(path)),
!                         arguments,
!                         environment,
!                         timeout)
          
          
      def DeleteFile(self, remote_file):
          """Delete the 'remote_file'.
  
--- 139,159 ----
          'timeout' -- As for 'Run'.
  
          returns -- As for 'Run'.
  
          The program is uploaded to the default directory on the remote
!         host, run, and then deleted."""
          
          self.UploadFile(path)
!         result = self.Run(os.path.join(os.path.curdir,
!                                        os.path.basename(path)),
!                           arguments,
!                           environment,
!                           timeout)
!         self.DeleteFile(path)
!         return result
!         
          
          
      def DeleteFile(self, remote_file):
          """Delete the 'remote_file'.
  
Index: qm/test/classes/local_host.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/classes/local_host.py,v
retrieving revision 1.2
diff -c -5 -p -r1.2 local_host.py
*** qm/test/classes/local_host.py	13 Jun 2005 22:41:19 -0000	1.2
--- qm/test/classes/local_host.py	1 Dec 2005 06:42:59 -0000
*************** class LocalHost(Host):
*** 49,58 ****
--- 49,66 ----
          # Do not copy the files if they are the same.
          if not self._SameFile(local_file, remote_file):
              shutil.copy(local_file, remote_file)
  
  
+     def UploadAndRun(self, path, arguments, environment = None,
+                      timeout = -1):
+ 
+         # There is no need to actually upload the file, since it is
+         # running on the local machine.
+         return self.Run(path, arguments, environment, timeout)
+ 
+ 
      def DownloadFile(self, remote_file, local_file = None):
  
          return self.UploadFile(remote_file, local_file)
  
  
Index: qm/test/classes/compiler_test.py
===================================================================
RCS file: /home/qm/Repository/qm/qm/test/classes/compiler_test.py,v
retrieving revision 1.3
diff -c -5 -p -r1.3 compiler_test.py
*** qm/test/classes/compiler_test.py	26 Oct 2005 02:55:21 -0000	1.3
--- qm/test/classes/compiler_test.py	1 Dec 2005 06:45:21 -0000
*************** class CompilerTest(Test, CompilerBase):
*** 296,306 ****
          timeout = context.get("CompilerTest.execution_timeout", -1)
          status, output = target.UploadAndRun(path,
                                               [],
                                               environment,
                                               timeout)
-         target.DeleteFile(path)
          # Record the output.
          result[prefix + "output"] = result.Quote(output)
          # Check the output status.
          result.CheckExitStatus(prefix, "Executable", status)
  
--- 296,305 ----



More information about the qmtest mailing list