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

Message ID 1533828226-24753-3-git-send-email-alexey.kodanev@oracle.com
State New
Headers show
Series
  • [RFC,1/4] lib/tst_test.c: add 'needs_drivers' option with tst_check_drivers cmd
Related show

Commit Message

Alexey Kodanev Aug. 9, 2018, 3:23 p.m.
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>
---
 testcases/lib/tst_test.sh |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

Comments

Petr Vorel Aug. 14, 2018, 6:39 p.m. | #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>
Acked-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/tst_test.sh |   16 ++++++++++++++++
>  1 files changed, 16 insertions(+), 0 deletions(-)


Kind regards,
Petr

Patch

diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
index 30f75b5..73dcdfb 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"