diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 6ec07e559f7c0c..f16c88e43548bd 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -74,7 +74,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: Fix pkgconfig link working-directory: /usr/local/lib/pkgconfig run: | diff --git a/scripts/tests/test_suites.sh b/scripts/tests/test_suites.sh index 36e12e502bf463..6d2a5cf00b2eb6 100755 --- a/scripts/tests/test_suites.sh +++ b/scripts/tests/test_suites.sh @@ -52,8 +52,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="$(