bneradt commented on code in PR #13237:
URL: https://github.com/apache/trafficserver/pull/13237#discussion_r3353377041


##########
tests/tools/condwait:
##########
@@ -55,24 +61,35 @@ if [[ "$X" = "$1" ]] ; then
 fi
 
 if [[ "$1" = "" ]] ; then
-    echo "usage: condwait [ MAX-WAIT [ POST-WAIT ] ] TEST-CONDTION" >&2
+    usage
     exit 1
 fi
 
+if [[ "$1" = "--contains" ]]; then
+    if [[ $# -ne 4 ]] || ! [[ "$4" =~ ^[0-9]+$ ]]; then
+        usage
+        exit 1
+    fi
+fi
+
 # Check if this is a simple file existence test (-f, -e, -d). If so, use ls -d
 # which handles glob patterns properly. Otherwise, use test for the condition.
 check_condition() {
-    if [[ "$1" = "-f" || "$1" = "-e" || "$1" = "-d" ]] && [[ $# -eq 2 ]]; then
+    if [[ "$1" = "--contains" ]]; then
+        [[ -f "$2" ]] || return 1
+        matches=$(awk -v pattern="$3" 'index($0, pattern) { count++ } END { 
print count + 0 }' "$2")
+        (( matches >= $4 ))
+    elif [[ "$1" = "-f" || "$1" = "-e" || "$1" = "-d" ]] && [[ $# -eq 2 ]]; 
then
         # Use ls -d for file existence tests to support glob patterns.
         ls -d $2 >/dev/null 2>&1
     else

Review Comment:
   Looks good



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to