blob: 7c1011ead2d88d22744e4092a7986e80e7d5e5bb [file] [log] [blame]
Valerio Setti4f4ade92024-05-03 17:28:04 +02001#!/bin/bash
2
3# This is a simple bash script that tests psa_client/psa_server interaction.
4# This script is automatically executed when "make run" is launched by the
5# "psasim" root folder. The script can also be launched manually once
6# binary files are built (i.e. after "make test" is executed from the "psasim"
7# root folder).
8#
9# Copyright The Mbed TLS Contributors
10# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
11
12set -e
13
Valerio Setti655b9792024-05-09 12:20:40 +020014cd "$(dirname "$0")"
15
Valerio Setti5beb2362024-06-24 13:13:17 +020016CLIENT_BIN=$1
17shift
18
Valerio Setti4f4ade92024-05-03 17:28:04 +020019function clean_run() {
Valerio Setti655b9792024-05-09 12:20:40 +020020 rm -f psa_notify_*
Valerio Setti4f4ade92024-05-03 17:28:04 +020021 pkill psa_partition || true
22 pkill psa_client || true
Tom Cosgrovebdc4c2d2024-05-27 23:55:43 +030023 ipcs | grep q | awk '{ printf " -q " $2 }' | xargs ipcrm > /dev/null 2>&1 || true
Valerio Setti4f4ade92024-05-03 17:28:04 +020024}
25
26# The server creates some local files when it starts up so we can wait for this
27# event as signal that the server is ready so that we can start client(s).
28function wait_for_server_startup() {
29 while [ ! -f ./psa_notify_* ]; do
Valerio Setti655b9792024-05-09 12:20:40 +020030 sleep 0.1
Valerio Setti4f4ade92024-05-03 17:28:04 +020031 done
32}
33
34clean_run
35
Valerio Setti5beb2362024-06-24 13:13:17 +020036./psa_partition &
Valerio Setti4f4ade92024-05-03 17:28:04 +020037wait_for_server_startup
Valerio Setti5beb2362024-06-24 13:13:17 +020038./$CLIENT_BIN "$@"
39
40# Kill server once client exited
41pkill psa_partition