freebsd-ports/devel/py-ice/files/patch-py-test-Ice-info-AllTests.py
Ruslan Makhmatkhanov 059541aef9 - respect CC, CXX to allow it be built with clang
- convert to optionsng
- make unit tests work correctly, fix running in a jail, make them run by default
- remove unnecessary -g flag when building a debug version
- silence post-patch commands
- compile and install .pyc and .pyo files (using python's compileall.py).
- rename the patches to comply to the naming conventions in the Porter's Handbook
- pass maintainership to submitter

while here:
- trim Makefile header
- remove indefinite article from COMMENT
- add license (GPLv2) and remove mention of it from pkg-descr
- limit python version to 2.x only

PR:		171645
Submitted by:	Michael Gmelin <freebsd at grem dot de>
Approved by:	Tony Maher <tonymaher at optusnet.com dot au> (maintainer)
Feature safe:	yes
2012-10-27 19:57:57 +00:00

79 lines
2.5 KiB
Python

--- py/test/Ice/info/AllTests.py.orig 2011-06-15 19:44:00.000000000 +0000
+++ py/test/Ice/info/AllTests.py 2012-09-11 19:18:30.188273390 +0000
@@ -7,12 +7,31 @@
#
# **********************************************************************
-import Ice, Test, threading
+import Ice, Test, threading, sys, subprocess
def test(b):
if not b:
raise RuntimeError('test assertion failed')
+def isFreeBSD():
+ return sys.platform.startswith("freebsd")
+
+def sysctl(key):
+ p = subprocess.Popen("sysctl "+key, shell=1, stdout=subprocess.PIPE)
+ try:
+ result = p.communicate()[0].strip().split()[1]
+ except IndexError:
+ return 0
+ if sys.version_info >= (3,):
+ result = str(result, sys.stdout.encoding)
+ try:
+ return int(result)
+ except ValueError:
+ return result
+
+def isFreeBSDJail():
+ return isFreeBSD() and sysctl("security.jail.jailed")
+
def allTests(communicator, collocated):
print "testing proxy endpoint information...",
@@ -64,12 +83,12 @@
ipEndpoint = endpoints[0].getInfo()
test(ipEndpoint.type() == Ice.TCPEndpointType or ipEndpoint.type() == 2)
- test(ipEndpoint.host == defaultHost)
+ test(ipEndpoint.host == defaultHost or isFreeBSDJail())
test(ipEndpoint.port > 0)
test(ipEndpoint.timeout == 15000)
udpEndpoint = endpoints[1].getInfo()
- test(udpEndpoint.host == defaultHost)
+ test(udpEndpoint.host == defaultHost or isFreeBSDJail())
test(udpEndpoint.datagram())
test(udpEndpoint.port > 0)
@@ -104,7 +123,7 @@
ipinfo = base.ice_getConnection().getEndpoint().getInfo()
test(ipinfo.port == 12010)
test(not ipinfo.compress)
- test(ipinfo.host == defaultHost)
+ test(ipinfo.host == defaultHost or isFreeBSDJail())
ctx = testIntf.getEndpointInfoAsContext()
test(ctx["host"] == ipinfo.host)
@@ -114,7 +133,7 @@
udp = base.ice_datagram().ice_getConnection().getEndpoint().getInfo()
test(udp.port == 12010)
- test(udp.host == defaultHost)
+ test(udp.host == defaultHost or isFreeBSDJail())
print "ok"
@@ -124,8 +143,8 @@
test(not info.incoming)
test(len(info.adapterName) == 0)
test(info.remotePort == 12010)
- test(info.remoteAddress == defaultHost)
- test(info.localAddress == defaultHost)
+ test(info.remoteAddress == defaultHost or isFreeBSDJail())
+ test(info.localAddress == defaultHost or isFreeBSDJail())
ctx = testIntf.getConnectionInfoAsContext()
test(ctx["incoming"] == "true")