[LTP] [PATCH 10/19] testcases/lib: Add tst_flag2mask function

Luke Nowakowski-Krijger luke.nowakowskikrijger@canonical.com
Thu Apr 28 22:39:35 CEST 2022


This function exists in the older test.sh and should be added here so
that easy access can be made to map the flag to return values by
programs and vice versa.

Signed-off-by: Luke Nowakowski-Krijger <luke.nowakowskikrijger@canonical.com>
---
 testcases/lib/tst_test.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index d97df9ab4..245c78886 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -434,6 +434,19 @@ tst_require_kconfigs()
 	return 0
 }
 
+tst_flag2mask()
+{
+	case "$1" in
+	TPASS) return 0;;
+	TFAIL) return 1;;
+	TBROK) return 2;;
+	TWARN) return 4;;
+	TINFO) return 16;;
+	TCONF) return 32;;
+	*) tst_brk TBROK "Invalid res type '$1'";;
+	esac
+}
+
 tst_is_int()
 {
 	[ "$1" -eq "$1" ] 2>/dev/null
-- 
2.32.0



More information about the ltp mailing list