Author: mattip <[email protected]>
Branch: issue1430
Changeset: r71108:f5c53e131b78
Date: 2014-05-01 01:23 +0300
http://bitbucket.org/pypy/pypy/changeset/f5c53e131b78/
Log: add tests
diff --git a/rpython/rlib/test/test_rsocket.py
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -61,6 +61,41 @@
py.test.fail("could not find the localhost address in %r"
% (address_list,))
+def test_thread_safe_gethostbyname_ex():
+ import threading
+ nthreads = 10
+ domain = 'google.com'
+ result = [0] * nthreads
+ threads = [None] * nthreads
+ def lookup_name(i):
+ name, aliases, address_list = gethostbyname_ex(domain)
+ if name == domain:
+ result[i] += 1
+ for i in range(nthreads):
+ threads[i] = threading.Thread(target = lookup_name, args=[i])
+ threads[i].start()
+ for i in range(nthreads):
+ threads[i].join()
+ assert sum(result) == nthreads
+
+def test_thread_safe_gethostbyaddr():
+ import threading
+ nthreads = 10
+ ip = '8.8.8.8'
+ domain = gethostbyaddr(ip)[0]
+ result = [0] * nthreads
+ threads = [None] * nthreads
+ def lookup_addr(ip, i):
+ name, aliases, address_list = gethostbyaddr(ip)
+ if name == domain:
+ result[i] += 1
+ for i in range(nthreads):
+ threads[i] = threading.Thread(target = lookup_addr, args=[ip, i])
+ threads[i].start()
+ for i in range(nthreads):
+ threads[i].join()
+ assert sum(result) == nthreads
+
def test_gethostbyaddr():
try:
cpy_socket.gethostbyaddr("::1")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit