1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
|
:mod:`plugins` – Testsuite plugins
==================================
.. automodule:: plugins
The following plugins are provided and enabled:
.. autosummary::
udev_database
privileged
fake_monitor
mock_libudev
libudev
The main plugin is :mod:`~plugins.udev_database` that extracts the
real udev database using the ``udevadm`` utility and provides tests with a
sample of this database. It also supports to restrict tests to certain udev
versions.
The other plugins only provide support for specific test cases by tuning some
hooks or adding some additional funcargs.
:mod:`~plugins.udev_database` – pytest_ plugin to access the udev device database
---------------------------------------------------------------------------------
.. automodule:: plugins.udev_database
.. autoclass:: DeviceDatabase()
:members:
.. autoclass:: DeviceData()
:members:
.. attribute:: device_path
The path of the device without the ``sysfs`` mountpoint.
Test markers
~~~~~~~~~~~~
.. function:: pytest.mark.udev_version(version_spec)
Specify the udev version requirement for a test::
@pytest.mark.udev_version('>= 180')
def test_foo():
assert True
``test_foo`` will only be run, if the udev version is greater or equal than
180. Otherwise the test is skipped.
``version_spec`` is a string specifying the udev version requirement. If
the requirement is not met, the test is skipped.
Configuration values
~~~~~~~~~~~~~~~~~~~~
The plugin attaches the following attributes to :data:`pytest.config`:
.. attribute:: pytest.config.udev_version
The udev version as integer.
.. attribute:: pytest.config.udev_database
The whole udev device database as :class:`DeviceDatabase` object.
.. attribute:: pytest.config.udev_device_sample
A list of devices to use for tests as list of :class:`DeviceData` objects,
an excerpt of :attr:`pytest.config.udev_database`.
Funcargs
~~~~~~~~
The plugin provides the following :ref:`funcargs <funcargs>`:
.. autofunction:: pytest_funcarg__udev_database
Command line options
~~~~~~~~~~~~~~~~~~~~
The plugin adds the following command line options to :program:`py.test`:
.. program:: py.test
.. option:: --all-devices
Run device tests against *all* devices in the database. By default, only a
random sample of devices are being tested against.
.. warning::
Tests may take a very long time with this option.
.. option:: --device DEVICE
Run device tests against a specific device only. ``DEVICE`` is the device
path *without* the sysfs mountpoint.
.. option:: --device-sample-size N
The size of the random sample. Defaults to 10.
:mod:`~plugins.privileged` – Privileged operations
--------------------------------------------------
.. automodule:: plugins.privileged
Command line options
~~~~~~~~~~~~~~~~~~~~
The plugin adds the following command line options to :program:`py.test`:
.. program:: py.test
.. option:: --enable-privileged
Enable privileged tests. You'll need to have :program:`sudo` configured
correctly in order to run tests with this option.
Configuration
~~~~~~~~~~~~~
In order to execute these tests without failure, you need to configure :program:`sudo`
to allow the user that executes the test to run the following commands:
- ``modprobe dummy``
- ``modprobe -r dummy``
To do so, create a file ``/etc/sudoers.d/20pyudev-tests`` with the following
content::
me ALL = (root) NOPASSWD: /sbin/modprobe dummy, /sbin/modprobe -r dummy
Replace ``me`` with your actual user name. ``NOPASSWD:`` tells :program:`sudo`
not to ask for a password when executing these commands. This is simply for
the sake of convenience and to allow unattended test execution. Remove this
word if you want to be asked for a password.
Make sure to change the owner and group to ``root:root`` and the permissions of
this file to ``440`` afterwards, other :program:`sudo` will refuse to load the
file. Also check the file with :program:`visudo` to prevent syntactic errors::
$ chown root:root /etc/sudoers.d/20pyudev-tests
$ chmod 440 /etc/sudoers.d/20pyudev-tests
$ visudo -c -f /etc/sudoers.d/20pyudev-tests
:mod:`pytest` namespace
~~~~~~~~~~~~~~~~~~~~~~~
The plugin adds the following functions to the :mod:`pytest` namespace:
.. autofunction:: load_dummy
.. autofunction:: unload_dummy
:mod:`~plugins.fake_monitor` – A fake :class:`Monitor`
------------------------------------------------------
.. automodule:: plugins.fake_monitor
.. autoclass:: FakeMonitor
:members:
Funcargs
~~~~~~~~
The plugin provides the following :ref:`funcargs <funcargs>`:
.. autofunction:: pytest_funcarg__fake_monitor
:mod:`~plugins.mock_libudev` – Mock calls to libudev
----------------------------------------------------
.. automodule:: plugins.mock_libudev
.. autofunction:: calls_to_libudev(function_calls)
.. autofunction:: libudev_list(function, items)
:mod:`~plugins.libudev` – Parse ``libudev.h``
---------------------------------------------
.. automodule:: plugins.libudev
Configuration values
~~~~~~~~~~~~~~~~~~~~
This plugin attaches the following attribute to :data:`pytest.config`:
.. attribute:: libudev_functions
All libudev functions as list of :class:`Function` objects.
Funcargs
~~~~~~~~
This plugin provides the the following :ref:`funcarg <funcargs>`:
.. autofunction:: pytest_funcarg__libudev_function
Types
~~~~~
.. autoclass:: GCCXMLParser
:members:
.. autoclass:: Unit
:members:
.. rubric:: Symbol classes
.. class:: Function
A function.
.. attribute:: name
The function name as string
.. attribute:: arguments
A tuple providing with the argument types of this function
.. attribute:: return_type
The return type of this function
.. class:: Struct
A structure.
.. attribute:: name
The struct name as string
.. class:: FundamentalType
A fundamental type.
.. attribute:: name
The type name as string
.. class:: CvQualifiedType
A constant-qualified type.
.. attribute:: type
The underlying type
.. class:: PointerType
A pointer type.
.. attribute:: type
The underyling type
.. _pytest: http://pytest.org
|