Skip to content

Commit

Permalink
adding serial id
Browse files Browse the repository at this point in the history
  • Loading branch information
xmos-jenkins committed Jun 14, 2024
1 parent 70bb03f commit c7a2595
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 7 additions & 5 deletions test/rtos_drivers/usb/check_usb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ DFU_RT_VID_PID=""
DFU_MODE_VID_PID="20b1:4000"
DFU_DOWNLOAD_BYTES=1024
DFU_ALT=1
DFU_SERIAL="123456"
DFU_VERBOSITY="-e" # Set to "-v -v -v" libusb debug prints.
APP_STARTUP_TIME_S=10
APP_SHUTDOWN_TIME_S=5
Expand Down Expand Up @@ -150,6 +151,7 @@ function wait_for_lsusb_entry {
}

function run_cdc_tests {
dfu-util --list
print_and_log_test_step "Writing CDC test data on both interfaces."
($TIMEOUT ${PY_TIMEOUT_S}s python3 "$REPO_ROOT/test/rtos_drivers/usb/serial_send_receive.py" -if0 "$SERIAL_TX0_FILE" -if1 "$SERIAL_TX1_FILE" -of0 "$SERIAL_RX0_FILE" -of1 "$SERIAL_RX1_FILE" 2>&1) >> "$HOST_REPORT"
exit_code=$?
Expand Down Expand Up @@ -184,33 +186,33 @@ function run_dfu_tests {
# First determine the state of the image currently on the target, then download
# the test image, and then read it back a final time to verify that it changed.
# Finally issue a DFU detach, to allow the device to terminate its application.

dfu-util --list # debug info
print_and_log_test_step "Reading DFU initial state of device's test partition."
dfu-util $DFU_VERBOSITY -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT -U "$FILE_PRE_DOWNLOAD" >> "$HOST_REPORT" 2>&1
dfu-util $DFU_VERBOSITY -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT --serial="$DFU_SERIAL" -U "$FILE_PRE_DOWNLOAD" >> "$HOST_REPORT" 2>&1
exit_code=$?
if [ $exit_code -ne 0 ]; then
print_and_log_failure "An error occurred during upload of pre-test image (exit code = $exit_code)."
return 1
fi

print_and_log_test_step "Writing DFU test image to target's test partition."
dfu-util $DFU_VERBOSITY -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT -D "$FILE_TO_DOWNLOAD" >> "$HOST_REPORT" 2>&1
dfu-util $DFU_VERBOSITY -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT --serial="$DFU_SERIAL" -D "$FILE_TO_DOWNLOAD" >> "$HOST_REPORT" 2>&1
exit_code=$?
if [ $exit_code -ne 0 ]; then
print_and_log_failure "An error occurred during download of test image (exit code = $exit_code)."
return 1
fi

print_and_log_test_step "Reading back DFU test image from the device's test partition."
dfu-util $DFU_VERBOSITY -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT -U "$FILE_POST_DOWNLOAD" >> "$HOST_REPORT" 2>&1
dfu-util $DFU_VERBOSITY -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT --serial="$DFU_SERIAL" -U "$FILE_POST_DOWNLOAD" >> "$HOST_REPORT" 2>&1
exit_code=$?
if [ $exit_code -ne 0 ]; then
print_and_log_failure "An error occurred during upload of post-test image (exit code = $exit_code)."
return 1
fi

print_and_log_test_step "Issuing DFU detach request."
dfu-util $DFU_VERBOSITY -e -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT >> "$HOST_REPORT" 2>&1
dfu-util $DFU_VERBOSITY -e -d "$DFU_RT_VID_PID,$DFU_MODE_VID_PID" -a $DFU_ALT --serial="$DFU_SERIAL" >> "$HOST_REPORT" 2>&1
exit_code=$?
if [ $exit_code -ne 0 ]; then
print_and_log_failure "An error occurred during DFU detach request (exit code = $exit_code)."
Expand Down
2 changes: 1 addition & 1 deletion test/rtos_drivers/usb/serial_send_receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def find_ports_by_vid_pid(rq=2, msg="COM ports missing"):
all_ports = serial.tools.list_ports.comports()
test_ports = [port for port in all_ports if port.vid == vid and port.pid == pid]
assert (len(test_ports) >= rq), msg
test_ports=test_ports[:rq]
test_ports=test_ports[0:rq] # TODO needs to be choosen more intelligently
return test_ports

def transfer_data(input_file, output_file, write_port, read_port, max_read_size):
Expand Down
9 changes: 8 additions & 1 deletion test/rtos_drivers/usb/test_verify_usb_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
host_test_results_filename = "testing/host.rpt"
host_test_regex = r"^\[TEST PASS\]:"

required_ports = 2

def test_results():
with open(target_test_results_filename, "r") as f:
cnt = 0
while 1:
line = f.readline()

if not line:
assert cnt == 2 # each tile should report PASS
# each tile should report PASS
assert cnt == required_ports, f"cnt = {cnt}"
break

p = re.match(target_test_regex, line)
Expand All @@ -39,3 +42,7 @@ def test_results():

if p:
cnt += 1


if __name__ == "__main__":
test_results() # manual debug

0 comments on commit c7a2595

Please sign in to comment.