automated: lib: modify check_return to support xfail
xfail tanslates to "expected failure". This implementation assumes that
exit code different than 0 means failure. The patch modifies
check_return to accept additional parameter "xfail". If the parameter is
set, exit code 0 will be considered "fail" and exit code different
than 0 will be considered "pass".
Signed-off-by: Milosz Wasilewski <milosz.wasilewski@oss.qualcomm.com>
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib
index bce0e71..0fa0d0e 100755
--- a/automated/lib/sh-test-lib
+++ b/automated/lib/sh-test-lib
@@ -102,15 +102,16 @@
check_return() {
# shellcheck disable=SC2039
local exit_code="$?"
- [ "$#" -ne 1 ] && error_msg "Usage: check_return test_case"
+ [ "$#" -lt 1 ] && error_msg "Usage: check_return test_case [xfail]"
# shellcheck disable=SC2039
local test_case="$1"
+ local xfail="${2:-}"
- if [ "${exit_code}" -ne 0 ]; then
- echo "${test_case} fail" | tee -a "${RESULT_FILE}"
+ if [ "${exit_code}" -ne 0 ] && [ -z "${xfail}" ]; then
+ report_fail "${test_case}"
return "${exit_code}"
else
- echo "${test_case} pass" | tee -a "${RESULT_FILE}"
+ report_pass "${test_case}"
return 0
fi
}