diff options
-rwxr-xr-x | automated/lib/sh-test-lib | 6 | ||||
-rwxr-xr-x | automated/linux/usb/usb-test-basic.sh | 9 |
2 files changed, 14 insertions, 1 deletions
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 <true>]" 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 |