mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-16 07:05:14 +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)"
|
this_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
export repo_root_dir="$(cd "${this_script_dir}/../" && 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 directory used for storing various test-related artifacts.
|
||||||
KATA_TESTS_BASEDIR="${KATA_TESTS_BASEDIR:-/var/log/kata-tests}"
|
KATA_TESTS_BASEDIR="${KATA_TESTS_BASEDIR:-/var/log/kata-tests}"
|
||||||
|
|
||||||
@ -28,8 +30,36 @@ RUNTIME="${RUNTIME:-containerd-shim-kata-v2}"
|
|||||||
|
|
||||||
function die() {
|
function die() {
|
||||||
local msg="$*"
|
local msg="$*"
|
||||||
|
|
||||||
|
if [ -z "${KATA_TEST_VERBOSE:-}" ]; then
|
||||||
echo -e "[$(basename $0):${BASH_LINENO[0]}] ERROR: $msg" >&2
|
echo -e "[$(basename $0):${BASH_LINENO[0]}] ERROR: $msg" >&2
|
||||||
exit 1
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
function warn() {
|
function warn() {
|
||||||
|
Loading…
Reference in New Issue
Block a user