Make sure that the vhci-hcd
kernel module is loaded:
# lsmod | grep vhci_hcd || modprobe vhci-hcd
Use the test-release.sh
script to download and test the usbip binaries from a GitHub release of the nitrokey-3-firmware
repository:
$ ./test-release.sh v1.3.0-rc.1
If you pass a second version, it will also run upgrade tests from that version:
$ ./test-release.sh v1.3.0-rc.1 v1.2.2-alpha.20230224
Use the test-local.sh
script to compile the usbip runner from a local Git checkout of the nitrokey-3-firmware
repository instead:
$ ./test-local.sh ../nitrokey-3-firmware
If you have a clean Git checkout, you can also enable upgrade tests from an old commit:
$ ./test-local.sh ../nitrokey-3-firmware v1.3.0
This will build the new firmware from HEAD
and the old firmware from the specified revision or tag.
If you want to use the Makefile to run the tests, you have to provide the usbip-runner
and usbip-provisioner
binaries in the bin
directory, for example by building them from source. See the test-local.sh
script for insipration. If you want to execute the upgrade tests, you also have to provide the usbip-runner-old
and usbip-provisioner-old
binaries for the firmware version to upgrade from.
These are the most useful targets in the Makefile:
$ make
$ make run-docker
$ make run
$ make check
The flags passed to pytest
can be extended by setting the PYTEST_FLAGS
environment variable.
To enable upgrade tests, set the --upgrade
flag. This only works with virtual devices and requires the usbip-runner-old
and usbip-provisioner-old
binaries.
Per default, the tests use a usbip simulation of a Nitrokey 3 device. If you want to use them with a real Nitrokey 3 device connected to your computer:
--use-usb-devices [uuid1] [uuid2] ... [uuidN]
(using PYTEST_FLAGS
) option with the UUIDs to whitelist for testingvirtual
mark with the -m "not virtual"
optionThere also is a shortcut for this:
variables.mk
with the variable: ALLOWED_UUIDS
which will be used for --use-usb-devices
make run-hw
to run the tests on one of the ALLOWED_UUIDS
PYTEST_EXTRA
to the make
call to call pytest with these extra argumentsWarning: The test suite will perform destructive changes like setting a PIN or resetting the device.