blob: 0ffaaea794ac02c21531c8ee4892004d103a1cbb [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
Valerio Setti4362aae2024-05-09 09:15:39 +020030./psa_partition -k > psa_partition.log 2>&1 &
Valerio Setti4f4ade92024-05-03 17:28:04 +020031SERV_PID=$!
32wait_for_server_startup
Valerio Setti4362aae2024-05-09 09:15:39 +020033./psa_client > psa_client.log 2>&1
Valerio Setti4f4ade92024-05-03 17:28:04 +020034wait $SERV_PID