libopencm3/tests/gadget-zero
Karl Palsson 5617ed4664 jenkins: reduce parallel, add verbose
V=s is openwrt, V=1 is here.
try and avoid weird problems with missing files like,
make[1]: *** No rule to make target '../../../include/libopencm3/stm32/g4/pwr.h', needed by 'rcc_common_all.o'.  Stop.

by turning down the paralellism a bit, it's a quad core arm, but it's
stil a little small machine.
2020-09-27 13:47:08 +00:00
..
.gitignore tests: usb-gadget0: gitignore generated linker scripts 2018-08-27 15:11:32 +00:00
70-libopencm3.rules tests: gadget0: include sample udev rules and document 2017-10-02 21:46:38 +00:00
Jenkinsfile jenkins: reduce parallel, add verbose 2020-09-27 13:47:08 +00:00
Makefile gadget0: allow parallel submake 2019-06-28 21:45:14 +00:00
Makefile.efm32hg309-generic tests: gadget0: efm32hg: add gadget0 test for efm32hg 2018-03-02 22:42:05 +00:00
Makefile.stm32f3-disco tests: gadget0: add stm32f3-disco 2018-05-01 22:23:47 +00:00
Makefile.stm32f4disco tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
Makefile.stm32f072disco tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
Makefile.stm32f103-generic tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
Makefile.stm32f429i-disco tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
Makefile.stm32l1-generic gadget0: stm32l1: target the "hw1" test board explicitly 2018-04-14 18:40:54 +00:00
Makefile.stm32l053disco tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
Makefile.tilm4f120xl tests: usb gadget0: add ti lm4f120xl board 2018-08-27 15:11:32 +00:00
README.md tests: gadget-zero: add xunit reporting 2020-09-10 21:19:55 +00:00
delay.c tests/gadget0: avoid floating point division 2020-01-04 23:49:16 +00:00
delay.h tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
delay_efm32.c tests: gadget0: efm32hg: add gadget0 test for efm32hg 2018-03-02 22:42:05 +00:00
main-efm32hg309-generic.c tests: gadget0: efm32hg: add gadget0 test for efm32hg 2018-03-02 22:42:05 +00:00
main-stm32f3-disco.c tests: gadget0: stm32f3: use library clock setups 2018-08-29 10:17:55 +00:00
main-stm32f4disco.c gadget0: f4: update to newest rcc api 2019-06-28 21:45:14 +00:00
main-stm32f072disco.c tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
main-stm32f103-generic.c tests: gadget0: stm32f1 hack should be consistent 2017-09-01 21:55:32 +00:00
main-stm32f429i-disco.c gadget0: f429: update to newest rcc api 2019-07-02 09:34:28 +00:00
main-stm32l1-generic.c gadget0: stm32l1: target the "hw1" test board explicitly 2018-04-14 18:40:54 +00:00
main-stm32l053disco.c tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00
main-tilm4f120xl.c tests: usb gadget0: ti: use dummy delay handlers 2018-08-27 15:51:17 +00:00
openocd.common.cfg tests: extract serials to optional local config 2016-02-28 17:47:28 +00:00
openocd.efm32hg309-generic.cfg tests: gadget0: efm32hg: add gadget0 test for efm32hg 2018-03-02 22:42:05 +00:00
openocd.stm32f3-disco.cfg tests: gadget0-f3: allow custom local stlink 2020-09-10 21:19:55 +00:00
openocd.stm32f4disco.cfg tests: extract serials to optional local config 2016-02-28 17:47:28 +00:00
openocd.stm32f072disco.cfg tests: extract serials to optional local config 2016-02-28 17:47:28 +00:00
openocd.stm32f103-generic.cfg tests: extract serials to optional local config 2016-02-28 17:47:28 +00:00
openocd.stm32f429i-disco.cfg tests: extract serials to optional local config 2016-02-28 17:47:28 +00:00
openocd.stm32l1-generic.cfg tests: extract serials to optional local config 2016-02-28 17:47:28 +00:00
openocd.stm32l053disco.cfg tests: extract serials to optional local config 2016-02-28 17:47:28 +00:00
stub.py tests: usb: gadget0 compatible interface (stm32f4) 2015-10-03 00:58:43 +00:00
test_gadget0.py trya nd make directories per 2020-09-10 21:19:55 +00:00
usb-gadget0.c usb gadget0: ctrl write/read loopback tests 2018-08-27 15:11:32 +00:00
usb-gadget0.h tests: gadget0: delay between calls to trigger races 2017-06-08 23:01:45 +00:00

README.md

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.
  • unittest-xml-reporting, only if running in CI mode. XX

Building the device firmware

There are Makefile.xxxxx files for all the currently tested targets.

make -f Makefile.stm32f4disco clean all V=1

The V=1 is optional, and turns on verbose mode, which can be useful if things don't work. This will give you a .elf file you can program using your own toolchain, but if you have a functional OpenOCD installed, then...

make -f Makefile.stm32f4disco clean all flash

Will handle flashing as well.

Setting up the test runner (using python virtual environments)

pyvenv .env  # ensures a python3 virtual env
. .env/bin/activate
pip install pyusb

If you have multiple test boards connected, have a look at opencd.common.cfg for some tips on selectively matching the right board. For people with just a single matching board, you don't need to do anything.

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

Access rights

On some systems (most linux systems) you probably won't have access to the usb vendor id being used/hijacked by the test cases. See 70-libopencm3.rules for installation instructions, or, if you have your own system, grant yourself access to the usb vid: 0xcafe

Running the tests

Below is an example of running the full suite of tests from the command line. The argument specifies the serial number to look for in the usb gadget, if you have more than one. No argument will the tests against all gadget-zero's found.

$ python test_gadget0.py
Running tests for DUT:  stm32f072disco
.........ss................
----------------------------------------------------------------------
Ran 27 tests in 0.388s

OK (skipped=2)

To be even more brutal, run this in a shell loop.

$ while true; do python test_gadget0.py -d stm32f072disco; done

You can also run individual tests, or individual sets of tests, see the unittest documentation for more information.

Many development environments, such as PyCharm can also be used to edit and run the tests, in whole or individually, with a nice visual test runner.