tests: Simplify capture of driver behaviour for regression tests

And update instructions for the simpler method.

Co-authored-by: Benjamin Berg <bberg@redhat.com>
This commit is contained in:
Bastien Nocera
2021-09-03 18:20:03 +02:00
committed by Benjamin Berg
parent e2511095d1
commit aff063c23c
3 changed files with 184 additions and 47 deletions

View File

@@ -15,57 +15,23 @@ script, capture it and store the capture to `custom.pcapng`.
-----------------------
A new 'capture' test is created by means of `capture.py` script:
1. Create (if needed) a directory for the driver under `tests`
directory:
1. Make sure that libfprint is built with support for the device driver
that you want to capture a test case for.
`mkdir DRIVER`
2. From the build directory, run tests/create-driver-test.py as root. Note
that if you're capturing data for a driver which already has a test case
but the hardware is slightly different, you might want to pass a variant
name as a command-line options, for example:
```sh
$ sudo tests/create-driver-test.py driver [variant]
```
Note that the name must be the exact name of the libfprint driver,
or the exact name of the driver followed by a `-` and a unique identifier
of your choosing.
3. If the capture is not successful, run the tool again to start another capture.
2. Prepare your execution environment.
4. Add driver test name to `drivers_tests` in the `meson.build`, as instructed,
and change the ownership of the just-created test directory in the source.
In the next step a working and up to date libfprint is needed. This can be
achieved by installing it into your system. Alternatively, you can set
the following environment variables to run a local build:
- `export LD_PRELOAD=<meson-build-dir>/libfprint/libfprint-2.so`
- `export GI_TYPELIB_PATH=<meson-build-dir>/libfprint`
Also, sometimes the driver must be adapted to the emulated environment
(mainly if it uses random numbers, see `synaptics.c` for an example).
Set the following environment variable to enable this adaptation:
- `export FP_DEVICE_EMULATION=1`
Run the next steps in the same terminal.
3. Find the real USB fingerprint device with `lsusb`, e.g.:
`Bus 001 Device 005: ID 138a:0090 Validity Sensors, Inc. VFS7500 Touch Fingerprint Sensor`
The following USB device is used in the example above:
`/dev/bus/usb/001/005`.
For the following commands, it is assumed that the user that's
running the commands has full access to the device node, whether
by running the commands as `root`, or changing the permissions for
that device node.
4. Record information about this device:
`umockdev-record /dev/bus/usb/001/005 > DRIVER/device`
5. Record interaction of `capture.py` (or other test) with the device. To do
so, start wireshark and record `usbmonX` (where X is the bus number). Then
run the test script:
`python3 ./capture.py DRIVER/capture.png`
Save the wireshark recording as `capture.pcapng`. The command will create
`capture.png`.
6. Add driver's name to `drivers_tests` in the `meson.build`.
7. Check whether everything works as expected.
5. Check whether `meson test` passes with this new test.
**Note.** To avoid submitting a real fingerprint, the side of finger,
arm, or anything else producing an image with the device can be used.