Skip to content

Commit 7e72d38

Browse files
committed
Do not register 'testclass' device class outside of tests
Now that more places (especially qvm-clone and ansible) properly lists available device classes, it's no longer harmless to include 'testclass' on production system. There is a mechanism to replace some entry point with another for tests (`substitute_entry_points` context manager), but unfortunately it can't be used here, as device classes are enumerated at the qubes.api.admin import time, not test run time (as it's the case for storage classes). Exclude it normally, and include only if QUBES_TEST=1 variable is set - which is done in run-tests script. The 'testclass' devices are used only in unit tests, so it's okay to not include them in integration tests. Reported at QubesOS/qubes-ansible#6 (comment)
1 parent a930d4e commit 7e72d38

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

run-tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ unset dir
4545

4646
PYTHONPATH=${TESTPYTHONPATH}${PYTHONPATH+":${PYTHONPATH}"}
4747
export PYTHONPATH
48+
export QUBES_TEST=1
4849

4950
"${PYTHON}" setup.py egg_info --egg-base "${TESTPYTHONPATH}"
5051
"${PYTHON}" -m coverage run --rcfile=ci/coveragerc -m qubes.tests.run "$@"

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ def run(self):
8080
'qubes.devices': [
8181
'pci = qubes.ext.pci:PCIDevice',
8282
'block = qubes.ext.block:BlockDevice',
83+
] + [
8384
'testclass = qubes.tests.devices:TestDevice',
84-
],
85+
] if os.environ.get("QUBES_TEST") else [],
8586
'qubes.storage': [
8687
'file = qubes.storage.file:FilePool',
8788
'file-reflink = qubes.storage.reflink:ReflinkPool',

0 commit comments

Comments
 (0)