summaryrefslogtreecommitdiff
path: root/utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2020-09-08 20:47:19 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2021-05-26 13:03:27 +0900
commit139d8855747799da9218f36720004fb1927bd2ef (patch)
tree7f3f47e68e08cfcf19ee9f37cc91f31690b9fc53 /utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py
parenta7ded8e8f5dd0ae0841960280fe9a7107f945a34 (diff)
utils: ipc: Update mojo
Update mojo from the Chromium repository. The commit from which this was taken is: 9c138d992bfc1fb8f4f7bcf58d00bf19c219e4e2 "Updating trunk VERSION from 4523.0 to 4524.0" The update-mojo.sh script was used for this update. Bug: https://bugs.libcamera.org/show_bug.cgi?id=34 Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py')
-rw-r--r--utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py b/utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py
index a0ee150e..65db4dc9 100644
--- a/utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py
+++ b/utils/ipc/mojo/public/tools/mojom/version_compatibility_unittest.py
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from mojom.generate import module
from mojom_parser_test_case import MojomParserTestCase
@@ -20,9 +21,11 @@ class VersionCompatibilityTest(MojomParserTestCase):
self.assertEqual(set(old.keys()), set(new.keys()),
'Old and new test mojoms should use the same type names.')
+ checker = module.BackwardCompatibilityChecker()
compatibility_map = {}
for name in old.keys():
- compatibility_map[name] = new[name].IsBackwardCompatible(old[name])
+ compatibility_map[name] = checker.IsBackwardCompatible(
+ new[name], old[name])
return compatibility_map
def assertBackwardCompatible(self, old_mojom, new_mojom):
@@ -234,6 +237,47 @@ class VersionCompatibilityTest(MojomParserTestCase):
self.assertNotBackwardCompatible('union U { string a; };',
'union U { string? a; };')
+ def testFieldNestedTypeChanged(self):
+ """Changing the definition of a nested type within a field (such as an array
+ element or interface endpoint type) should only break backward-compatibility
+ if the changes to that type are not backward-compatible."""
+ self.assertBackwardCompatible(
+ """\
+ struct S { string a; };
+ struct T { array<S> ss; };
+ """, """\
+ struct S {
+ string a;
+ [MinVersion=1] string? b;
+ };
+ struct T { array<S> ss; };
+ """)
+ self.assertBackwardCompatible(
+ """\
+ interface F { Do(); };
+ struct S { pending_receiver<F> r; };
+ """, """\
+ interface F {
+ Do();
+ [MinVersion=1] Say();
+ };
+ struct S { pending_receiver<F> r; };
+ """)
+
+ def testRecursiveTypeChange(self):
+ """Recursive types do not break the compatibility checker."""
+ self.assertBackwardCompatible(
+ """\
+ struct S {
+ string a;
+ array<S> others;
+ };""", """\
+ struct S {
+ string a;
+ array<S> others;
+ [MinVersion=1] string? b;
+ };""")
+
def testUnionFieldBecomingNonOptional(self):
"""Changing a field from optional to non-optional breaks
backward-compatibility."""