mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 14:54:15 +01:00
Enable tests in Mbed OS environment
Update Makefiles and config.pl to adapt to directory structure used in Mbed OS.
This commit is contained in:
parent
ab9a29bd2c
commit
8307802824
54
Makefile
54
Makefile
@ -2,6 +2,18 @@
|
|||||||
DESTDIR=/usr/local
|
DESTDIR=/usr/local
|
||||||
PREFIX=mbedtls_
|
PREFIX=mbedtls_
|
||||||
|
|
||||||
|
PROGRAMS_DIR=./programs
|
||||||
|
TESTS_DIR=./tests
|
||||||
|
|
||||||
|
DIR_FOR_MBED_TLS_ENV=./library
|
||||||
|
ifneq "$(wildcard $(DIR_FOR_MBED_TLS_ENV) )" ""
|
||||||
|
LIBRARY_DIR=./library
|
||||||
|
INCLUDE_DIR=./include
|
||||||
|
else
|
||||||
|
LIBRARY_DIR=./src
|
||||||
|
INCLUDE_DIR=./inc
|
||||||
|
endif
|
||||||
|
|
||||||
.SILENT:
|
.SILENT:
|
||||||
|
|
||||||
.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
|
.PHONY: all no_test programs lib tests install uninstall clean test check covtest lcov apidoc apidoc_clean
|
||||||
@ -12,26 +24,26 @@ all: programs tests
|
|||||||
no_test: programs
|
no_test: programs
|
||||||
|
|
||||||
programs: lib
|
programs: lib
|
||||||
$(MAKE) -C programs
|
$(MAKE) -C $(PROGRAMS_DIR)
|
||||||
|
|
||||||
lib:
|
lib:
|
||||||
$(MAKE) -C library
|
$(MAKE) -C $(LIBRARY_DIR)
|
||||||
|
|
||||||
tests: lib
|
tests: lib
|
||||||
$(MAKE) -C tests
|
$(MAKE) -C $(TESTS_DIR)
|
||||||
|
|
||||||
ifndef WINDOWS
|
ifndef WINDOWS
|
||||||
install: no_test
|
install: no_test
|
||||||
mkdir -p $(DESTDIR)/include/mbedtls
|
mkdir -p $(DESTDIR)/$(INCLUDE_DIR)/mbedtls
|
||||||
cp -rp include/mbedtls $(DESTDIR)/include
|
cp -rp $(INCLUDE_DIR)/mbedtls $(DESTDIR)/$(INCLUDE_DIR)
|
||||||
|
|
||||||
mkdir -p $(DESTDIR)/lib
|
mkdir -p $(DESTDIR)/lib
|
||||||
cp -RP library/libmbedtls.* $(DESTDIR)/lib
|
cp -RP $(LIBRARY_DIR)/libmbedtls.* $(DESTDIR)/lib
|
||||||
cp -RP library/libmbedx509.* $(DESTDIR)/lib
|
cp -RP $(LIBRARY_DIR)/libmbedx509.* $(DESTDIR)/lib
|
||||||
cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
|
cp -RP $(LIBRARY_DIR)/libmbedcrypto.* $(DESTDIR)/lib
|
||||||
|
|
||||||
mkdir -p $(DESTDIR)/bin
|
mkdir -p $(DESTDIR)/bin
|
||||||
for p in programs/*/* ; do \
|
for p in $(PROGRAMS_DIR)/*/* ; do \
|
||||||
if [ -x $$p ] && [ ! -d $$p ] ; \
|
if [ -x $$p ] && [ ! -d $$p ] ; \
|
||||||
then \
|
then \
|
||||||
f=$(PREFIX)`basename $$p` ; \
|
f=$(PREFIX)`basename $$p` ; \
|
||||||
@ -40,12 +52,12 @@ install: no_test
|
|||||||
done
|
done
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -rf $(DESTDIR)/include/mbedtls
|
rm -rf $(DESTDIR)/$(INCLUDE_DIR)/mbedtls
|
||||||
rm -f $(DESTDIR)/lib/libmbedtls.*
|
rm -f $(DESTDIR)/lib/libmbedtls.*
|
||||||
rm -f $(DESTDIR)/lib/libmbedx509.*
|
rm -f $(DESTDIR)/lib/libmbedx509.*
|
||||||
rm -f $(DESTDIR)/lib/libmbedcrypto.*
|
rm -f $(DESTDIR)/lib/libmbedcrypto.*
|
||||||
|
|
||||||
for p in programs/*/* ; do \
|
for p in $(PROGRAMS_DIR)/*/* ; do \
|
||||||
if [ -x $$p ] && [ ! -d $$p ] ; \
|
if [ -x $$p ] && [ ! -d $$p ] ; \
|
||||||
then \
|
then \
|
||||||
f=$(PREFIX)`basename $$p` ; \
|
f=$(PREFIX)`basename $$p` ; \
|
||||||
@ -82,15 +94,15 @@ ifndef WINDOWS
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -C library clean
|
$(MAKE) -C $(LIBRARY_DIR) clean
|
||||||
$(MAKE) -C programs clean
|
$(MAKE) -C $(PROGRAMS_DIR) clean
|
||||||
$(MAKE) -C tests clean
|
$(MAKE) -C $(TESTS_DIR) clean
|
||||||
ifndef WINDOWS
|
ifndef WINDOWS
|
||||||
find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
|
find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
|
||||||
endif
|
endif
|
||||||
|
|
||||||
check: lib tests
|
check: lib tests
|
||||||
$(MAKE) -C tests check
|
$(MAKE) -C $(TESTS_DIR) check
|
||||||
|
|
||||||
test: check
|
test: check
|
||||||
|
|
||||||
@ -99,14 +111,14 @@ ifndef WINDOWS
|
|||||||
# make CFLAGS='--coverage -g3 -O0'
|
# make CFLAGS='--coverage -g3 -O0'
|
||||||
covtest:
|
covtest:
|
||||||
$(MAKE) check
|
$(MAKE) check
|
||||||
programs/test/selftest
|
$(PROGRAMS_DIR)/test/selftest
|
||||||
tests/compat.sh
|
$(TESTS_DIR)/compat.sh
|
||||||
tests/ssl-opt.sh
|
$(TESTS_DIR)/ssl-opt.sh
|
||||||
|
|
||||||
lcov:
|
lcov:
|
||||||
rm -rf Coverage
|
rm -rf Coverage
|
||||||
lcov --capture --initial --directory library -o files.info
|
lcov --capture --initial --directory $(LIBRARY_DIR) -o files.info
|
||||||
lcov --capture --directory library -o tests.info
|
lcov --capture --directory $(LIBRARY_DIR) -o tests.info
|
||||||
lcov --add-tracefile files.info --add-tracefile tests.info -o all.info
|
lcov --add-tracefile files.info --add-tracefile tests.info -o all.info
|
||||||
lcov --remove all.info -o final.info '*.h'
|
lcov --remove all.info -o final.info '*.h'
|
||||||
gendesc tests/Descriptions.txt -o descriptions
|
gendesc tests/Descriptions.txt -o descriptions
|
||||||
@ -122,7 +134,7 @@ apidoc_clean:
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
## Editor navigation files
|
## Editor navigation files
|
||||||
C_SOURCE_FILES = $(wildcard include/*/*.h library/*.[hc] programs/*/*.[hc] tests/suites/*.function)
|
C_SOURCE_FILES = $(wildcard $(INCLUDE_DIR)/*/*.h $(LIBRARY_DIR)/*.[hc] $(PROGRAMS_DIR)/*/*.[hc] $(TESTS_DIR)/suites/*.function)
|
||||||
tags: $(C_SOURCE_FILES)
|
tags: $(C_SOURCE_FILES)
|
||||||
ctags -o $@ $(C_SOURCE_FILES)
|
ctags -o $@ $(C_SOURCE_FILES)
|
||||||
TAGS: $(C_SOURCE_FILES)
|
TAGS: $(C_SOURCE_FILES)
|
||||||
|
@ -5,7 +5,20 @@ CFLAGS ?= -O2
|
|||||||
WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
|
WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
|
||||||
LDFLAGS ?=
|
LDFLAGS ?=
|
||||||
|
|
||||||
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
|
DIR_FOR_MBED_TLS_ENV=../library
|
||||||
|
ifneq "$(wildcard $(DIR_FOR_MBED_TLS_ENV) )" ""
|
||||||
|
# Set include dirs for Mbed TLS test environment
|
||||||
|
INCLUDE_DIRS=-I../include
|
||||||
|
else
|
||||||
|
# Set include dirs for Mbed OS test environment
|
||||||
|
INCLUDE_DIRS=-I.. -I../inc
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_CFLAGS = $(WARNING_CFLAGS) $(INCLUDE_DIRS) -D_FILE_OFFSET_BITS=64
|
||||||
|
ifdef MBEDTLS_CONFIG_FILE
|
||||||
|
LOCAL_CFLAGS += "-DMBEDTLS_CONFIG_FILE=\"${MBEDTLS_CONFIG_FILE}\""
|
||||||
|
endif
|
||||||
|
|
||||||
LOCAL_LDFLAGS =
|
LOCAL_LDFLAGS =
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
|
@ -7,17 +7,32 @@ WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement
|
|||||||
WARNING_CXXFLAGS ?= -Wall -W
|
WARNING_CXXFLAGS ?= -Wall -W
|
||||||
LDFLAGS ?=
|
LDFLAGS ?=
|
||||||
|
|
||||||
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
|
# Check test environment. If ../library is available then Mbed TLS is used.
|
||||||
LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) -I../include -D_FILE_OFFSET_BITS=64
|
# Otherwise Mbed OS environment is used.
|
||||||
LOCAL_LDFLAGS = -L../library \
|
DIR_FOR_MBED_TLS_ENV=../library
|
||||||
|
ifneq "$(wildcard $(DIR_FOR_MBED_TLS_ENV) )" ""
|
||||||
|
LIBRARY_DIR=../library
|
||||||
|
INCLUDE_DIR=-I../include
|
||||||
|
else
|
||||||
|
LIBRARY_DIR=../src
|
||||||
|
INCLUDE_DIR=-I.. -I../inc
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_CFLAGS = $(WARNING_CFLAGS) $(INCLUDE_DIR) -D_FILE_OFFSET_BITS=64
|
||||||
|
ifdef MBEDTLS_CONFIG_FILE
|
||||||
|
LOCAL_CFLAGS += "-DMBEDTLS_CONFIG_FILE=\"${MBEDTLS_CONFIG_FILE}\""
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_CXXFLAGS = $(WARNING_CXXFLAGS) $(INCLUDE_DIR) -D_FILE_OFFSET_BITS=64
|
||||||
|
LOCAL_LDFLAGS = -L$(LIBRARY_DIR) \
|
||||||
-lmbedtls$(SHARED_SUFFIX) \
|
-lmbedtls$(SHARED_SUFFIX) \
|
||||||
-lmbedx509$(SHARED_SUFFIX) \
|
-lmbedx509$(SHARED_SUFFIX) \
|
||||||
-lmbedcrypto$(SHARED_SUFFIX)
|
-lmbedcrypto$(SHARED_SUFFIX)
|
||||||
|
|
||||||
ifndef SHARED
|
ifndef SHARED
|
||||||
DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
|
DEP=$(LIBRARY_DIR)/libmbedcrypto.a $(LIBRARY_DIR)/libmbedx509.a $(LIBRARY_DIR)/libmbedtls.a
|
||||||
else
|
else
|
||||||
DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
|
DEP=$(LIBRARY_DIR)/libmbedcrypto.$(DLEXT) $(LIBRARY_DIR)/libmbedx509.$(DLEXT) $(LIBRARY_DIR)/libmbedtls.$(DLEXT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
@ -47,12 +62,12 @@ ifdef ZLIB
|
|||||||
LOCAL_LDFLAGS += -lz
|
LOCAL_LDFLAGS += -lz
|
||||||
endif
|
endif
|
||||||
|
|
||||||
APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \
|
APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \
|
||||||
hash/hello$(EXEXT) hash/generic_sum$(EXEXT) \
|
hash/hello$(EXEXT) hash/generic_sum$(EXEXT) \
|
||||||
pkey/dh_client$(EXEXT) \
|
pkey/dh_client$(EXEXT) \
|
||||||
pkey/dh_genprime$(EXEXT) pkey/dh_server$(EXEXT) \
|
pkey/dh_genprime$(EXEXT) pkey/dh_server$(EXEXT) \
|
||||||
pkey/ecdh_curve25519$(EXEXT) \
|
pkey/ecdh_curve25519$(EXEXT) \
|
||||||
pkey/ecdsa$(EXEXT) pkey/gen_key$(EXEXT) \
|
pkey/ecdsa$(EXEXT) pkey/gen_key$(EXEXT) \
|
||||||
pkey/key_app$(EXEXT) pkey/key_app_writer$(EXEXT) \
|
pkey/key_app$(EXEXT) pkey/key_app_writer$(EXEXT) \
|
||||||
pkey/mpi_demo$(EXEXT) pkey/pk_decrypt$(EXEXT) \
|
pkey/mpi_demo$(EXEXT) pkey/pk_decrypt$(EXEXT) \
|
||||||
pkey/pk_encrypt$(EXEXT) pkey/pk_sign$(EXEXT) \
|
pkey/pk_encrypt$(EXEXT) pkey/pk_sign$(EXEXT) \
|
||||||
@ -65,12 +80,12 @@ APPS = aes/aescrypt2$(EXEXT) aes/crypt_and_hash$(EXEXT) \
|
|||||||
ssl/ssl_server$(EXEXT) ssl/ssl_server2$(EXEXT) \
|
ssl/ssl_server$(EXEXT) ssl/ssl_server2$(EXEXT) \
|
||||||
ssl/ssl_fork_server$(EXEXT) ssl/mini_client$(EXEXT) \
|
ssl/ssl_fork_server$(EXEXT) ssl/mini_client$(EXEXT) \
|
||||||
ssl/ssl_mail_client$(EXEXT) random/gen_entropy$(EXEXT) \
|
ssl/ssl_mail_client$(EXEXT) random/gen_entropy$(EXEXT) \
|
||||||
random/gen_random_havege$(EXEXT) \
|
random/gen_random_havege$(EXEXT) \
|
||||||
random/gen_random_ctr_drbg$(EXEXT) \
|
random/gen_random_ctr_drbg$(EXEXT) \
|
||||||
test/benchmark$(EXEXT) \
|
test/benchmark$(EXEXT) \
|
||||||
test/selftest$(EXEXT) test/udp_proxy$(EXEXT) \
|
test/selftest$(EXEXT) test/udp_proxy$(EXEXT) \
|
||||||
test/zeroize$(EXEXT) \
|
test/zeroize$(EXEXT) \
|
||||||
test/query_compile_time_config$(EXEXT) \
|
test/query_compile_time_config$(EXEXT) \
|
||||||
util/pem2der$(EXEXT) util/strerror$(EXEXT) \
|
util/pem2der$(EXEXT) util/strerror$(EXEXT) \
|
||||||
x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \
|
x509/cert_app$(EXEXT) x509/crl_app$(EXEXT) \
|
||||||
x509/cert_req$(EXEXT) x509/cert_write$(EXEXT) \
|
x509/cert_req$(EXEXT) x509/cert_write$(EXEXT) \
|
||||||
|
@ -53,7 +53,28 @@
|
|||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
|
||||||
my $config_file = "include/mbedtls/config.h";
|
my $config_file;
|
||||||
|
my $include_dir;
|
||||||
|
my $library_dir;
|
||||||
|
my $mbedtls_config_file = $ENV{"MBEDTLS_CONFIG_FILE"};
|
||||||
|
|
||||||
|
if ( ( -d "../library") || ( -d "./library") ) {
|
||||||
|
# library directory is present, we are using Mbed TLS namespace
|
||||||
|
$config_file = "include/mbedtls/config.h";
|
||||||
|
$include_dir = "include";
|
||||||
|
$library_dir = "library";
|
||||||
|
} else {
|
||||||
|
# library directory is not present, we are using Mbed OS namespace
|
||||||
|
$config_file = "inc/mbedtls/config.h";
|
||||||
|
$include_dir = "inc";
|
||||||
|
$library_dir = "src";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( length $mbedtls_config_file ) {
|
||||||
|
$mbedtls_config_file = substr $mbedtls_config_file, 1, -1;
|
||||||
|
$config_file = $include_dir . "/" . $mbedtls_config_file;
|
||||||
|
}
|
||||||
|
|
||||||
my $usage = <<EOU;
|
my $usage = <<EOU;
|
||||||
$0 [-f <file> | --file <file>] [-o | --force]
|
$0 [-f <file> | --file <file>] [-o | --force]
|
||||||
[set <symbol> <value> | unset <symbol> | get <symbol> |
|
[set <symbol> <value> | unset <symbol> | get <symbol> |
|
||||||
@ -205,7 +226,7 @@ if (! -f $config_file) {
|
|||||||
chdir '..' or die;
|
chdir '..' or die;
|
||||||
|
|
||||||
# Confirm this is the project root directory and try again
|
# Confirm this is the project root directory and try again
|
||||||
if ( !(-d 'scripts' && -d 'include' && -d 'library' && -f $config_file) ) {
|
if ( !(-d 'scripts' && -d $include_dir && -d $library_dir && -f $config_file) ) {
|
||||||
die "If no file specified, must be run from the project root or scripts directory.\n";
|
die "If no file specified, must be run from the project root or scripts directory.\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,23 @@ CFLAGS ?= -O2
|
|||||||
WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wunused
|
WARNING_CFLAGS ?= -Wall -W -Wdeclaration-after-statement -Wunused
|
||||||
LDFLAGS ?=
|
LDFLAGS ?=
|
||||||
|
|
||||||
LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -D_FILE_OFFSET_BITS=64
|
# Check test environment. If ../library is available then Mbed TLS is used.
|
||||||
LOCAL_LDFLAGS = -L../library \
|
# Otherwise Mbed OS environment is used.
|
||||||
|
DIR_FOR_MBED_TLS_ENV=../library
|
||||||
|
ifneq "$(wildcard $(DIR_FOR_MBED_TLS_ENV) )" ""
|
||||||
|
LIBRARY_DIR=../library
|
||||||
|
INCLUDE_DIR=-I../include
|
||||||
|
else
|
||||||
|
LIBRARY_DIR=../src
|
||||||
|
INCLUDE_DIR=-I.. -I../inc
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_CFLAGS = $(WARNING_CFLAGS) $(INCLUDE_DIR) -D_FILE_OFFSET_BITS=64
|
||||||
|
ifdef MBEDTLS_CONFIG_FILE
|
||||||
|
LOCAL_CFLAGS += "-DMBEDTLS_CONFIG_FILE=\"${MBEDTLS_CONFIG_FILE}\""
|
||||||
|
endif
|
||||||
|
|
||||||
|
LOCAL_LDFLAGS = -L$(LIBRARY_DIR) \
|
||||||
-lmbedtls$(SHARED_SUFFIX) \
|
-lmbedtls$(SHARED_SUFFIX) \
|
||||||
-lmbedx509$(SHARED_SUFFIX) \
|
-lmbedx509$(SHARED_SUFFIX) \
|
||||||
-lmbedcrypto$(SHARED_SUFFIX)
|
-lmbedcrypto$(SHARED_SUFFIX)
|
||||||
@ -18,9 +33,9 @@ LOCAL_LDFLAGS = -L../library \
|
|||||||
LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L
|
LOCAL_CFLAGS += -D_POSIX_C_SOURCE=200809L
|
||||||
|
|
||||||
ifndef SHARED
|
ifndef SHARED
|
||||||
DEP=../library/libmbedcrypto.a ../library/libmbedx509.a ../library/libmbedtls.a
|
DEP=$(LIBRARY_DIR)/libmbedcrypto.a $(LIBRARY_DIR)/libmbedx509.a $(LIBRARY_DIR)/libmbedtls.a
|
||||||
else
|
else
|
||||||
DEP=../library/libmbedcrypto.$(DLEXT) ../library/libmbedx509.$(DLEXT) ../library/libmbedtls.$(DLEXT)
|
DEP=$(LIBRARY_DIR)/libmbedcrypto.$(DLEXT) $(LIBRARY_DIR)/libmbedx509.$(DLEXT) $(LIBRARY_DIR)/libmbedtls.$(DLEXT)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef DEBUG
|
ifdef DEBUG
|
||||||
@ -77,7 +92,7 @@ BINARIES := $(addsuffix $(EXEXT),$(APPS))
|
|||||||
all: $(BINARIES)
|
all: $(BINARIES)
|
||||||
|
|
||||||
$(DEP):
|
$(DEP):
|
||||||
$(MAKE) -C ../library
|
$(MAKE) -C $(LIBRARY_DIR) $(INCLUDE_DIR)
|
||||||
|
|
||||||
C_FILES := $(addsuffix .c,$(APPS))
|
C_FILES := $(addsuffix .c,$(APPS))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user