From 1eb8138e493fa772f6398f89fbf6a93f36ff1fa4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9C=A4=ED=98=84=EC=8B=9D/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 14 Nov 2019 16:09:21 +0900 Subject: [PATCH] [dredd] applying error handling code to runner.sh (#8935) * [dredd] applying error handling code to runner.sh This applies error handling code into runner.sh that was applied in #8888, #8910 Signed-off-by: Hyun Sik Yoon * change comment --- compiler/tf2circle-dredd-pb-test/runner.sh | 17 ++++++++++++++--- compiler/tf2circle-dredd-pbtxt-test/runner.sh | 17 ++++++++++++++--- compiler/tf2tflite-dredd-pb-test/runner.sh | 17 ++++++++++++++--- compiler/tf2tflite-dredd-pbtxt-test/runner.sh | 2 +- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/compiler/tf2circle-dredd-pb-test/runner.sh b/compiler/tf2circle-dredd-pb-test/runner.sh index 5745db1..7c7b123 100755 --- a/compiler/tf2circle-dredd-pb-test/runner.sh +++ b/compiler/tf2circle-dredd-pb-test/runner.sh @@ -2,6 +2,9 @@ # This script checks circle file generated by tf2circle +# exit if unknown var is used +set -u + WORKDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # Need at least toolchain.config @@ -76,15 +79,23 @@ while [[ $# -ne 0 ]]; do COMPILED_FILE=${CIRCLE_PATH} INSPECT_PROG_PATH=${CIRCLE_INSPECT_PATH} VERIFY_PROG_PATH=${CIRCLE_VERIFY_PATH} + ERROR_LOG="${PREFIX}.error" + + rm -f "${ERROR_LOG}" + + # in case error while running ${MODEL_RULE_PATH}, prints error msg + trap 'echo "** ERROR **" ; cat "${ERROR_LOG}"' ERR source rule-lib.sh source "${MODEL_RULE_PATH}" + # unset + trap - ERR set -x - if [[ $? -eq 0 ]]; then - touch "${PASSED_TAG}" - fi + # At this point, the exit code of all commands is 0 + # If not 0, execution of this script ends because of "set -e" + touch "${PASSED_TAG}" ) if [[ -f "${PASSED_TAG}" ]]; then diff --git a/compiler/tf2circle-dredd-pbtxt-test/runner.sh b/compiler/tf2circle-dredd-pbtxt-test/runner.sh index 5745db1..7c7b123 100755 --- a/compiler/tf2circle-dredd-pbtxt-test/runner.sh +++ b/compiler/tf2circle-dredd-pbtxt-test/runner.sh @@ -2,6 +2,9 @@ # This script checks circle file generated by tf2circle +# exit if unknown var is used +set -u + WORKDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # Need at least toolchain.config @@ -76,15 +79,23 @@ while [[ $# -ne 0 ]]; do COMPILED_FILE=${CIRCLE_PATH} INSPECT_PROG_PATH=${CIRCLE_INSPECT_PATH} VERIFY_PROG_PATH=${CIRCLE_VERIFY_PATH} + ERROR_LOG="${PREFIX}.error" + + rm -f "${ERROR_LOG}" + + # in case error while running ${MODEL_RULE_PATH}, prints error msg + trap 'echo "** ERROR **" ; cat "${ERROR_LOG}"' ERR source rule-lib.sh source "${MODEL_RULE_PATH}" + # unset + trap - ERR set -x - if [[ $? -eq 0 ]]; then - touch "${PASSED_TAG}" - fi + # At this point, the exit code of all commands is 0 + # If not 0, execution of this script ends because of "set -e" + touch "${PASSED_TAG}" ) if [[ -f "${PASSED_TAG}" ]]; then diff --git a/compiler/tf2tflite-dredd-pb-test/runner.sh b/compiler/tf2tflite-dredd-pb-test/runner.sh index e44d5be..4eef372 100755 --- a/compiler/tf2tflite-dredd-pb-test/runner.sh +++ b/compiler/tf2tflite-dredd-pb-test/runner.sh @@ -2,6 +2,9 @@ # This script checks tflite file generated by tf2tflite +# exit if unknown var is used +set -u + WORKDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) # Need at least toolchain.config @@ -76,15 +79,23 @@ while [[ $# -ne 0 ]]; do COMPILED_FILE=${TFLITE_PATH} INSPECT_PROG_PATH=${TFL_INSPECT_PATH} VERIFY_PROG_PATH=${TFL_VERIFY_PATH} + ERROR_LOG="${PREFIX}.error" + + rm -f "${ERROR_LOG}" + + # in case error while running ${MODEL_RULE_PATH}, prints error msg + trap 'echo "** ERROR **" ; cat "${ERROR_LOG}"' ERR source rule-lib.sh source "${MODEL_RULE_PATH}" + # unset + trap - ERR set -x - if [[ $? -eq 0 ]]; then - touch "${PASSED_TAG}" - fi + # At this point, the exit code of all commands is 0 + # If not 0, execution of this script ends because of "set -e" + touch "${PASSED_TAG}" ) if [[ -f "${PASSED_TAG}" ]]; then diff --git a/compiler/tf2tflite-dredd-pbtxt-test/runner.sh b/compiler/tf2tflite-dredd-pbtxt-test/runner.sh index 75a8ad7..8575bc2 100755 --- a/compiler/tf2tflite-dredd-pbtxt-test/runner.sh +++ b/compiler/tf2tflite-dredd-pbtxt-test/runner.sh @@ -89,7 +89,7 @@ while [[ $# -ne 0 ]]; do source rule-lib.sh source "${MODEL_RULE_PATH}" - # unset trap and set +x + # unset trap - ERR set -x -- 2.7.4