Skip to content

Commit

Permalink
theres no good unbuffered linux utils...
Browse files Browse the repository at this point in the history
  • Loading branch information
grg-haas committed Jun 17, 2024
1 parent bc0b41d commit 46ca635
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/ci/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function wait_tty {
exit 1
fi

configure_tty "$1" "$2" ; cat "$1" | grep --line-buffered -m1 "$3"
configure_tty "$1" "$2" ; cat "$1" | ./scripts/ci/utils/wait_for.py "$3"
}

function start_record_tty {
Expand Down
21 changes: 21 additions & 0 deletions scripts/ci/utils/wait_for.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/python3

import sys
import os

if len(sys.argv) != 2:
print('usage: wait_for.py [pattern]')
exit(1)

pattern = sys.argv[1].encode('utf-8')

index = 0
while True:
if index == len(pattern):
exit(0)

n = os.read(sys.stdin.fileno(), 1)
if n[0] == pattern[index]:
index += 1
else:
index = 0

0 comments on commit 46ca635

Please sign in to comment.