1#!/bin/bash
2
3# Copyright The Mbed TLS Contributors
4# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
5
6set -e
7
8# The server creates some local files when it starts up so we can wait for this
9# event as signal that the server is ready so that we can start client(s).
10function wait_for_server_startup() {
11    SECONDS=0
12    TIMEOUT=10
13
14    while [ $(find . -name "psa_notify_*" | wc -l) -eq 0 ]; do
15        if [ "$SECONDS" -ge "$TIMEOUT" ]; then
16            echo "Timeout: psa_server not started within $TIMEOUT seconds."
17            return 1
18        fi
19        sleep 0.1
20    done
21}
22
23$(dirname "$0")/psa_server &
24wait_for_server_startup
25