From f594ddb39520e6bce4716120c419a9350686472d Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Mon, 8 May 2017 23:20:04 +0000 Subject: [PATCH] tests: gadget-zero: run against all attached targets Less command line arguments, more automatic "do what I mean" --- tests/gadget-zero/README.md | 6 ++++-- tests/gadget-zero/test_gadget0.py | 13 +++++++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/gadget-zero/README.md b/tests/gadget-zero/README.md index 8586de10..b22cc627 100644 --- a/tests/gadget-zero/README.md +++ b/tests/gadget-zero/README.md @@ -27,9 +27,11 @@ broken, and are awaiting code fixes, or are long running performance tests ## 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. +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 stm32f072disco +$ python test_gadget0.py Running tests for DUT: stm32f072disco .........ss................ ---------------------------------------------------------------------- diff --git a/tests/gadget-zero/test_gadget0.py b/tests/gadget-zero/test_gadget0.py index ec16f278..25e2fa2b 100644 --- a/tests/gadget-zero/test_gadget0.py +++ b/tests/gadget-zero/test_gadget0.py @@ -10,6 +10,8 @@ import unittest VENDOR_ID=0xcafe PRODUCT_ID=0xcafe +# you only need to worry about these if you are trying to explicitly test +# a single target. Normally, the test will autofind the attached target #DUT_SERIAL = "stm32f429i-disco" DUT_SERIAL = "stm32f4disco" #DUT_SERIAL = "stm32f103-generic" @@ -385,5 +387,12 @@ class TestUnaligned(unittest.TestCase): if __name__ == "__main__": if len(sys.argv) > 1: DUT_SERIAL = sys.argv.pop() - print("Running tests for DUT: ", DUT_SERIAL) - unittest.main() + print("Running tests for DUT: ", DUT_SERIAL) + unittest.main() + else: + # scan for available and try them all! + devs = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID, find_all=True) + for dev in devs: + DUT_SERIAL = dev.serial_number + print("Running tests for DUT: ", DUT_SERIAL) + unittest.main(exit=False)