diff mbox series

[v2,3/4] lib/tst_test.sh: add TST_RTNL_CHK() helper function

Message ID 1534764229-26993-3-git-send-email-alexey.kodanev@oracle.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series [v2,1/4] lib/tst_test.c: add 'needs_drivers' option with tst_check_drivers cmd | expand

Commit Message

Alexey Kodanev Aug. 20, 2018, 11:23 a.m. UTC
It should parse iproute commands output and exit the test with TCONF
if there are certain messages returned from iproute/RTNETLINK.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
v2: no changes

 testcases/lib/tst_test.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

Comments

Petr Vorel Sept. 13, 2018, 1 p.m. UTC | #1
Hi Alexey,

> It should parse iproute commands output and exit the test with TCONF
> if there are certain messages returned from iproute/RTNETLINK.

> Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
> ---
> v2: no changes

Merged your patch to have it for the release.
Thanks a lot!


Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 23d66eb..6837eb1 100644
--- a/testcases/lib/tst_test.sh
+++ b/testcases/lib/tst_test.sh
@@ -202,6 +202,22 @@  TST_RETRY_FUNC()
 	return $2
 }
 
+TST_RTNL_CHK()
+{
+	local msg1="RTNETLINK answers: Function not implemented"
+	local msg2="RTNETLINK answers: Operation not supported"
+	local output="$($@ 2>&1 || echo 'LTP_ERR')"
+	local msg
+
+	echo "$output" | grep -q "LTP_ERR" || return 0
+
+	for msg in "$msg1" "$msg2"; do
+		echo "$output" | grep -q "$msg" && tst_brk TCONF "'$@': $msg"
+	done
+
+	tst_brk TBROK "$@ failed: $output"
+}
+
 tst_umount()
 {
 	local device="$1"