Browse Source

Merge pull request #1535 from hamiltont/remove-install-scripts

Fix setup script bugs
Mike Smith 10 years ago
parent
commit
aa59ed280d
2 changed files with 12 additions and 7 deletions
  1. 3 2
      toolset/benchmark/benchmarker.py
  2. 9 5
      toolset/benchmark/framework_test.py

+ 3 - 2
toolset/benchmark/benchmarker.py

@@ -715,13 +715,14 @@ class Benchmarker:
   # shutdown properly.
   ############################################################
   def __is_port_bound(self, port):
+    port = int(port)
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     try:
       # Try to bind to all IP addresses, this port
       s.bind(("", port))
       # If we get here, we were able to bind successfully,
       # which means the port is free.
-    except Exception:
+    except socket.error:
       # If we get an exception, it might be because the port is still bound
       # which would be bad, or maybe it is a privileged port (<1024) and we
       # are not running as root, or maybe the server is gone, but sockets are
@@ -732,7 +733,7 @@ class Benchmarker:
         # If we get here, we were able to connect to something, which means
         # that the port is still bound.
         return True
-      except Exception:
+      except socket.error:
         # An exception means that we couldn't connect, so a server probably
         # isn't still running on the port.
         pass

+ 9 - 5
toolset/benchmark/framework_test.py

@@ -283,9 +283,9 @@ class FrameworkTest:
     # output to the pipes. 
     #
     prefix = "Setup %s: " % self.name
-    while not (p.poll() 
-      or self.benchmarker.is_port_bound(self.port)
-      or time_remaining.total_seconds() < 0):
+    while (p.poll() is None
+      and not self.benchmarker.is_port_bound(self.port)
+      and not time_remaining.total_seconds() < 0):
       
       # The conditions above are slow to check, so 
       # we will delay output substantially if we only
@@ -310,6 +310,8 @@ class FrameworkTest:
 
       if (travis_timeout - datetime.now()).total_seconds() < 0:
         sys.stdout.write(prefix + 'Printing so Travis-CI does not time out\n')
+        sys.stdout.write(prefix + "Status: Poll: %s, Port %s bound: %s, Time Left: %s\n" % (
+          p.poll(), self.port, self.benchmarker.is_port_bound(self.port), time_remaining))
         sys.stdout.flush()
         travis_timeout = datetime.now() + timedelta(minutes = 5)
 
@@ -322,8 +324,10 @@ class FrameworkTest:
     # What's our return code? 
     # If setup.sh has terminated, use that code
     # Otherwise, detect if the port was bound
-    retcode = (p.poll() or 0 if self.benchmarker.is_port_bound(self.port) else 1)
-    if p.poll():
+    tee_output(prefix, "Status: Poll: %s, Port %s bound: %s, Time Left: %s\n" % (
+      p.poll(), self.port, self.benchmarker.is_port_bound(self.port), time_remaining))
+    retcode = (p.poll() if p.poll() is not None else 0 if self.benchmarker.is_port_bound(self.port) else 1)
+    if p.poll() is not None:
       tee_output(prefix, "%s.sh process exited naturally with %s\n" % (self.setup_file, p.poll()))
     elif self.benchmarker.is_port_bound(self.port):
       tee_output(prefix, "Bound port detected on %s\n" % self.port)