From 513be212d9ee71dfb6efe1c8d3ff49a9f8eaf4ee Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 24 Aug 2012 14:24:12 -0400 Subject: [PATCH] signer scripts: include debug output when we fail When checking kernel params fail, it's useful to know all the variables as to what it's doing. So dump some state when an error occurs. BRANCH=None BUG=None TEST=ran `ensure_secure_kernelparams.sh` on a bad image and saw useful output TEST=ran `ensure_secure_kernelparams.sh` on a good image and saw no output Change-Id: I0e499f87a6d8feed80da72aba75e1e6c1b4076c9 Reviewed-on: https://gerrit.chromium.org/gerrit/31355 Reviewed-by: David McMahon Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- .../ensure_secure_kernelparams.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/image_signing/ensure_secure_kernelparams.sh b/scripts/image_signing/ensure_secure_kernelparams.sh index 52a3ce995a..1eb4364b45 100755 --- a/scripts/image_signing/ensure_secure_kernelparams.sh +++ b/scripts/image_signing/ensure_secure_kernelparams.sh @@ -57,6 +57,8 @@ main() { # So, any time we find one, we set testfail=1 and continue. # When finished we will use testfail to determine our exit value. local testfail=0 + # A buffer to include useful information that we dump when things fail. + local output if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then usage @@ -92,13 +94,26 @@ main() { eval "optional_kparams=(\${optional_kparams_$board[@]})" eval "optional_kparams_regex=(\${optional_kparams_regex_$board[@]})" eval "required_dmparams=(\"\${required_dmparams_$board[@]}\")" + output+="required_kparams=(\n" + output+="$(printf "\t'%s'\n" "${required_kparams[@]}")\n)\n" + output+="optional_kparams=(\n" + output+="$(printf "\t'%s'\n" "${optional_kparams[@]}")\n)\n" + output+="optional_kparams_regex=(\n" + output+="$(printf "\t'%s'\n" "${optional_kparams_regex[@]}")\n)\n" + output+="required_dmparams=(\n" + output+="$(printf "\t'%s'\n" "${required_dmparams[@]}")\n)\n" # Divide the dm params from the rest and process seperately. local kparams=$(dump_kernel_config "$kernelblob") local dmparams=$(get_dmparams "$kparams") local kparams_nodm=$(kparams_remove_dm "$kparams") + output+="\nkparams='${kparams}'\n" + output+="\ndmparams='${dmparams}'\n" + output+="\nkparams_nodm='${kparams_nodm}'\n" + mangled_dmparams=$(dmparams_mangle "${dmparams}") + output+="\nmangled_dmparams='${mangled_dmparams}'\n" # Special-case handling of the dm= param: for expected_dmparams in "${required_dmparams[@]}"; do # Filter out all dynamic parameters. @@ -146,6 +161,12 @@ main() { testfail=1 fi + if [[ ${testfail} -eq 1 ]]; then + echo "Debug output:" + printf '%b\n' "${output}" + echo "(actual error will be at the top of output)" + fi + exit $testfail }