summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Peres <martin.peres@linux.intel.com>2016-01-30 17:06:40 +0200
committerMartin Peres <martin.peres@linux.intel.com>2016-01-30 17:08:10 +0200
commit2a6d4c26ae4c68885d7fcc1d259113aae78d79fa (patch)
tree3e3bb01b997d2a5db141e71910132ce445fca4b0
parent8a7374c7e7556747de0b6a64d5f448b954c59cf9 (diff)
core: make sure we set-up the exit function before parsing any user script
-rwxr-xr-xcore.sh56
1 files changed, 28 insertions, 28 deletions
diff --git a/core.sh b/core.sh
index 45df877..c6785e6 100755
--- a/core.sh
+++ b/core.sh
@@ -259,6 +259,34 @@ function read_git_version_deployed() {
return 1
}
+# 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!
+ __ezbench_reset_git_state__
+
+ # Execute the user-defined post hook
+ callIfDefined ezbench_post_hook
+
+ 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 __ezbench_finish__ EXIT
+trap __ezbench_finish__ INT # Needed for zsh
+
# Execute the user-defined pre hook
callIfDefined ezbench_pre_hook
@@ -301,34 +329,6 @@ for id in "$@"; do
commitList+=" "
done
-# 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!
- __ezbench_reset_git_state__
-
- # Execute the user-defined post hook
- callIfDefined ezbench_post_hook
-
- 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 __ezbench_finish__ EXIT
-trap __ezbench_finish__ INT # Needed for zsh
-
# Seed the results with the last round?
commitListLog="$logsFolder/commit_list"
last_commit=$(tail -1 "$commitListLog" 2>/dev/null | cut -f 1 -d ' ')