File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ if have_python_support
6262
6363 py_tests = [
6464 [ ' create ctrl object' , files (' tests/create-ctrl-obj.py' ) ],
65+ [ ' SIGSEGV during gc' , files (' tests/gc.py' ) ],
6566 ]
6667 foreach test : py_tests
6768 description = test[0 ]
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ # SPDX-License-Identifier: LGPL-2.1-or-later
3+ import gc
4+ import sys
5+ import pprint
6+ from libnvme import nvme
7+
8+ root = nvme .root ()
9+ root .log_level ('debug' )
10+ print (f'root: { root } ' )
11+
12+ host = nvme .host (root )
13+ print (f'host: { host } ' )
14+
15+ subsystem = host .subsystems ()
16+ print (f'subsystem: { subsystem } ' )
17+
18+ ctrls = []
19+ for i in range (10 ):
20+ ctrl = nvme .ctrl (
21+ root ,
22+ subsysnqn = nvme .NVME_DISC_SUBSYS_NAME ,
23+ transport = 'loop' ,
24+ )
25+ ctrls .append (ctrl )
26+ print (f'ctrl { i } : { ctrl } ' )
27+
28+ ns = subsystem .namespaces () if subsystem is not None else None
29+ print (f'ns: { ns } ' )
30+
31+ # Deleting objects in the following order would create a segmentation
32+ # fault if it weren't for the %pythonappend in nvme.i. This test is to
33+ # make sure garbage collection is not impacted by object deletion order.
34+ root = None
35+ host = None
36+
37+ gc .collect () # Force garbage collection before controller/subsystem objects get deleted
38+
39+ ctrls = None
40+ subsystem = None
41+ ns = None
You can’t perform that action at this time.
0 commit comments