blob: 45a317a24e736b808c977ace62e3e05684e09f90 [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 Setti4f4ade92024-05-03 17:28:04 +020016function clean_run() {
Valerio Setti655b9792024-05-09 12:20:40 +020017 rm -f psa_notify_*
Valerio Setti4f4ade92024-05-03 17:28:04 +020018 pkill psa_partition || true
19 pkill psa_client || true
Tom Cosgrovebdc4c2d2024-05-27 23:55:43 +030020 ipcs | grep q | awk '{ printf " -q " $2 }' | xargs ipcrm > /dev/null 2>&1 || true
Valerio Setti4f4ade92024-05-03 17:28:04 +020021}
22
23# The server creates some local files when it starts up so we can wait for this
24# event as signal that the server is ready so that we can start client(s).
25function wait_for_server_startup() {
26 while [ ! -f ./psa_notify_* ]; do
Valerio Setti655b9792024-05-09 12:20:40 +020027 sleep 0.1
Valerio Setti4f4ade92024-05-03 17:28:04 +020028 done
29}
30
31clean_run
32
Tom Cosgrovea4952f92024-05-29 10:28:08 +010033./psa_partition -k &
Valerio Setti4f4ade92024-05-03 17:28:04 +020034SERV_PID=$!
35wait_for_server_startup
Tom Cosgrove98760122024-06-11 17:21:15 +010036./psa_client "$@"
Valerio Setti4f4ade92024-05-03 17:28:04 +020037wait $SERV_PID