1MBEDTLS_TEST_PATH = .
2include ../scripts/common.make
3
4# Set this to -v to see the details of failing test cases
5TEST_FLAGS ?= $(if $(filter-out 0 OFF Off off NO No no FALSE False false N n,$(CTEST_OUTPUT_ON_FAILURE)),-v,)
6
7# Also include private headers, for the sake of invasive tests.
8LOCAL_CFLAGS += -I$(MBEDTLS_PATH)/library -I$(MBEDTLS_PATH)/tf-psa-crypto/core -I$(MBEDTLS_PATH)/tf-psa-crypto/drivers/builtin/src
9
10# Enable definition of various functions used throughout the testsuite
11# (gethostname, strdup, fileno...) even when compiling with -std=c99. Harmless
12# on non-POSIX platforms.
13LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L
14
15ifdef RECORD_PSA_STATUS_COVERAGE_LOG
16LOCAL_CFLAGS += -Werror -DRECORD_PSA_STATUS_COVERAGE_LOG
17endif
18
19GENERATED_BIGNUM_DATA_FILES := $(addprefix ../tf-psa-crypto/,$(shell \
20	$(PYTHON) ../framework/scripts/generate_bignum_tests.py --list || \
21	echo FAILED \
22))
23ifeq ($(GENERATED_BIGNUM_DATA_FILES),FAILED)
24$(error "$(PYTHON) ../framework/scripts/generate_bignum_tests.py --list" failed)
25endif
26GENERATED_CRYPTO_DATA_FILES += $(GENERATED_BIGNUM_DATA_FILES)
27
28GENERATED_MBEDTLS_CONFIG_DATA_FILES := $(patsubst tests/%,%,$(shell \
29	$(PYTHON) ../framework/scripts/generate_config_tests.py --list || \
30	echo FAILED \
31))
32ifeq ($(GENERATED_MBEDTLS_CONFIG_DATA_FILES),FAILED)
33$(error "$(PYTHON) ../framework/scripts/generate_config_tests.py --list" failed)
34endif
35
36GENERATED_PSA_CONFIG_DATA_FILES := $(addprefix ../tf-psa-crypto/,$(shell \
37	$(PYTHON) ../tf-psa-crypto/framework/scripts/generate_config_tests.py --list || \
38	echo FAILED \
39))
40ifeq ($(GENERATED_PSA_CONFIG_DATA_FILES),FAILED)
41$(error "$(PYTHON) ../tf-psa-crypto/framework/scripts/generate_config_tests.py --list" failed)
42endif
43
44GENERATED_CONFIG_DATA_FILES := $(GENERATED_MBEDTLS_CONFIG_DATA_FILES) $(GENERATED_PSA_CONFIG_DATA_FILES)
45GENERATED_DATA_FILES += $(GENERATED_MBEDTLS_CONFIG_DATA_FILES)
46GENERATED_CRYPTO_DATA_FILES += $(GENERATED_PSA_CONFIG_DATA_FILES)
47
48GENERATED_ECP_DATA_FILES := $(addprefix ../tf-psa-crypto/,$(shell \
49	$(PYTHON) ../framework/scripts/generate_ecp_tests.py --list || \
50	echo FAILED \
51))
52ifeq ($(GENERATED_ECP_DATA_FILES),FAILED)
53$(error "$(PYTHON) ../framework/scripts/generate_ecp_tests.py --list" failed)
54endif
55GENERATED_CRYPTO_DATA_FILES += $(GENERATED_ECP_DATA_FILES)
56
57GENERATED_PSA_DATA_FILES := $(addprefix ../tf-psa-crypto/,$(shell \
58	$(PYTHON) ../framework/scripts/generate_psa_tests.py --list || \
59	echo FAILED \
60))
61ifeq ($(GENERATED_PSA_DATA_FILES),FAILED)
62$(error "$(PYTHON) ../framework/scripts/generate_psa_tests.py --list" failed)
63endif
64GENERATED_CRYPTO_DATA_FILES += $(GENERATED_PSA_DATA_FILES)
65
66GENERATED_FILES = $(GENERATED_DATA_FILES) $(GENERATED_CRYPTO_DATA_FILES)
67GENERATED_FILES += include/test/test_keys.h \
68                   ../tf-psa-crypto/tests/include/test/test_keys.h \
69                   include/test/test_certs.h
70
71# Generated files needed to (fully) run ssl-opt.sh
72.PHONY: ssl-opt
73
74opt-testcases/handshake-generated.sh: ../framework/scripts/mbedtls_framework/tls_test_case.py
75opt-testcases/handshake-generated.sh: ../framework/scripts/generate_tls_handshake_tests.py
76	echo "  Gen   $@"
77	$(PYTHON) ../framework/scripts/generate_tls_handshake_tests.py -o $@
78GENERATED_FILES += opt-testcases/handshake-generated.sh
79ssl-opt: opt-testcases/handshake-generated.sh
80
81opt-testcases/tls13-compat.sh: ../framework/scripts/generate_tls13_compat_tests.py
82	echo "  Gen   $@"
83	$(PYTHON) ../framework/scripts/generate_tls13_compat_tests.py -o $@
84GENERATED_FILES += opt-testcases/tls13-compat.sh
85ssl-opt: opt-testcases/tls13-compat.sh
86
87.PHONY: generated_files
88generated_files: $(GENERATED_FILES)
89
90# generate_bignum_tests.py and generate_psa_tests.py spend more time analyzing
91# inputs than generating outputs. Its inputs are the same no matter which files
92# are being generated.
93# It's rare not to want all the outputs. So always generate all of its outputs.
94# Use an intermediate phony dependency so that parallel builds don't run
95# a separate instance of the recipe for each output file.
96$(GENERATED_BIGNUM_DATA_FILES): $(gen_file_dep) generated_bignum_test_data
97generated_bignum_test_data: ../framework/scripts/generate_bignum_tests.py
98generated_bignum_test_data: ../framework/scripts/mbedtls_framework/bignum_common.py
99generated_bignum_test_data: ../framework/scripts/mbedtls_framework/bignum_core.py
100generated_bignum_test_data: ../framework/scripts/mbedtls_framework/bignum_mod_raw.py
101generated_bignum_test_data: ../framework/scripts/mbedtls_framework/bignum_mod.py
102generated_bignum_test_data: ../framework/scripts/mbedtls_framework/test_case.py
103generated_bignum_test_data: ../framework/scripts/mbedtls_framework/test_data_generation.py
104generated_bignum_test_data:
105	echo "  Gen   $(GENERATED_BIGNUM_DATA_FILES)"
106	$(PYTHON) ../framework/scripts/generate_bignum_tests.py --directory ../tf-psa-crypto/tests/suites
107.SECONDARY: generated_bignum_test_data
108
109# We deliberately omit the configuration files (mbedtls_config.h,
110# crypto_config.h) from the depenency list because during development
111# and on the CI, we often edit those in a way that doesn't change the
112# output, to comment out certain options, or even to remove certain
113# lines which do affect the output negatively (it will miss the
114# corresponding test cases).
115$(GENERATED_CONFIG_DATA_FILES): $(gen_file_dep) generated_config_test_data
116generated_config_test_data: ../framework/scripts/generate_config_tests.py
117generated_config_test_data: ../scripts/config.py
118generated_config_test_data: ../framework/scripts/mbedtls_framework/test_case.py
119generated_config_test_data: ../framework/scripts/mbedtls_framework/test_data_generation.py
120generated_config_test_data:
121	echo "  Gen   $(GENERATED_CONFIG_DATA_FILES)"
122	$(PYTHON) ../framework/scripts/generate_config_tests.py
123	cd ../tf-psa-crypto && $(PYTHON) ./framework/scripts/generate_config_tests.py
124.SECONDARY: generated_config_test_data
125
126$(GENERATED_ECP_DATA_FILES): $(gen_file_dep) generated_ecp_test_data
127generated_ecp_test_data: ../framework/scripts/generate_ecp_tests.py
128generated_ecp_test_data: ../framework/scripts/mbedtls_framework/bignum_common.py
129generated_ecp_test_data: ../framework/scripts/mbedtls_framework/ecp.py
130generated_ecp_test_data: ../framework/scripts/mbedtls_framework/test_case.py
131generated_ecp_test_data: ../framework/scripts/mbedtls_framework/test_data_generation.py
132generated_ecp_test_data:
133	echo "  Gen   $(GENERATED_ECP_DATA_FILES)"
134	$(PYTHON) ../framework/scripts/generate_ecp_tests.py --directory ../tf-psa-crypto/tests/suites
135.SECONDARY: generated_ecp_test_data
136
137$(GENERATED_PSA_DATA_FILES): $(gen_file_dep) generated_psa_test_data
138generated_psa_test_data: ../framework/scripts/generate_psa_tests.py
139generated_psa_test_data: ../framework/scripts/mbedtls_framework/crypto_data_tests.py
140generated_psa_test_data: ../framework/scripts/mbedtls_framework/crypto_knowledge.py
141generated_psa_test_data: ../framework/scripts/mbedtls_framework/macro_collector.py
142generated_psa_test_data: ../framework/scripts/mbedtls_framework/psa_information.py
143generated_psa_test_data: ../framework/scripts/mbedtls_framework/psa_storage.py
144generated_psa_test_data: ../framework/scripts/mbedtls_framework/psa_test_case.py
145generated_psa_test_data: ../framework/scripts/mbedtls_framework/test_case.py
146generated_psa_test_data: ../framework/scripts/mbedtls_framework/test_data_generation.py
147## The generated file only depends on the options that are present in
148## crypto_config.h, not on which options are set. To avoid regenerating this
149## file all the time when switching between configurations, don't declare
150## crypto_config.h as a dependency. Remove this file from your working tree
151## if you've just added or removed an option in crypto_config.h.
152#generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_config.h
153generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_values.h
154generated_psa_test_data: ../tf-psa-crypto/include/psa/crypto_extra.h
155generated_psa_test_data: ../tf-psa-crypto/tests/suites/test_suite_psa_crypto_metadata.data
156generated_psa_test_data:
157	echo "  Gen   $(GENERATED_PSA_DATA_FILES) ..."
158	$(PYTHON) ../framework/scripts/generate_psa_tests.py --directory ../tf-psa-crypto/tests/suites
159.SECONDARY: generated_psa_test_data
160
161# A test application is built for each suites/test_suite_*.data file.
162# Application name is same as .data file's base name and can be
163# constructed by stripping path 'suites/' and extension .data.
164DATA_FILES = $(filter-out $(GENERATED_DATA_FILES), $(wildcard suites/test_suite_*.data))
165CRYPTO_DATA_FILES = $(filter-out $(GENERATED_CRYPTO_DATA_FILES), $(wildcard ../tf-psa-crypto/tests/suites/test_suite_*.data))
166
167# Make sure that generated data files are included even if they don't
168# exist yet when the makefile is parsed.
169DATA_FILES += $(GENERATED_DATA_FILES)
170CRYPTO_DATA_FILES += $(GENERATED_CRYPTO_DATA_FILES)
171
172APPS = $(basename $(subst suites/,,$(DATA_FILES)))
173CRYPTO_APPS = $(basename $(subst suites/,,$(CRYPTO_DATA_FILES)))
174
175# Construct executable name by adding OS specific suffix $(EXEXT).
176BINARIES := $(addsuffix $(EXEXT),$(APPS))
177CRYPTO_BINARIES := $(addsuffix $(EXEXT),$(CRYPTO_APPS))
178
179.SILENT:
180
181.PHONY: all check test clean
182
183all: $(BINARIES) $(CRYPTO_BINARIES)
184
185mbedtls_test: $(MBEDTLS_TEST_OBJS)
186
187include/test/test_certs.h: ../framework/scripts/generate_test_cert_macros.py \
188				  $($(PYTHON) ../framework/scripts/generate_test_cert_macros.py --list-dependencies)
189	echo "  Gen   $@"
190	$(PYTHON) ../framework/scripts/generate_test_cert_macros.py --output $@
191
192include/test/test_keys.h: ../framework/scripts/generate_test_keys.py
193	echo "  Gen   $@"
194	$(PYTHON) ../framework/scripts/generate_test_keys.py --output $@
195
196../tf-psa-crypto/tests/include/test/test_keys.h: ../tf-psa-crypto/framework/scripts/generate_test_keys.py
197	echo "  Gen   $@"
198	$(PYTHON) ../tf-psa-crypto/framework/scripts/generate_test_keys.py --output $@
199
200TEST_OBJS_DEPS = $(wildcard include/test/*.h include/test/*/*.h)
201ifdef RECORD_PSA_STATUS_COVERAGE_LOG
202# Explicitly depend on this header because on a clean copy of the source tree,
203# it doesn't exist yet and must be generated as part of the build, and
204# therefore the wildcard enumeration above doesn't include it.
205TEST_OBJS_DEPS += ../framework/tests/include/test/instrument_record_status.h
206endif
207TEST_OBJS_DEPS += include/test/test_certs.h include/test/test_keys.h \
208                  ../tf-psa-crypto/tests/include/test/test_keys.h
209
210# Rule to compile common test C files in framework
211../framework/tests/src/%.o : ../framework/tests/src/%.c $(TEST_OBJS_DEPS)
212	echo "  CC    $<"
213	$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
214
215../framework/tests/src/drivers/%.o : ../framework/tests/src/drivers/%.c
216	echo "  CC    $<"
217	$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
218
219# Rule to compile common test C files in src folder
220src/%.o : src/%.c $(TEST_OBJS_DEPS)
221	echo "  CC    $<"
222	$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
223
224src/test_helpers/%.o : src/test_helpers/%.c
225	echo "  CC    $<"
226	$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
227
228C_FILES := $(addsuffix .c,$(APPS)) $(addsuffix .c,$(CRYPTO_APPS))
229c: $(C_FILES)
230
231# Wildcard target for test code generation:
232# A .c file is generated for each .data file in the suites/ directory. Each .c
233# file depends on a .data and .function file from suites/ directory. Following
234# nameing convention is followed:
235#
236#     C file        |        Depends on
237#-----------------------------------------------------------------------------
238#  foo.c            | suites/foo.function suites/foo.data
239#  foo.bar.c        | suites/foo.function suites/foo.bar.data
240#
241# Note above that .c and .data files have same base name.
242# However, corresponding .function file's base name is the word before first
243# dot in .c file's base name.
244#
245.SECONDEXPANSION:
246
247# First handle the tf-psa-crypto case, which has different paths from
248# the local case. In GNU Make >=3.82, the shortest match applies regardless
249# of the order in the makefile. In GNU Make <=3.81, the first matching rule
250# applies.
251../tf-psa-crypto/tests/%.c: ../tf-psa-crypto/tests/suites/$$(firstword $$(subst ., ,$$*)).function ../tf-psa-crypto/tests/suites/%.data ../framework/scripts/generate_test_code.py ../tf-psa-crypto/tests/suites/helpers.function ../tf-psa-crypto/tests/suites/main_test.function ../tf-psa-crypto/tests/suites/host_test.function
252	echo "  Gen   $@"
253	cd ../tf-psa-crypto/tests && $(PYTHON) ../../framework/scripts/generate_test_code.py -f suites/$(firstword $(subst ., ,$*)).function \
254		-d suites/$*.data \
255		-t suites/main_test.function \
256		-p suites/host_test.function \
257		-s suites  \
258		--helpers-file suites/helpers.function \
259		-o .
260
261%.c: suites/$$(firstword $$(subst ., ,$$*)).function suites/%.data ../framework/scripts/generate_test_code.py ../tf-psa-crypto/tests/suites/helpers.function ../tf-psa-crypto/tests/suites/main_test.function ../tf-psa-crypto/tests/suites/host_test.function
262	echo "  Gen   $@"
263	$(PYTHON) ../framework/scripts/generate_test_code.py -f suites/$(firstword $(subst ., ,$*)).function \
264		-d suites/$*.data \
265		-t ../tf-psa-crypto/tests/suites/main_test.function \
266		-p ../tf-psa-crypto/tests/suites/host_test.function \
267		-s suites  \
268		--helpers-file ../tf-psa-crypto/tests/suites/helpers.function \
269		-o .
270
271$(BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(TEST_OBJS_DEPS) $(MBEDTLS_TEST_OBJS)
272	echo "  CC   $<"
273	$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
274
275LOCAL_CRYPTO_CFLAGS = $(patsubst -I./include, -I../../tests/include, $(patsubst -I../%,-I../../%, $(LOCAL_CFLAGS)))
276LOCAL_CRYPTO_LDFLAGS = $(patsubst -L../library, -L../../library, \
277                       $(patsubst -L../tests/%, -L../../tests/%, \
278                       $(patsubst ./src/%,../../tests/src/%, \
279                       $(patsubst ../framework/tests/src/%,../../framework/tests/src/%, \
280					   $(LOCAL_LDFLAGS)))))
281$(CRYPTO_BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(TEST_OBJS_DEPS) $(MBEDTLS_TEST_OBJS)
282	echo "  CC   $<"
283	cd ../tf-psa-crypto/tests && $(CC) $(LOCAL_CRYPTO_CFLAGS) $(CFLAGS) $(subst $(EXEXT),,$(@F)).c $(LOCAL_CRYPTO_LDFLAGS) $(LDFLAGS) -o $(@F)
284
285clean:
286ifndef WINDOWS
287	$(MAKE) -C psa-client-server/psasim clean
288	rm -rf $(BINARIES) *.c *.datax
289	rm -rf $(CRYPTO_BINARIES) ../tf-psa-crypto/tests/*.c ../tf-psa-crypto/tests/*.datax
290	rm -f src/*.o src/test_helpers/*.o src/libmbed*
291	rm -f ../framework/tests/src/*.o ../framework/tests/src/drivers/*.o
292	rm -f ../framework/tests/include/test/instrument_record_status.h
293	rm -f ../framework/tests/include/alt-extra/*/*_alt.h
294	rm -rf libtestdriver1
295	rm -rf libpsaclient libpsaserver
296	rm -f ../library/libtestdriver1.a
297else
298	if exist *.c del /Q /F *.c
299	if exist *.exe del /Q /F *.exe
300	if exist *.datax del /Q /F *.datax
301	if exist ../tf-psa-crypto/tests/*.c del /Q /F ../tf-psa-crypto/tests/*.c
302	if exist ../tf-psa-crypto/tests/*.exe del /Q /F ../tf-psa-crypto/tests/*.exe
303	if exist ../tf-psa-crypto/tests/*.datax del /Q /F ../tf-psa-crypto/tests/*.datax
304	if exist src/*.o del /Q /F src/*.o
305	if exist src/test_helpers/*.o del /Q /F src/test_helpers/*.o
306	if exist src/libmbed* del /Q /F src/libmbed*
307	if exist ../framework/tests/src/*.o del /Q /F ../framework/tests/src/*.o
308	if exist ../framework/tests/src/drivers/*.o del /Q /F ../framework/tests/src/drivers/*.o
309	if exist ../framework/tests/include/test/instrument_record_status.h del /Q /F ../framework/tests/include/test/instrument_record_status.h
310endif
311
312# Test suites caught by SKIP_TEST_SUITES are built but not executed.
313check: $(BINARIES) $(CRYPTO_BINARIES)
314	perl scripts/run-test-suites.pl $(TEST_FLAGS) --skip=$(SKIP_TEST_SUITES)
315
316test: check
317
318# Generate variants of some headers for testing
319../framework/tests/include/alt-extra/%_alt.h: ../include/%.h
320	perl -p -e 's/^(# *(define|ifndef) +\w+_)H\b/$${1}ALT_H/' $< >$@
321../framework/tests/include/alt-extra/%_alt.h: ../tf-psa-crypto/include/%.h
322	perl -p -e 's/^(# *(define|ifndef) +\w+_)H\b/$${1}ALT_H/' $< >$@
323../framework/tests/include/alt-extra/%_alt.h: ../tf-psa-crypto/drivers/builtin/include/%.h
324	perl -p -e 's/^(# *(define|ifndef) +\w+_)H\b/$${1}ALT_H/' $< >$@
325
326# Generate test library
327libtestdriver1.a:
328	rm -Rf ./libtestdriver1
329	mkdir ./libtestdriver1
330	mkdir ./libtestdriver1/framework
331	mkdir ./libtestdriver1/tf-psa-crypto
332	mkdir ./libtestdriver1/tf-psa-crypto/drivers
333	mkdir ./libtestdriver1/tf-psa-crypto/drivers/everest
334	mkdir ./libtestdriver1/tf-psa-crypto/drivers/p256-m
335	touch ./libtestdriver1/tf-psa-crypto/drivers/everest/Makefile.inc
336	touch ./libtestdriver1/tf-psa-crypto/drivers/p256-m/Makefile.inc
337	cp -Rf ../framework/scripts ./libtestdriver1/framework
338	cp -Rf ../library ./libtestdriver1
339	cp -Rf ../include ./libtestdriver1
340	cp -Rf ../scripts ./libtestdriver1
341	cp -Rf ../tf-psa-crypto/core ./libtestdriver1/tf-psa-crypto
342	cp -Rf ../tf-psa-crypto/include ./libtestdriver1/tf-psa-crypto
343	cp -Rf ../tf-psa-crypto/drivers/builtin ./libtestdriver1/tf-psa-crypto/drivers
344	cp -Rf ../tf-psa-crypto/scripts ./libtestdriver1/tf-psa-crypto
345
346	# Set the test driver base (minimal) configuration.
347	cp ../tf-psa-crypto/tests/configs/config_test_driver.h ./libtestdriver1/include/mbedtls/mbedtls_config.h
348	cp ../tf-psa-crypto/tests/configs/crypto_config_test_driver.h ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h
349
350	# Set the PSA cryptography configuration for the test library.
351	# The configuration is created by joining the base
352	# ../tf-psa-crypto/tests/configs/crypto_config_test_driver.h,
353	# with the the library's PSA_WANT_* macros extracted from
354	# ./tf-psa-crypto/include/psa/crypto_config.h
355	# and then extended with entries of
356	# ../tf-psa-crypto/tests/configs/crypto_config_test_driver_extension.h
357	# to mirror the PSA_ACCEL_* macros.
358
359	mv ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h.bak
360	head -n -1 ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h.bak > ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h
361	grep '^#define PSA_WANT_*' ../tf-psa-crypto/include/psa/crypto_config.h >> ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h
362	cat ../tf-psa-crypto/tests/configs/crypto_config_test_driver_extension.h >> ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h
363	echo "#endif /* PSA_CRYPTO_CONFIG_H */" >> ./libtestdriver1/tf-psa-crypto/include/psa/crypto_config.h
364
365	# Prefix MBEDTLS_* PSA_* symbols with LIBTESTDRIVER1_ as well as
366	# mbedtls_* psa_* symbols with libtestdriver1_ to avoid symbol clash
367	# when this test driver library is linked with the Mbed TLS library.
368	perl -i ./scripts/libtestdriver1_rewrite.pl ./libtestdriver1/library/*.[ch]
369	perl -i ./scripts/libtestdriver1_rewrite.pl ./libtestdriver1/include/*/*.h
370	perl -i ./scripts/libtestdriver1_rewrite.pl ./libtestdriver1/tf-psa-crypto/core/*.[ch]
371	perl -i ./scripts/libtestdriver1_rewrite.pl ./libtestdriver1/tf-psa-crypto/include/*/*.h
372	perl -i ./scripts/libtestdriver1_rewrite.pl ./libtestdriver1/tf-psa-crypto/drivers/builtin/include/*/*.h
373	perl -i ./scripts/libtestdriver1_rewrite.pl ./libtestdriver1/tf-psa-crypto/drivers/builtin/include/*/*/*.h
374	perl -i ./scripts/libtestdriver1_rewrite.pl ./libtestdriver1/tf-psa-crypto/drivers/builtin/src/*.[ch]
375
376	$(MAKE) -C ./libtestdriver1/library CFLAGS="-I../../ $(CFLAGS)" LDFLAGS="$(LDFLAGS)" libmbedcrypto.a
377	cp ./libtestdriver1/library/libmbedcrypto.a ../library/libtestdriver1.a
378
379ifdef RECORD_PSA_STATUS_COVERAGE_LOG
380../framework/tests/include/test/instrument_record_status.h: ../tf-psa-crypto/include/psa/crypto.h Makefile
381	echo "  Gen  $@"
382	sed <../tf-psa-crypto/include/psa/crypto.h >$@ -n 's/^psa_status_t \([A-Za-z0-9_]*\)(.*/#define \1(...) RECORD_STATUS("\1", \1(__VA_ARGS__))/p'
383endif
384