diff options
author | Joe George <joe@zeroc.com> | 2020-07-07 16:57:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 16:57:51 -0400 |
commit | 6c0e7e6fcabde691e7c38a814b6171f9f4e77d09 (patch) | |
tree | aed41fdff6561e134c73da214e580be0910e6f6a /python/test | |
parent | Copy python dependencies to the extension directory - Close #926 (#927) (diff) | |
download | ice-6c0e7e6fcabde691e7c38a814b6171f9f4e77d09.tar.bz2 ice-6c0e7e6fcabde691e7c38a814b6171f9f4e77d09.tar.xz ice-6c0e7e6fcabde691e7c38a814b6171f9f4e77d09.zip |
Add class cycle detection during unmarshaling (#946)
Add support for detection of class cycles during unmarshaling in
languages which do no have garbage collection: C++, Swift, and Objective-C.
A `MarshalException` is thrown when a cycle is detected.
The property `Ice.AcceptClassCycles` can be set to a value greater than `0`
to change this behavior.
Diffstat (limited to 'python/test')
-rw-r--r-- | python/test/Ice/admin/AllTests.py | 4 | ||||
-rw-r--r-- | python/test/Ice/objects/AllTests.py | 12 | ||||
-rw-r--r-- | python/test/Ice/objects/Test.ice | 3 | ||||
-rw-r--r-- | python/test/Ice/objects/TestI.py | 6 |
4 files changed, 24 insertions, 1 deletions
diff --git a/python/test/Ice/admin/AllTests.py b/python/test/Ice/admin/AllTests.py index 1e8e1cb72d9..a6ac1fcb2f8 100644 --- a/python/test/Ice/admin/AllTests.py +++ b/python/test/Ice/admin/AllTests.py @@ -183,12 +183,14 @@ def allTests(helper, communicator): # Test: PropertiesAdmin::getProperties() # pd = pa.getPropertiesForPrefix("") - test(len(pd) == 5) + test(len(pd) == 6) test(pd["Ice.Admin.Endpoints"] == "tcp -h 127.0.0.1") test(pd["Ice.Admin.InstanceName"] == "Test") test(pd["Prop1"] == "1") test(pd["Prop2"] == "2") test(pd["Prop3"] == "3") + # Ice for Python always sets Ice.AcceptClassCycles + test(pd["Ice.AcceptClassCycles"] == "1") changes = {} diff --git a/python/test/Ice/objects/AllTests.py b/python/test/Ice/objects/AllTests.py index 13dcef18c27..0cdcbd7d48d 100644 --- a/python/test/Ice/objects/AllTests.py +++ b/python/test/Ice/objects/AllTests.py @@ -357,4 +357,16 @@ def allTests(helper, communicator): test(f32.f2.ice_getIdentity().name == "F22") print("ok") + sys.stdout.write("testing sending class cycle... ") + sys.stdout.flush() + rec = Test.Recursive() + rec.v = rec + acceptsCycles = initial.acceptsClassCycles() + try: + initial.setCycle(rec) + test(acceptsCycles) + except Ice.UnknownLocalException: + test(not acceptsCycles) + print("ok") + return initial diff --git a/python/test/Ice/objects/Test.ice b/python/test/Ice/objects/Test.ice index e6e4828ffb9..0acc2fd52a5 100644 --- a/python/test/Ice/objects/Test.ice +++ b/python/test/Ice/objects/Test.ice @@ -216,6 +216,9 @@ interface Initial void setRecursive(Recursive p); bool supportsClassGraphDepthMax(); + void setCycle(Recursive r); + bool acceptsClassCycles(); + ["marshaled-result"] B getMB(); ["amd", "marshaled-result"] B getAMDMB(); diff --git a/python/test/Ice/objects/TestI.py b/python/test/Ice/objects/TestI.py index 7bebf279f22..82d868f0143 100644 --- a/python/test/Ice/objects/TestI.py +++ b/python/test/Ice/objects/TestI.py @@ -126,6 +126,12 @@ class InitialI(Test.Initial): def supportsClassGraphDepthMax(self, current): return True + def setCycle(self, r, current): + pass + + def acceptsClassCycles(self, current): + return True + def getMB(self, current): return Test.Initial.GetMBMarshaledResult(self._b1, current) |