blob: 6a5605ff5a2ed36baed55f8bc63e591b7b64f236 [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
20 ipcs | grep q | awk '{ printf " -q " $$2 }' | xargs ipcrm > /dev/null 2>&1 || true
21}
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
Valerio Setti4362aae2024-05-09 09:15:39 +020033./psa_partition -k > psa_partition.log 2>&1 &
Valerio Setti4f4ade92024-05-03 17:28:04 +020034SERV_PID=$!
35wait_for_server_startup
Valerio Setti4362aae2024-05-09 09:15:39 +020036./psa_client > psa_client.log 2>&1
Valerio Setti4f4ade92024-05-03 17:28:04 +020037wait $SERV_PID