mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-12-24 17:41:01 +03:00
Add docker-based test scripts
Enable running tests under Docker. This makes it easier to spin up an environment with all dependencies (especially the multiple versions of openssl and gnutls needed). * tests/docker/xenial/Dockerfile: Definition for the docker image, including local builds for openssl and gnutls. * tests/scripts/docker_env.sh: New helper script that creates the Docker image and has a function to run a command in the Docker container. * tests/docker/all-in-docker.sh: Wrapper for all.sh under Docker. * tests/docker/basic-in-docker.sh: Script that runs the same commands as .travis.yml, in Docker. * tests/ssl-opt-in-docker.sh: Wrapper to run ssl-opt.sh in Docker. * tests/compat-in-docker.sh: Wrapper to run compat.sh in Docker. * tests/make-in-docker.sh: Wrapper to run make in Docker. Change-Id: Ie092b1deed24c24c3859754535589523ce1d0a58
This commit is contained in:
24
tests/scripts/all-in-docker.sh
Executable file
24
tests/scripts/all-in-docker.sh
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
# all-in-docker.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018-2019, ARM Limited, All Rights Reserved
|
||||
#
|
||||
# Purpose
|
||||
# -------
|
||||
# This runs all.sh (except for armcc) in a Docker container.
|
||||
#
|
||||
# Notes for users
|
||||
# ---------------
|
||||
# See docker_env.sh for prerequisites and other information.
|
||||
#
|
||||
# See also all.sh for notes about invocation of that script.
|
||||
|
||||
source tests/scripts/docker_env.sh
|
||||
|
||||
# Run tests that are possible with openly available compilers
|
||||
run_in_docker tests/scripts/all.sh \
|
||||
--no-armcc \
|
||||
$@
|
||||
37
tests/scripts/basic-in-docker.sh
Executable file
37
tests/scripts/basic-in-docker.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
# basic-in-docker.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018-2019, ARM Limited, All Rights Reserved
|
||||
#
|
||||
# Purpose
|
||||
# -------
|
||||
# This runs a rough equivalent of the travis.yml in a Docker container.
|
||||
# The tests are run for both clang and gcc.
|
||||
#
|
||||
# Notes for users
|
||||
# ---------------
|
||||
# See docker_env.sh for prerequisites and other information.
|
||||
|
||||
source tests/scripts/docker_env.sh
|
||||
|
||||
run_in_docker tests/scripts/recursion.pl library/*.c
|
||||
run_in_docker tests/scripts/check-generated-files.sh
|
||||
run_in_docker tests/scripts/check-doxy-blocks.pl
|
||||
run_in_docker tests/scripts/check-names.sh
|
||||
run_in_docker tests/scripts/check-files.py
|
||||
run_in_docker tests/scripts/doxygen.sh
|
||||
|
||||
for compiler in clang gcc; do
|
||||
run_in_docker -e CC=${compiler} cmake -D CMAKE_BUILD_TYPE:String="Check" .
|
||||
run_in_docker -e CC=${compiler} make
|
||||
run_in_docker -e CC=${compiler} make test
|
||||
run_in_docker programs/test/selftest
|
||||
run_in_docker -e OSSL_NO_DTLS=1 tests/compat.sh
|
||||
run_in_docker tests/ssl-opt.sh -e '\(DTLS\|SCSV\).*openssl'
|
||||
run_in_docker tests/scripts/test-ref-configs.pl
|
||||
run_in_docker tests/scripts/curves.pl
|
||||
run_in_docker tests/scripts/key-exchanges.pl
|
||||
done
|
||||
75
tests/scripts/docker_env.sh
Executable file
75
tests/scripts/docker_env.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
# docker_env.sh
|
||||
#
|
||||
# This file is part of mbed TLS (https://tls.mbed.org)
|
||||
#
|
||||
# Copyright (c) 2018-2019, ARM Limited, All Rights Reserved
|
||||
#
|
||||
# Purpose
|
||||
# -------
|
||||
#
|
||||
# This is a helper script to enable running tests under a Docker container,
|
||||
# thus making it easier to get set up as well as isolating test dependencies
|
||||
# (which include legacy/insecure configurations of openssl and gnutls).
|
||||
#
|
||||
# Notes for users
|
||||
# ---------------
|
||||
# This script expects a Linux x86_64 system with a recent version of Docker
|
||||
# installed and available for use, as well as http/https access. If a proxy
|
||||
# server must be used, invoke this script with the usual environment variables
|
||||
# (http_proxy and https_proxy) set appropriately.
|
||||
#
|
||||
# Running this script directly will check for Docker availability and set up
|
||||
# the Docker image.
|
||||
|
||||
|
||||
# default values, can be overridden by the environment
|
||||
: ${MBEDTLS_DOCKER_GUEST:=xenial}
|
||||
|
||||
|
||||
DOCKER_IMAGE_TAG="armmbed/mbedtls-test:${MBEDTLS_DOCKER_GUEST}"
|
||||
|
||||
# Make sure docker is available
|
||||
if ! which docker > /dev/null; then
|
||||
echo "Docker is required but doesn't seem to be installed. See https://www.docker.com/ to get started"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Figure out if we need to 'sudo docker'
|
||||
if groups | grep docker > /dev/null; then
|
||||
DOCKER="docker"
|
||||
else
|
||||
echo "Using sudo to invoke docker since you're not a member of the docker group..."
|
||||
DOCKER="sudo docker"
|
||||
fi
|
||||
|
||||
# Build the Docker image
|
||||
echo "Getting docker image up to date (this may take a few minutes)..."
|
||||
${DOCKER} image build \
|
||||
-t ${DOCKER_IMAGE_TAG} \
|
||||
--cache-from=${DOCKER_IMAGE_TAG} \
|
||||
--build-arg MAKEFLAGS_PARALLEL="-j $(nproc)" \
|
||||
${http_proxy+--build-arg http_proxy=${http_proxy}} \
|
||||
${https_proxy+--build-arg https_proxy=${https_proxy}} \
|
||||
tests/docker/${MBEDTLS_DOCKER_GUEST}
|
||||
|
||||
run_in_docker()
|
||||
{
|
||||
ENV_ARGS=""
|
||||
while [ "$1" == "-e" ]; do
|
||||
ENV_ARGS="${ENV_ARGS} $1 $2"
|
||||
shift 2
|
||||
done
|
||||
|
||||
${DOCKER} container run -it --rm \
|
||||
--cap-add SYS_PTRACE \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
--volume $PWD:$PWD \
|
||||
--workdir $PWD \
|
||||
-e MAKEFLAGS \
|
||||
-e PYLINTHOME=/tmp/.pylintd \
|
||||
${ENV_ARGS} \
|
||||
${DOCKER_IMAGE_TAG} \
|
||||
$@
|
||||
}
|
||||
Reference in New Issue
Block a user