diff mbox series

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

Message ID ce6c0683b6f053161fbb8b1469ad73e670e2d22f.1651176646.git.luke.nowakowskikrijger@canonical.com
State Changes Requested
Headers show
Series Expand Cgroup lib and modify controller tests | expand

Commit Message

Luke Nowakowski-Krijger April 28, 2022, 8:39 p.m. UTC
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(+)

Comments

Petr Vorel May 5, 2022, 8:01 a.m. UTC | #1
Hi Luke,

> 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.

FYI we deliberately didn't add tst_flag2mask into new shell API.
I'll post more comments on next patch where it is used.

Kind regards,
Petr
diff mbox series

Patch

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