From 22fadd104afbf3abfdccbbcc989d0809f27bfb4a Mon Sep 17 00:00:00 2001 From: Naresh Kamboju Date: Wed, 7 Sep 2016 21:24:17 +0530 Subject: linux: Adding increment_return_status Signed-off-by: Naresh Kamboju --- automated/lib/sh-test-lib | 6 ++++++ automated/linux/usb/usb-test-basic.sh | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib index fca1153..8cbb931 100755 --- a/automated/lib/sh-test-lib +++ b/automated/lib/sh-test-lib @@ -55,6 +55,12 @@ check_return() { fi } +increment_return_status() { + local exit_code="$?" + [ "$#" -ne 1 ] && error_msg "Usage: increment_return_status value" + local value="$1" + return $(expr $exit_code + $value) +} add_metric() { if [ "$#" -ne 4 ]; then warn_msg "The number of parameters less then 4" diff --git a/automated/linux/usb/usb-test-basic.sh b/automated/linux/usb/usb-test-basic.sh index 9b834c6..a8360ab 100755 --- a/automated/linux/usb/usb-test-basic.sh +++ b/automated/linux/usb/usb-test-basic.sh @@ -25,6 +25,7 @@ . ../../lib/sh-test-lib OUTPUT="$(pwd)/output" RESULT_FILE="${OUTPUT}/result.txt" +RET=0 usage() { echo "Usage: $0 [-s ]" 1>&2 @@ -60,9 +61,15 @@ examine_all_usb_devices() { echo "=======================================" echo "lsusb -D "${USB_BUS}""${bus}"/"${device}"" lsusb -D "${USB_BUS}""${bus}"/"${device}" + increment_return_status $RET + RET=$? done done - echo "examine_all_usb_devices pass" | tee -a "${RESULT_FILE}" + if [ $RET -ne 0 ]; then + echo "examine_all_usb_devices fail" | tee -a "${RESULT_FILE}" + else + echo "examine_all_usb_devices pass" | tee -a "${RESULT_FILE}" + fi else echo "examine_all_usb_devices fail" | tee -a "${RESULT_FILE}" fi -- cgit v1.2.3