Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(747)

Unified Diff: client/common_lib/utils_unittest.py

Issue 3554003: Merge remote branch 'cros/upstream' into tempbranch3 (Closed) Base URL: http://git.chromium.org/git/autotest.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/common_lib/utils.py ('k') | client/deps/boottool/boottool.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/common_lib/utils_unittest.py
diff --git a/client/common_lib/utils_unittest.py b/client/common_lib/utils_unittest.py
index b0a928bfef7c0b7068634f11b5dba996d96ccacc..8eef49c8dcbffb63f8a3bc0c1644a5d668216485 100755
--- a/client/common_lib/utils_unittest.py
+++ b/client/common_lib/utils_unittest.py
@@ -773,5 +773,22 @@ class test_args_to_dict(unittest.TestCase):
logger.setLevel(saved_level)
+class test_get_random_port(unittest.TestCase):
+ def do_bind(self, port, socket_type, socket_proto):
+ s = socket.socket(socket.AF_INET, socket_type, socket_proto)
+ s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+ s.bind(('', port))
+ return s
+
+
+ def test_get_port(self):
+ for _ in xrange(100):
+ p = utils.get_unused_port()
+ s = self.do_bind(p, socket.SOCK_STREAM, socket.IPPROTO_TCP)
+ self.assert_(s.getsockname())
+ s = self.do_bind(p, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
+ self.assert_(s.getsockname())
+
+
if __name__ == "__main__":
unittest.main()
« no previous file with comments | « client/common_lib/utils.py ('k') | client/deps/boottool/boottool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698