Files
pqAutomationApp/docs/UCD-API文档/examples/work_with_tests_from_file.py

44 lines
1.4 KiB
Python
Raw Permalink Normal View History

2026-07-02 17:16:18 +08:00
#
# Import UniTAP module.
#
import UniTAP
#
# To initialize UniTAP library wrapper user should create UniTAP.TsiLib() object.
#
lUniTAP = UniTAP.TsiLib()
#
# For opening device, please, put serial number of the device as 8 symbol str or put index of device.
#
# dev = lUniTAP.open("NNNNNNNN")
dev = lUniTAP.open(0)
# After opening device as in UCD Console device role should be selected.
role = dev.select_role(UniTAP.dev.UCD400.DPSourceDPSink)
# role = dev.select_role(UniTAP.dev.UCD500.DPSourceDPSink)
dev.opf_handler = UniTAP.OpfHandlerInternal(port_tx=role.dptx, port_rx=role.dprx)
file_name = "./config.json"
group_id, test_id, params = role.dut_tests.get_params_from_file(file_name)
role.dut_tests.run(group_id=group_id, test_id=test_id, params=params) # Run selected test
results = role.dut_tests.get_all_tests_results() # Get results after testing
role.dptx.event_capturer.stop() # Stop event capturing
# Save test result to HTML report
role.dut_tests.make_report('./report',
tested_by="Example",
remarks="Remarks for test report.")
#
# Since the 3.5 version, TsiLib and TSIDevice objects have the option to be closed earlier.
# TSIDevice can be closed with the TsiLib method close(). TsiLib can be closed with cleanup().
# Clean up will close all opened devices and block ability to open any devices
# with same TsiLib object.
#
lUniTAP.close(dev)
lUniTAP.cleanup()