On 12/22/25 20:48, Aleksei Oladko wrote:
In some forwarding tests, it is necessary to check for features or
specific keywords in command output before proceeding.

Introduce the run_cmd_grep helper in lib.sh. This helper executes a
command and searches for a specific pattern in its output.

https://virtuozzo.atlassian.net/browse/VSTOR-121418

Signed-off-by: Aleksei Oladko <[email protected]>
---
  tools/testing/selftests/net/forwarding/lib.sh | 20 +++++++++++++++++++
  1 file changed, 20 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh 
b/tools/testing/selftests/net/forwarding/lib.sh
index 7f22496bfdf9..36fadf71fcd8 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -2314,3 +2314,23 @@ has_unicast_flt()
[[ $promisc == 1 ]] && echo "no" || echo "yes"
  }
+
+run_cmd_grep_common()
+{
+       local find="$1"; shift
+       local cmd="$*"
+       local out
redundant var

+               echo "COMMAND: ${cmd} 2>&1 | grep -q '${find}'"

redundant line?

+       if [ "$VERBOSE" = "1" ]; then
+               echo "COMMAND: ${cmd} 2>&1 | grep -q '${find}'"
+       fi
+       out=$($cmd 2>&1 | grep -q "${find}" 2>&1)

"out" is not used (and "grep -q" won't print anything anyway), to be dropped?

+       return $?
+}
+
+run_cmd_grep() {
+       run_cmd_grep_common "$@"
+       rc=$?
+       check_err $rc
+       return $rc
+}

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to