mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-14 06:06:12 +00:00
scripts: Add an enhanced die function
This PR adds an enhanced die function in order to dump more information in a yaml format that will help with the debugging. Fixes #9105 Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com>
This commit is contained in:
parent
61ce7455c5
commit
43a46d5a6b
@ -10,6 +10,8 @@
|
||||
this_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
export repo_root_dir="$(cd "${this_script_dir}/../" && pwd)"
|
||||
|
||||
source "${this_script_dir}/error.sh"
|
||||
|
||||
# Kata tests directory used for storing various test-related artifacts.
|
||||
KATA_TESTS_BASEDIR="${KATA_TESTS_BASEDIR:-/var/log/kata-tests}"
|
||||
|
||||
@ -28,7 +30,35 @@ RUNTIME="${RUNTIME:-containerd-shim-kata-v2}"
|
||||
|
||||
function die() {
|
||||
local msg="$*"
|
||||
echo -e "[$(basename $0):${BASH_LINENO[0]}] ERROR: $msg" >&2
|
||||
|
||||
if [ -z "${KATA_TEST_VERBOSE:-}" ]; then
|
||||
echo -e "[$(basename $0):${BASH_LINENO[0]}] ERROR: $msg" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo >&2 "ERROR: $msg"
|
||||
|
||||
# This function is called to indicate a fatal error occurred, so
|
||||
# the caller of this function is the site of the detected error.
|
||||
local error_location
|
||||
error_location=$(caller 0)
|
||||
|
||||
local line
|
||||
local func
|
||||
local file
|
||||
|
||||
line=$(echo "$error_location"|awk '{print $1}')
|
||||
func=$(echo "$error_location"|awk '{print $2}')
|
||||
file=$(echo "$error_location"|awk '{print $3}')
|
||||
|
||||
local path
|
||||
path=$(resolve_path "$file")
|
||||
|
||||
dump_details \
|
||||
"${line}" \
|
||||
"${func}" \
|
||||
"${path}"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user