[Devel] [PATCH RHEL10 COMMIT] selftests: net: forwarding: add run_cmd_grep helper for feature probing

Konstantin Khorenko khorenko at virtuozzo.com
Tue Dec 23 16:42:32 MSK 2025


The commit is pushed to "vz10.kselftest.net-forwarding" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-55.13.1.3.26.vz10
------>
commit bff6df841084f15437c5a00faf5fa1b26a2aa1fc
Author: Aleksei Oladko <aleksey.oladko at virtuozzo.com>
Date:   Mon Dec 22 19:48:41 2025 +0000

    selftests: net: forwarding: add run_cmd_grep helper for feature probing
    
    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 <aleksey.oladko at virtuozzo.com>
---
 tools/testing/selftests/net/forwarding/lib.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 7f22496bfdf9d..9f7f5b7ab18c8 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -2314,3 +2314,22 @@ has_unicast_flt()
 
 	[[ $promisc == 1 ]] && echo "no" || echo "yes"
 }
+
+run_cmd_grep_common()
+{
+	local find="$1"; shift
+	local cmd="$*"
+
+	if [ "$VERBOSE" = "1" ]; then
+		echo "COMMAND: ${cmd} 2>&1 | grep -q '${find}'"
+	fi
+	$cmd 2>&1 | grep -q "${find}"
+	return $?
+}
+
+run_cmd_grep() {
+	run_cmd_grep_common "$@"
+	rc=$?
+	check_err $rc
+	return $rc
+}


More information about the Devel mailing list