Skip to content

Commit

Permalink
Make sure chip-all-clusters-app is ready before we try to do PASE set…
Browse files Browse the repository at this point in the history
…up with it.

We were racing startup of chip-tool against that of
chip-all-clusters-app, and if the former started faster it would send
the first PASE handshake message before the latter was ready. Then it
would wait 5 seconds before resending, which slowed the test down
quite a bit
  • Loading branch information
bzbarsky-apple committed Jun 15, 2021
1 parent 345b466 commit f8fb35c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ jobs:
with:
submodules: true
- name: Setup Environment
run: brew install openssl pkg-config
# coreutils for stdbuf
run: brew install openssl pkg-config coreutils
- name: Try to ensure the directories for core dumping and diagnostic log collection exist and we can write them.
run: |
sudo chown ${USER} /cores || true
Expand Down
25 changes: 23 additions & 2 deletions scripts/tests/test_suites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,29 @@ for j in "${iter_array[@]}"; do
echo " ===== Running test: $i"
echo " * Starting cluster server"
rm -rf /tmp/chip_tool_config.ini
out/debug/chip-all-clusters-app &
background_pid=$!
# This part is a little complicated. We want to
# 1) Start chip-all-clusters-app in the background
# 2) Pipe its output through tee so we can wait until it's ready for a
# PASE handshake.
# 3) Save its pid off so we can kill it.
#
# The subshell with echoing of $! to a file descriptor and
# then reading things out of there accomplishes item 3;
# otherwise $! would be the last-started command which would
# be the tee. This part comes from https://stackoverflow.com/a/3786955
# and better ideas are welcome.
#
# The stdbuf -o0 is to make sure our output is flushed through
# tee expeditiously; otherwise it will buffer things up and we
# will never see the string we want.
(
stdbuf -o0 out/debug/chip-all-clusters-app &
echo $! >&3
) 3>/tmp/pid | tee /tmp/all-clusters-log &
background_pid="$(</tmp/pid)"
while ! grep -q "Server Listening" /tmp/all-clusters-log; do
:
done
echo " * Pairing to device"
out/debug/standalone/chip-tool pairing onnetwork 1 20202021 3840 ::1 11097
echo " * Starting test run: $i"
Expand Down

0 comments on commit f8fb35c

Please sign in to comment.