Patchwork [3,of,3,v2] run-tests: validate cached port in _getport

login
register
mail settings
Submitter timeless@mozdev.org
Date Dec. 29, 2015, 5:40 a.m.
Message ID <ecd36680cdf2dd638645.1451367600@waste.org>
Download mbox | patch
Permalink /patch/12391/
State Rejected
Delegated to: Yuya Nishihara
Headers show

Comments

timeless@mozdev.org - Dec. 29, 2015, 5:40 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1451364276 0
#      Tue Dec 29 04:44:36 2015 +0000
# Node ID ecd36680cdf2dd63864505f60ee14ed3ef84e864
# Parent  a12404484af03ddddbd326af08ca1217b77ebc13
run-tests: validate cached port in _getport
Yuya Nishihara - Jan. 1, 2016, 7:14 a.m.
On Mon, 28 Dec 2015 23:40:00 -0600, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1451364276 0
> #      Tue Dec 29 04:44:36 2015 +0000
> # Node ID ecd36680cdf2dd63864505f60ee14ed3ef84e864
> # Parent  a12404484af03ddddbd326af08ca1217b77ebc13
> run-tests: validate cached port in _getport
> 
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -2012,9 +2012,9 @@
>          return True
>  
>      def _getport(self, count):
> +        portneeded = 3
>          port = self._ports.get(count) # do we have a cached entry?
> -        if port is None:
> -            portneeded = 3
> +        if port is None or not self._checkportrange(port, portneeded):

I see no benefit to re-validate ports here because _getport() is called
repeatedly before running all tests.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2012,9 +2012,9 @@ 
         return True
 
     def _getport(self, count):
+        portneeded = 3
         port = self._ports.get(count) # do we have a cached entry?
-        if port is None:
-            portneeded = 3
+        if port is None or not self._checkportrange(port, portneeded):
             # above 100 tries we just give up and let test reports failure
             for tries in xrange(100):
                 port = self.options.port + self._portoffset