blob: f0e7a62f1a7c67ffacce9c9a7208aa3f467843ae [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
14function clean_run() {
15 pkill psa_partition || true
16 pkill psa_client || true
17 ipcs | grep q | awk '{ printf " -q " $$2 }' | xargs ipcrm > /dev/null 2>&1 || true
18}
19
20# The server creates some local files when it starts up so we can wait for this
21# event as signal that the server is ready so that we can start client(s).
22function wait_for_server_startup() {
23 while [ ! -f ./psa_notify_* ]; do
24 sleep 0.1
25 done
26}
27
28clean_run
29
30./psa_partition -k &
31SERV_PID=$!
32wait_for_server_startup
33./psa_client
34wait $SERV_PID