diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2020-12-11 13:25:44 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2020-12-11 13:25:44 +0000 |
commit | 7f1b5075acffcf0e711b07addf51c6e5d2e42274 (patch) | |
tree | bf6157aedd6d81746991df0b214d634e03b31579 | |
parent | 333123515e7d6ad9b5bb5eaa931249672170b1ee (diff) |
tcwg-benchmark.sh: Better structure code for rebooting and power-cycling
Change-Id: I711c726552dd0b96bb3790dd9d6114d3cedb289f
-rwxr-xr-x | tcwg-benchmark.sh | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/tcwg-benchmark.sh b/tcwg-benchmark.sh index 48680384..b9a29f9a 100755 --- a/tcwg-benchmark.sh +++ b/tcwg-benchmark.sh @@ -232,32 +232,40 @@ esac # Check that we can ssh to the board and rsync scripts. This ensures that # the board is online and filesystem is good condition. Try to reboot and/or # power-cycle the board as needed. -tries_left=2 +if $reboot; then + # 1. Try access after soft reboot + # 2. Try access after power-cycle + tries_left=2 +else + # 1. Try access without rebooting + # 2. Try access after soft reboot + # 3. Try access after power-cycle + tries_left=3 +fi force_power_cycle=false while [ $tries_left != 0 ]; do tries_left=$(($tries_left-1)) - if ! ssh "$boardname" true || $force_power_cycle; then - echo "Trying to power-cycle $boardname" - ( - nvidia-power-cycle.sh "${boardname%.tcwglab}" - wait_for_ssh_server "$boardname" 22 100 - ) & - wait $! || exit $EXTERNAL_FAIL - echo "Successfull powered-cycled $boardname" - reboot=false - fi - if $reboot; then - # Reboot the board - ssh $boardname sudo /sbin/reboot || true - # Wait until the ssh server is ready - sleep 30 # Give time to the board to shutdown - ret=0 - wait_for_ssh_server $boardname 22 100 || ret=$? - if [ $ret != 0 ]; then - echo "SSH server did not respond after reboot, exiting." - exit $EXTERNAL_FAIL + if ! ssh "$boardname" true || $force_power_cycle; then + echo "Trying to power-cycle $boardname" + ( + nvidia-power-cycle.sh "${boardname%.tcwglab}" + wait_for_ssh_server "$boardname" 22 100 + ) & + wait $! || exit $EXTERNAL_FAIL + echo "Successfully powered-cycled $boardname" + else + # Reboot the board + ssh $boardname sudo /sbin/reboot || true + # Wait until the ssh server is ready + sleep 30 # Give time to the board to shutdown + ret=0 + wait_for_ssh_server $boardname 22 100 || ret=$? + if [ $ret != 0 ]; then + echo "SSH server did not respond after reboot, exiting." + exit $EXTERNAL_FAIL + fi fi fi @@ -266,11 +274,14 @@ while [ $tries_left != 0 ]; do if [ $res = 0 ]; then break else - force_power_cycle=true + reboot=true + if [ x"$tries_left" = x"1" ]; then + force_power_cycle=true + fi fi done -if [ res != 0 ]; then +if [ $res != 0 ]; then echo "ERROR: Could not get board online" exit $EXTERNAL_FAIL fi |