From 4306f85ff5e4a6f555c492ae3909a25fab5aff10 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Mon, 31 Aug 2020 16:02:00 -0700 Subject: [PATCH] cicd: Support capturing bugcheck output on openwrt systems. Signed-off-by: Ben Greear --- gui/basic_regression.bash | 11 +++++++++++ openwrt_ctl.py | 28 ++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/gui/basic_regression.bash b/gui/basic_regression.bash index 935a40da..ee3c1d52 100755 --- a/gui/basic_regression.bash +++ b/gui/basic_regression.bash @@ -137,6 +137,17 @@ function post_test { pkill -f ".*openwrt_ctl.*$AP_SERIAL.*" mv $DUT_SER_LOG $DEST/logs/dut_console_log.txt + # Look for firmware crash files + PIDD=$$ + ../openwrt_ctl.py $OWRTCTL_ARGS --tty $AP_SERIAL --scheme serial --action cmd --value "tar -cvzf /tmp/bugcheck.tgz /tmp/bugcheck" + ../openwrt_ctl.py $OWRTCTL_ARGS --tty $AP_SERIAL --scheme serial --action upload --value "/tmp/bugcheck.tgz" --value2 "lanforge\@$ap_gw:bugcheck-$PIDD.tgz" + + # Grab the file from LANforge + scp lanforge\@$LFMANAGER:bugcheck-$PIDD.tgz $DEST/logs/bugcheck.tgz + + # Clean log file + ssh lanforge\@$LFMANAGER "rm bugcheck-$PIDD.tgz" + # detect a few fatal flaws and reqest AP restart if found. grep "Hardware became unavailable" $DEST/logs/dut_console_log.txt && reboot_dut fi diff --git a/openwrt_ctl.py b/openwrt_ctl.py index ac0ef20f..182742b6 100755 --- a/openwrt_ctl.py +++ b/openwrt_ctl.py @@ -48,7 +48,7 @@ def usage(): print("--prompt Prompt to look for when commands are done (default: root@OpenWrt)") print("-s|--scheme (serial|telnet|ssh): connect via serial, ssh or telnet") print("-l|--log file log messages here") - print("--action (logread | journalctl | lurk | sysupgrade | download | reboot | cmd") + print("--action (logread | journalctl | lurk | sysupgrade | download | upload | reboot | cmd") print("--value (option to help complete the action") print("--value2 (option to help complete the action, dest filename for download") print("-h|--help") @@ -78,7 +78,7 @@ def main(): parser.add_argument("-t", "--tty", type=str, help="tty serial device") parser.add_argument("-l", "--log", type=str, help="logfile for messages, stdout means output to console") parser.add_argument("--action", type=str, help="perform action", - choices=["logread", "journalctl", "lurk", "sysupgrade", "download", "reboot", "cmd" ]) + choices=["logread", "journalctl", "lurk", "sysupgrade", "download", "upload", "reboot", "cmd" ]) parser.add_argument("--value", type=str, help="set value") parser.add_argument("--value2", type=str, help="set value2") tty = None @@ -267,6 +267,30 @@ def main(): egg.expect(CCPROMPT, timeout=20) return + if (args.action == "upload"): + command = "scp %s %s"%(args.value, args.value2) + logg.info("Command[%s]"%command) + egg.sendline(command); + + i = egg.expect(["password:", "Do you want to continue connecting", "Network unreachable"], timeout=5) + if i == 2: + print("Network unreachable, wait 15 seconds and try again.") + time.sleep(15) + command = "scp /tmp/%s %s"%(args.value, args.value2) + logg.info("Command[%s]"%command) + egg.sendline(command); + + i = egg.expect(["password:", "Do you want to continue connecting", "Network unreachable"], timeout=5) + if i == 2: + print("ERROR: Could not connect to LANforge to put upload file") + exit(2) + if i == 1: + egg.sendline("y") + egg.expect("password:", timeout=5) + egg.sendline("lanforge") + egg.expect(CCPROMPT, timeout=20) + return + if (command is None): logg.info("No command specified, going to log out.") else: