Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client-server build to all.sh #9121

Merged
merged 13 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ ifndef WINDOWS
rm -f include/test/instrument_record_status.h
rm -f include/alt-extra/*/*_alt.h
rm -rf libtestdriver1
rm -rf libpsaclient libpsaserver
rm -f ../library/libtestdriver1.a
else
if exist *.c del /Q /F *.c
Expand Down
67 changes: 53 additions & 14 deletions tests/psa-client-server/psasim/Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,62 @@
CFLAGS ?= -Wall -Werror -std=c99 -D_XOPEN_SOURCE=1 -D_POSIX_C_SOURCE=200809L
CFLAGS += -Wall -Werror -std=c99 -D_XOPEN_SOURCE=1 -D_POSIX_C_SOURCE=200809L

ifeq ($(DEBUG),1)
CFLAGS += -DDEBUG -O0 -g
CFLAGS += -DDEBUG -O0 -g
endif

.PHONY: all lib test run
LIBPSACLIENT := -Llibpsaclient/ -lmbedcrypto -lmbedx509 -lmbedtls
LIBPSASERVER := -Llibpsaserver/ -lmbedcrypto

all: lib test
MBEDTLS_ROOT_PATH = ../../..
COMMON_INCLUDE := -I./include -I$(MBEDTLS_ROOT_PATH)/include

lib:
$(MAKE) -C src CFLAGS="$(CFLAGS)"
TEST_BIN = test/psa_client \
test/psa_partition

test: lib
$(MAKE) -C test CFLAGS="$(CFLAGS)"
GENERATED_H_FILES = include/psa_manifest/manifest.h \
include/psa_manifest/pid.h \
include/psa_manifest/sid.h

clean:
rm -f $(PSA_LIB) $(PSA_LIB_OBJS)
$(MAKE) -C test clean
$(MAKE) -C src clean
PSA_CLIENT_SRC = src/psa_ff_client.c \
src/client.c

PARTITION_SERVER_BOOTSTRAP = src/psa_ff_bootstrap_TEST_PARTITION.c

PSA_SERVER_SRC = $(PARTITION_SERVER_BOOTSTRAP) \
src/psa_ff_server.c

.PHONY: all clean libpsaclient libpsaserver

all: $(TEST_BIN)

test/seedfile:
dd if=/dev/urandom of=./test/seedfile bs=64 count=1

run: test
cd test && ./run_test.sh
test/psa_client: $(PSA_CLIENT_SRC) $(GENERATED_H_FILES)
$(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_CLIENT_SRC) $(LIBPSACLIENT) $(LDFLAGS) -o $@

test/psa_partition: $(PSA_SERVER_SRC) $(GENERATED_H_FILES) test/seedfile
$(CC) $(COMMON_INCLUDE) $(CFLAGS) $(PSA_SERVER_SRC) $(LIBPSASERVER) $(LDFLAGS) -o $@

$(PARTITION_SERVER_BOOTSTRAP) $(GENERATED_H_FILES): src/manifest.json src/server.c
tools/psa_autogen.py src/manifest.json

# Build MbedTLS libraries (crypto, x509 and tls) and copy them locally to
# build client/server applications.
#
# Note: these rules assume that mbedtls_config.h is already configured by all.sh.
# If not using all.sh then the user must do it manually.
libpsaclient libpsaserver:
$(MAKE) -C $(MBEDTLS_ROOT_PATH)/library CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" libmbedcrypto.a libmbedx509.a libmbedtls.a
mkdir -p $@
cp $(MBEDTLS_ROOT_PATH)/library/libmbed*.a $@/
$(MAKE) -C $(MBEDTLS_ROOT_PATH) clean

clean:
rm -f $(TEST_BIN)
rm -f $(PARTITION_SERVER_BOOTSTRAP)
rm -rf libpsaclient libpsaserver
rm -rf include/psa_manifest
rm -f test/psa_service_* test/psa_notify_*
rm -f test/*.log
rm -f test/seedfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ extern "C" {
#include <stdint.h>
#include <stddef.h>

#include "psa/error.h"
#include "psa/crypto.h"

#include "error_ext.h"
/*********************** PSA Client Macros and Types *************************/

#define PSA_FRAMEWORK_VERSION (0x0100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#define NON_SECURE (1 << 30)

typedef int32_t psa_status_t;
typedef int32_t psa_handle_t;

#define PSA_MAX_IOVEC (4u)
Expand Down
19 changes: 19 additions & 0 deletions tests/psa-client-server/psasim/include/error_ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* PSA status codes used by psasim. */

/*
* Copyright The Mbed TLS Contributors
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/

#ifndef PSA_ERROR_H
#define PSA_ERROR_H

#include <stdint.h>

#include "common.h"

#define PSA_ERROR_PROGRAMMER_ERROR ((psa_status_t) -129)
#define PSA_ERROR_CONNECTION_REFUSED ((psa_status_t) -130)
#define PSA_ERROR_CONNECTION_BUSY ((psa_status_t) -131)

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#include <stdint.h>
#include <psa/service.h>
#include <service.h>
void raise_signal(psa_signal_t signal);
void __init_psasim(const char **array,
int size,
Expand Down
38 changes: 0 additions & 38 deletions tests/psa-client-server/psasim/include/psa/error.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ extern "C" {
#include <stdint.h>
#include <stddef.h>

#include "psa/common.h"
#include "common.h"

#include "psa/crypto.h"

/********************** PSA Secure Partition Macros and Types ****************/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
*/

#include "psa/service.h"
#include "service.h"

#define PRINT(fmt, ...) \
fprintf(stdout, fmt "\n", ##__VA_ARGS__)
Expand Down
17 changes: 0 additions & 17 deletions tests/psa-client-server/psasim/src/Makefile

This file was deleted.

Loading