There's no F1 discovery style board with usb device, so this is for a "generic" device. The USB portion should be safe, but there's a led used for bootup that is board specific, and of course the clock source is board specific. Related, the openocd config file is rather custom to my own setup, but shows what you need to customize for your test environment. Further, as the F1 usb core doesn't include support for soft disconnect, use the very hacky method of dragging the pin low to force reenumeration on reset. Very very useful for development purposes!
This project, inspired by usbtest and the linux usb gadget zero driver is used for regression testing changes to the libopencm3 usb stack.
The firmware itself is meant to be portable to any supported hardware, and then identical unit test code is run against all platforms. This project can and should be built for multiple devices.
Requirements: pyusb for running the tests. openocd >= 0.9 for automated flashing of specific boards python3 for running the tests at the command line.
You will need to modify the openocd config files, as they contain specific serial numbers of programming hardware. You should set these up for the set of available boards at your disposal.
Tests marked as @unittest.skip are either for functionality that is known to be broken, and are awaiting code fixes, or are long running performance tests
An example of a successful test run: