diff options
author | Martin Peres <martin.peres@linux.intel.com> | 2016-01-19 18:32:36 +0200 |
---|---|---|
committer | Martin Peres <martin.peres@linux.intel.com> | 2016-01-20 12:20:10 +0200 |
commit | 806c1fc3f45fc6a89b4006519cd866c8aefd9c4f (patch) | |
tree | 3ad25c3a6896fd65f9dc8d15a8da796d389d0b29 | |
parent | 1bf9a06e6b8f0f227e9ddfadc2ab8309cd60f31b (diff) |
core: handle reboots more cleanly
-rwxr-xr-x | core.sh | 43 | ||||
-rw-r--r-- | profiles.d/kernel/profile | 4 | ||||
-rw-r--r-- | utils/ezbench.py | 1 |
3 files changed, 35 insertions, 13 deletions
@@ -51,6 +51,7 @@ # - 71: Compilation failed # - 72: Deployment failed # - 73: The deployed version does not match the wanted version +# - 74: A reboot is necessary # # Tests: # - 100: At least one test does not exist @@ -300,23 +301,33 @@ for id in "$@"; do commitList+=" " done -# function to call on exit -function finish { +# functions to call on exit +function __ezbench_reset_git_state__ { + git reset --hard "$commit_head" 2> /dev/null + [ -n "$stash" ] && git stash apply "$stash" > /dev/null +} + +function __ezbench_finish__ { exitcode=$? + action=$1 # to be executed on exit, possibly twice! - git reset --hard "$commit_head" 2> /dev/null - [ -n "$stash" ] && git stash apply "$stash" > /dev/null + __ezbench_reset_git_state__ # Execute the user-defined post hook callIfDefined ezbench_post_hook - printf "Exiting with error code $exitcode\n" - - exit $exitcode + if [ "$action" == "reboot" ] + then + printf "Rebooting with error code $exitcode\n" + sudo reboot + else + printf "Exiting with error code $exitcode\n" + exit $exitcode + fi } -trap finish EXIT -trap finish INT # Needed for zsh +trap __ezbench_finish__ EXIT +trap __ezbench_finish__ INT # Needed for zsh # Seed the results with the last round? commitListLog="$logsFolder/commit_list" @@ -477,11 +488,18 @@ function compile_and_deploy { compile_start=$(date +%s) eval "$makeAndDeployCmd" > "$compile_logs" 2>&1 local exit_code=$? - printf "Exiting with error code $exit_code\n" >> "$compile_logs" compile_end=$(date +%s) + # The exit code 74 actually means everything is fine but we need to reboot + if [ $exit_code -eq 74 ] + then + printf "Exiting with error code 0\n" >> "$compile_logs" + else + printf "Exiting with error code $exit_code\n" >> "$compile_logs" + fi + # Reset to the original commit early - git reset --hard "$commit_head" 2> /dev/null + __ezbench_reset_git_state__ # Call the user-defined post-compile hook callIfDefined compile_post_hook @@ -493,6 +511,9 @@ function compile_and_deploy { component="Compilation" elif [ $exit_code -eq 72 ]; then component="Deployment" + elif [ $exit_code -eq 74 ]; then + $?=$exit_code + __ezbench_finish__ "reboot" else exit_code=70 fi diff --git a/profiles.d/kernel/profile b/profiles.d/kernel/profile index 96d55de..855de13 100644 --- a/profiles.d/kernel/profile +++ b/profiles.d/kernel/profile @@ -54,8 +54,8 @@ function __default_make_and_deploy__() { [ "$compile_error" -ne 0 ] && return $compile_error - # Here we go, reboot on the new kernel! - sudo reboot + # Return that a reboot is necessary + return 74 } function __git_version_deployed__() { diff --git a/utils/ezbench.py b/utils/ezbench.py index efe4e94..2b917c5 100644 --- a/utils/ezbench.py +++ b/utils/ezbench.py @@ -60,6 +60,7 @@ class EzbenchExitCode(Enum): COMPILATION_FAILED = 71 DEPLOYMENT_FAILED = 72 DEPLOYMENT_ERROR = 73 + REBOOT_NEEDED = 74 TEST_INVALID_NAME = 100 UNK_ERROR = 255 |