Skip to content

Commit 48b039c

Browse files
authored
libyang-python: fix test crash seen in Trixie (#23229)
There is an internal Python CFFI pointer that gets invalidated in a test case due to the internal object being mutated. This test case appears to be malformed and makes incorrect assumptions. Nothing here in particular appears to be actually related to Trixie so it isn't clear why it shows up. The feature being tested is also in a code path that is not used at all by SONiC. CESNET/libyang-python#141 Signed-off-by: Brad House <[email protected]>
1 parent 658c381 commit 48b039c

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From 2d8dcdfb3ac67389b61f46130c27815b47c0e7e7 Mon Sep 17 00:00:00 2001
2+
From: Brad House <[email protected]>
3+
Date: Sun, 6 Jul 2025 16:42:00 -0400
4+
Subject: [PATCH] tests: test_iffeature_state crash fix
5+
6+
As observed on Debian Trixie RC2, test_iffeature_state crashes due
7+
to an internal pointer being invalidated. This invalidation appears
8+
to be due to a call to lys_set_implemented() possibly causing a
9+
full recompile of the ctx.
10+
11+
This simply reorders the caching of the path pointers so they are
12+
not invalidated when used.
13+
14+
Signed-off-by: Brad House <[email protected]>
15+
---
16+
tests/test_schema.py | 19 ++++++++-----------
17+
1 file changed, 8 insertions(+), 11 deletions(-)
18+
19+
diff --git a/tests/test_schema.py b/tests/test_schema.py
20+
index a310aad..4578f84 100644
21+
--- a/tests/test_schema.py
22+
+++ b/tests/test_schema.py
23+
@@ -197,18 +197,8 @@ def feature_disable_only(feature):
24+
continue
25+
self.mod.feature_enable(f.name())
26+
27+
- leaf_simple = next(self.ctx.find_path("/yolo-system:conf/yolo-system:speed"))
28+
-
29+
- self.mod.feature_disable_all()
30+
- leaf_not = next(self.ctx.find_path("/yolo-system:conf/yolo-system:offline"))
31+
- self.mod.feature_enable_all()
32+
-
33+
- leaf_and = next(self.ctx.find_path("/yolo-system:conf/yolo-system:full"))
34+
- leaf_or = next(
35+
- self.ctx.find_path("/yolo-system:conf/yolo-system:isolation-level")
36+
- )
37+
-
38+
# if-feature is just a feature
39+
+ leaf_simple = next(self.ctx.find_path("/yolo-system:conf/yolo-system:speed"))
40+
tree = next(leaf_simple.if_features()).tree()
41+
self.mod.feature_enable_all()
42+
self.assertEqual(tree.state(), True)
43+
@@ -216,6 +206,8 @@ def feature_disable_only(feature):
44+
self.assertEqual(tree.state(), False)
45+
46+
# if-feature is "NOT networking"
47+
+ self.mod.feature_disable_all()
48+
+ leaf_not = next(self.ctx.find_path("/yolo-system:conf/yolo-system:offline"))
49+
tree = next(leaf_not.if_features()).tree()
50+
self.mod.feature_enable_all()
51+
self.assertEqual(tree.state(), False)
52+
@@ -223,6 +215,8 @@ def feature_disable_only(feature):
53+
self.assertEqual(tree.state(), True)
54+
55+
# if-feature is "turbo-boost AND networking"
56+
+ self.mod.feature_enable_all()
57+
+ leaf_and = next(self.ctx.find_path("/yolo-system:conf/yolo-system:full"))
58+
tree = next(leaf_and.if_features()).tree()
59+
self.mod.feature_enable_all()
60+
self.assertEqual(tree.state(), True)
61+
@@ -234,6 +228,9 @@ def feature_disable_only(feature):
62+
self.assertEqual(tree.state(), False)
63+
64+
# if-feature is "turbo-boost OR networking"
65+
+ leaf_or = next(
66+
+ self.ctx.find_path("/yolo-system:conf/yolo-system:isolation-level")
67+
+ )
68+
tree = next(leaf_or.if_features()).tree()
69+
self.mod.feature_enable_all()
70+
self.assertEqual(tree.state(), True)

src/libyang3-py3/patch/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
0001-debian.patch
22
0002-pr134-json-string-datatypes.patch
33
0003-pr132-backlinks.patch
4+
0004-pr141-test-crash.patch

0 commit comments

Comments
 (0)