Jenkins: HIL improve run_tests.py and run_nsh_cmd.py helper

- switch to python3
 - run_nsh_cmd.py return error if command fails
 - decrease timeout in checking for output
 - Jenkins hardware tests tolerate certain command failures that aren't available on all boards (flash constrained, etc)
This commit is contained in:
Daniel Agar
2020-11-10 22:45:50 -05:00
committed by GitHub
parent ea09d9ebbf
commit 3924792c20
4 changed files with 159 additions and 178 deletions

View File

@@ -1,4 +1,4 @@
#! /usr/bin/python
#! /usr/bin/env python3
import serial, time
import subprocess
@@ -10,7 +10,7 @@ def monitor_firmware_upload(port, baudrate):
databits = serial.EIGHTBITS
stopbits = serial.STOPBITS_ONE
parity = serial.PARITY_NONE
ser = serial.Serial(port, baudrate, databits, parity, stopbits, timeout=10)
ser = serial.Serial(port, baudrate, databits, parity, stopbits, timeout=1)
finished = 0
@@ -19,8 +19,9 @@ def monitor_firmware_upload(port, baudrate):
timeout_newline = time.time()
while finished == 0:
serial_line = ser.readline()
print(serial_line.replace('\n',''))
serial_line = ser.readline().decode("utf-8", errors='ignore')
if (len(serial_line) > 0):
print(serial_line.replace('\n', ''))
if "NuttShell (NSH)" in serial_line:
finished = 1
@@ -36,16 +37,17 @@ def monitor_firmware_upload(port, baudrate):
finished = 1
break
# newline every 30 seconds if still running
if time.time() - timeout_newline > 30:
ser.write('\n')
# newline every 10 seconds if still running
if time.time() - timeout_newline > 10:
timeout_newline = time.time()
ser.write('\n'.encode("utf-8"))
ser.flush()
ser.close()
def main():
parser = ArgumentParser(description=__doc__)
parser.add_argument('--device', "-d", nargs='?', default = None, help='')
parser.add_argument('--device', "-d", nargs='?', default=None, help='', required=True)
parser.add_argument("--baudrate", "-b", dest="baudrate", type=int, help="Mavlink port baud rate (default=57600)", default=57600)
args = parser.parse_args()