Merge pull request #8623 from daverodgman/verbatim-tfm
Use TF-M config verbatim
diff --git a/programs/Makefile b/programs/Makefile
index 64f7cc1..82c8569 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -1,9 +1,4 @@
MBEDTLS_TEST_PATH = ../tests
-# Support code used by test programs and test builds, excluding TLS-specific
-# code which is in the src/test_helpers subdirectory.
-MBEDTLS_TEST_OBJS = $(patsubst %.c,%.o,$(wildcard ${MBEDTLS_TEST_PATH}/src/*.c ${MBEDTLS_TEST_PATH}/src/drivers/*.c))
-
-LOCAL_CFLAGS = $(WARNING_CFLAGS) -I$(MBEDTLS_TEST_PATH)/include -I../include -D_FILE_OFFSET_BITS=64
include ../scripts/common.make
ifeq ($(shell uname -s),Linux)
diff --git a/programs/test/benchmark.c b/programs/test/benchmark.c
index 658f7cf..755a731 100644
--- a/programs/test/benchmark.c
+++ b/programs/test/benchmark.c
@@ -83,7 +83,14 @@
#include "mbedtls/memory_buffer_alloc.h"
#endif
+#ifdef MBEDTLS_TIMING_ALT
+void mbedtls_set_alarm(int seconds);
+unsigned long mbedtls_timing_hardclock(void);
+extern volatile int mbedtls_timing_alarmed;
+#else
static void mbedtls_set_alarm(int seconds);
+static unsigned long mbedtls_timing_hardclock(void);
+#endif
/*
* For heap usage estimates, we need an estimate of the overhead per allocated
@@ -227,6 +234,7 @@
} \
} while (0)
+#if !defined(MBEDTLS_TIMING_ALT)
#if !defined(HAVE_HARDCLOCK) && defined(MBEDTLS_HAVE_ASM) && \
(defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
@@ -441,6 +449,7 @@
}
#endif /* _WIN32 && !EFIX64 && !EFI32 */
+#endif /* !MBEDTLS_TIMING_ALT */
static int myrand(void *rng_state, unsigned char *output, size_t len)
{
diff --git a/scripts/common.make b/scripts/common.make
index 2f27d0e..6c95b42 100644
--- a/scripts/common.make
+++ b/scripts/common.make
@@ -5,7 +5,7 @@
WARNING_CXXFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
LDFLAGS ?=
-LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../tests/include -I../include -D_FILE_OFFSET_BITS=64
+LOCAL_CFLAGS = $(WARNING_CFLAGS) -I$(MBEDTLS_TEST_PATH)/include -I../include -D_FILE_OFFSET_BITS=64
LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I../include -I../tests/include -D_FILE_OFFSET_BITS=64
LOCAL_LDFLAGS = ${MBEDTLS_TEST_OBJS} \
-L../library \
@@ -35,7 +35,7 @@
## Remove the preprocessor symbols that are set in the current configuration
## from PREPROCESSOR_INPUT. Also normalize whitespace.
## Example:
-## $(call remove_set_options,MBEDTLS_FOO MBEDTLS_BAR)
+## $(call remove_enabled_options,MBEDTLS_FOO MBEDTLS_BAR)
## This expands to an empty string "" if MBEDTLS_FOO and MBEDTLS_BAR are both
## enabled, to "MBEDTLS_FOO" if MBEDTLS_BAR is enabled but MBEDTLS_FOO is
## disabled, etc.
@@ -105,3 +105,15 @@
else
for %f in ($(subst /,\,$(GENERATED_FILES))) if exist %f del /Q /F %f
endif
+
+# Auxiliary modules used by tests and some sample programs
+MBEDTLS_CORE_TEST_OBJS = $(patsubst %.c,%.o,$(wildcard \
+ ${MBEDTLS_TEST_PATH}/src/*.c \
+ ${MBEDTLS_TEST_PATH}/src/drivers/*.c \
+ ))
+# Additional auxiliary modules for TLS testing
+MBEDTLS_TLS_TEST_OBJS = $(patsubst %.c,%.o,$(wildcard \
+ ${MBEDTLS_TEST_PATH}/src/test_helpers/*.c \
+ ))
+
+MBEDTLS_TEST_OBJS = $(MBEDTLS_CORE_TEST_OBJS) $(MBEDTLS_TLS_TEST_OBJS)
diff --git a/tests/Makefile b/tests/Makefile
index 7a10af2..f82c267 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,3 +1,4 @@
+MBEDTLS_TEST_PATH = .
include ../scripts/common.make
# Set this to -v to see the details of failing test cases
@@ -109,10 +110,6 @@
all: $(BINARIES)
-MBEDTLS_TEST_PATH = .
-MBEDTLS_TEST_OBJS = $(patsubst %.c,%.o,$(wildcard ${MBEDTLS_TEST_PATH}/src/*.c ${MBEDTLS_TEST_PATH}/src/drivers/*.c))
-MBEDTLS_TEST_OBJS += $(patsubst %.c,%.o,$(wildcard ${MBEDTLS_TEST_PATH}/src/test_helpers/*.c))
-
mbedtls_test: $(MBEDTLS_TEST_OBJS)
TEST_OBJS_DEPS = $(wildcard include/test/*.h include/test/*/*.h)