@@ -1639,154 +1639,3 @@ def get_descriptor(dev, type_index, lang_id, length):
1639
1639
ret = dev .ctrl_transfer (request_type , request , value , index , length )
1640
1640
1641
1641
return ret
1642
-
1643
-
1644
- """
1645
- For documentation purpose until test writing finished
1646
- TODO: remove this if not needed anymore
1647
-
1648
-
1649
- def test_device(serial_number, log=print):
1650
- dev = usb.core.find(custom_match=TestMatch(serial_number))
1651
- if dev is None:
1652
- log("Device not found")
1653
- return
1654
-
1655
- ## --Control Tests-- ##
1656
- #control_basic_test(dev, log)
1657
- # Test control IN/OUT/NODATA
1658
- control_stall_test(dev, log)
1659
- # Invalid control in/out/nodata requests are stalled
1660
- # Stall during different points in the control transfer
1661
- #control_sizes_test(dev, log)
1662
- # Test control requests of various data stage sizes (1,8,16,32,64,255,256,...)
1663
- control_stress_test(dev, log)
1664
- # normal and delay mode
1665
-
1666
- ## --Endpoint test-- ##
1667
- #for each endpoint
1668
- #-test all allowed wMaxPacketSize sizes and transfer types
1669
- #-stall tests
1670
- #-set/clear stall control request
1671
- #-stall at random points of sending/receiveing data
1672
- #-test aborting an in progress transfer
1673
- #test as many endpoints at once as possible
1674
- #test biggest configuration possible
1675
-
1676
- ## --physical test-- ##
1677
- #-reset notification/handling
1678
- #-connect/disconnect tests - have device disconnect and then reconnect
1679
- #-disconnect during various phases of control transfers and endpoint transfers
1680
- #-suspend/resume tests (may not be possible to test with current framework)
1681
- #-suspend/resume notifications
1682
-
1683
- ## -- Stress tests-- ##
1684
- #-concurrent tests (all endpoints at once including control)
1685
- #-concurrent tests + reset + delay
1686
-
1687
- ## -- other tests-- ##
1688
- #-report throughput for in/out of control, bulk, interrupt and iso transfers
1689
- #-verify that construction/destruction repeatedly works gracefully
1690
-
1691
- intf = get_interface(dev, 0, 0)
1692
-
1693
- # Find endpoints
1694
- bulk_in = None
1695
- bulk_out = None
1696
- int_in = None
1697
- int_out = None
1698
-
1699
- for endpoint in intf:
1700
- log("Processing endpoint %s" % endpoint)
1701
- ep_type = endpoint.bmAttributes & 0x3
1702
- if ep_type == 2:
1703
- if endpoint.bEndpointAddress & 0x80:
1704
- assert bulk_in is None
1705
- bulk_in = endpoint
1706
- else:
1707
- assert bulk_out is None
1708
- bulk_out = endpoint
1709
- elif ep_type == 3:
1710
- if endpoint.bEndpointAddress & 0x80:
1711
- assert int_in is None
1712
- int_in = endpoint
1713
- else:
1714
- assert int_out is None
1715
- int_out = endpoint
1716
- assert bulk_in is not None
1717
- assert bulk_out is not None
1718
- assert int_in is not None
1719
- assert int_out is not None
1720
- bulk_out.write("hello" + "x" *256);
1721
- int_out.write("world" + "x" *256);
1722
-
1723
- dev.set_interface_altsetting(0, 1)
1724
-
1725
- intf = get_interface(dev, 0, 0)
1726
-
1727
- # Find endpoints
1728
- bulk_in = None
1729
- bulk_out = None
1730
- int_in = None
1731
- int_out = None
1732
-
1733
- for endpoint in intf:
1734
- log("Processing endpoint %s" % endpoint)
1735
- ep_type = endpoint.bmAttributes & 0x3
1736
- if ep_type == 2:
1737
- if endpoint.bEndpointAddress & 0x80:
1738
- assert bulk_in is None
1739
- bulk_in = endpoint
1740
- else:
1741
- assert bulk_out is None
1742
- bulk_out = endpoint
1743
- elif ep_type == 3:
1744
- if endpoint.bEndpointAddress & 0x80:
1745
- assert int_in is None
1746
- int_in = endpoint
1747
- else:
1748
- assert int_out is None
1749
- int_out = endpoint
1750
- assert bulk_in is not None
1751
- assert bulk_out is not None
1752
- assert int_in is not None
1753
- assert int_out is not None
1754
- bulk_out.write("hello2" + "x" *256);
1755
- int_out.write("world2" + "x" *256);
1756
-
1757
-
1758
- t = Thread(target=write_data, args=(bulk_out,))
1759
- t.start()
1760
-
1761
- for _ in range(10):
1762
- request_type = build_request_type(CTRL_OUT, CTRL_TYPE_VENDOR,
1763
- CTRL_RECIPIENT_DEVICE)
1764
- request = VENDOR_TEST_CTRL_NONE_DELAY
1765
- value = 0 # Always 0 for this request
1766
- index = 0 # Communication interface
1767
- length = 0 # No data
1768
- dev.ctrl_transfer(request_type, request, value, index, length, 5000)
1769
-
1770
- t.join()
1771
-
1772
-
1773
- def write_data(pipe):
1774
- print("Write data running")
1775
- count = 0
1776
- for _ in range(40):
1777
- pipe.write("Value is %s" % count)
1778
- count += 1
1779
- print("Count %s" % count)
1780
- time.sleep(0.5)
1781
-
1782
-
1783
- def main():
1784
- parser = ArgumentParser(description="USB basic test")
1785
- parser.add_argument('serial', help='USB serial number of DUT')
1786
- args = parser.parse_args()
1787
- ret = test_device(args.serial)
1788
- print("Test %s" % "passed" if ret else "failed")
1789
-
1790
- if __name__ == "__main__":
1791
- main()
1792
- """
0 commit comments