diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 346: fix two bugs found while doing fastmodel testing

Message ID 20120710160611.11043.99180.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Andy Doan July 10, 2012, 4:06 p.m. UTC
Merge authors:
  Andy Doan (doanac)
Related merge proposals:
  https://code.launchpad.net/~doanac/lava-dispatcher/fm-perms-drain/+merge/114093
  proposed by: Andy Doan (doanac)
  review: Approve - Michael Hudson-Doyle (mwhudson)
------------------------------------------------------------
revno: 346 [merge]
committer: Andy Doan <andy.doan@linaro.org>
branch nick: lava-dispatcher
timestamp: Tue 2012-07-10 11:05:19 -0500
message:
  fix two bugs found while doing fastmodel testing
  
   file permissions
   proper draining of fastmodel pexpect session
modified:
  lava_dispatcher/client/fastmodel.py
  lava_dispatcher/utils.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dispatcher/client/fastmodel.py'
--- lava_dispatcher/client/fastmodel.py	2012-06-29 01:26:45 +0000
+++ lava_dispatcher/client/fastmodel.py	2012-07-09 23:11:59 +0000
@@ -24,6 +24,7 @@ 
 import os
 import pexpect
 import shutil
+import stat
 import threading
 
 from lava_dispatcher.client.base import (
@@ -121,6 +122,17 @@ 
     def _close_serial_proc(self):
         self.proc.close(True)
 
+    def _fix_perms(self):
+        ''' The directory created for the image download/creation gets created
+        with tempfile.mkdtemp which grants permission only to the creator of
+        the directory. We need group access because the dispatcher may run
+        the simulator as a different user
+        '''
+        d = os.path.dirname(self._sd_image)
+        os.chmod(d, stat.S_IRWXG|stat.S_IRWXU)
+        os.chmod(self._sd_image, stat.S_IRWXG|stat.S_IRWXU)
+        os.chmod(self._axf, stat.S_IRWXG|stat.S_IRWXU)
+
     def _get_sim_cmd(self):
         return ("%s -a coretile.cluster0.*=%s "
             "-C motherboard.smsc_91c111.enabled=1 "
@@ -137,6 +149,7 @@ 
         if self._sim_proc is not None:
             self._sim_proc.close()
 
+        self._fix_perms()
         sim_cmd = self._get_sim_cmd()
 
         # the simulator proc only has stdout/stderr about the simulator
@@ -185,4 +198,4 @@ 
         # change simproc's stdout so it doesn't overlap the stdout from our
         # serial console logging
         self.proc.logfile = open('/dev/null', 'w')
-        self.proc.interact()
+        self.proc.drain()

=== modified file 'lava_dispatcher/utils.py'
--- lava_dispatcher/utils.py	2012-06-15 20:35:05 +0000
+++ lava_dispatcher/utils.py	2012-07-09 23:10:24 +0000
@@ -22,6 +22,7 @@ 
 import errno
 import logging
 import os
+import sys
 import shutil
 import urllib2
 import urlparse
@@ -124,6 +125,15 @@ 
 
         return super(logging_spawn, self).expect(*args, **kw)
 
+    def drain(self):
+        """this is a one-off of the pexect __interact that ignores STDIN and
+        handles an error that happens when we call read just after the process exits
+        """
+        try:
+            self._spawn__interact_copy(escape_character=chr(29))
+        except:
+            logging.warn(sys.exc_info())
+            pass
 
 # XXX Duplication: we should reuse lava-test TestArtifacts
 def generate_bundle_file_name(test_name):