Skip to content

Commit 2d8dcdf

Browse files
committed
tests: test_iffeature_state crash fix
As observed on Debian Trixie RC2, test_iffeature_state crashes due to an internal pointer being invalidated. This invalidation appears to be due to a call to lys_set_implemented() possibly causing a full recompile of the ctx. This simply reorders the caching of the path pointers so they are not invalidated when used. Signed-off-by: Brad House <brad@brad-house.com>
1 parent 3072af0 commit 2d8dcdf

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/test_schema.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,32 +197,26 @@ def feature_disable_only(feature):
197197
continue
198198
self.mod.feature_enable(f.name())
199199

200-
leaf_simple = next(self.ctx.find_path("/yolo-system:conf/yolo-system:speed"))
201-
202-
self.mod.feature_disable_all()
203-
leaf_not = next(self.ctx.find_path("/yolo-system:conf/yolo-system:offline"))
204-
self.mod.feature_enable_all()
205-
206-
leaf_and = next(self.ctx.find_path("/yolo-system:conf/yolo-system:full"))
207-
leaf_or = next(
208-
self.ctx.find_path("/yolo-system:conf/yolo-system:isolation-level")
209-
)
210-
211200
# if-feature is just a feature
201+
leaf_simple = next(self.ctx.find_path("/yolo-system:conf/yolo-system:speed"))
212202
tree = next(leaf_simple.if_features()).tree()
213203
self.mod.feature_enable_all()
214204
self.assertEqual(tree.state(), True)
215205
self.mod.feature_disable_all()
216206
self.assertEqual(tree.state(), False)
217207

218208
# if-feature is "NOT networking"
209+
self.mod.feature_disable_all()
210+
leaf_not = next(self.ctx.find_path("/yolo-system:conf/yolo-system:offline"))
219211
tree = next(leaf_not.if_features()).tree()
220212
self.mod.feature_enable_all()
221213
self.assertEqual(tree.state(), False)
222214
self.mod.feature_disable_all()
223215
self.assertEqual(tree.state(), True)
224216

225217
# if-feature is "turbo-boost AND networking"
218+
self.mod.feature_enable_all()
219+
leaf_and = next(self.ctx.find_path("/yolo-system:conf/yolo-system:full"))
226220
tree = next(leaf_and.if_features()).tree()
227221
self.mod.feature_enable_all()
228222
self.assertEqual(tree.state(), True)
@@ -234,6 +228,9 @@ def feature_disable_only(feature):
234228
self.assertEqual(tree.state(), False)
235229

236230
# if-feature is "turbo-boost OR networking"
231+
leaf_or = next(
232+
self.ctx.find_path("/yolo-system:conf/yolo-system:isolation-level")
233+
)
237234
tree = next(leaf_or.if_features()).tree()
238235
self.mod.feature_enable_all()
239236
self.assertEqual(tree.state(), True)

0 commit comments

Comments
 (0)