From e06e039f7ae7de8871d7be2e8c6ec8480d0d786b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teppo=20J=C3=A4rvelin?= Date: Mon, 25 Nov 2019 15:22:42 +0200 Subject: [PATCH] Fix basic-build-test.sh to work in different env Also added possibility to run only unit tests --- scripts/config.pl | 14 +++++++----- tests/scripts/basic-build-test.sh | 37 ++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/scripts/config.pl b/scripts/config.pl index 619c5cae8..ff522b623 100755 --- a/scripts/config.pl +++ b/scripts/config.pl @@ -213,11 +213,15 @@ if ( not defined($action) ){ die $usage; } # Check the config file is present if (! -f $config_file) { - chdir '..' or die; - - # Confirm this is the project root directory and try again - if ( !(-d 'scripts' && -d 'include' && -d 'library' && -f $config_file) ) { - die "If no file specified, must be run from the project root or scripts directory.\n"; + if ( -d 'importer' && -d 'inc' && -d 'src') { + $config_file = "inc/mbedtls/config.h"; + } + else { + chdir '..' or die; + # Confirm this is the project root directory and try again + if ( !(-d 'scripts' && -d 'include' && -d 'library' && -f $config_file) ) { + die "If no file specified, must be run from the project root or scripts directory.\n"; + } } } diff --git a/tests/scripts/basic-build-test.sh b/tests/scripts/basic-build-test.sh index 8990dfbea..d559fa522 100755 --- a/tests/scripts/basic-build-test.sh +++ b/tests/scripts/basic-build-test.sh @@ -25,13 +25,37 @@ # # This script has been written to be generic and should work on any shell. # -# Usage: basic-build-tests.sh +# Usage: basic-build-tests.sh to run all tests +# basic-build-tests.sh unit_test to run only unit tests # # Abort on errors (and uninitiliased variables) set -eu -if [ -d library -a -d include -a -d tests ]; then :; else +CONFIG_H='include/mbedtls/config.h' +CONFIG_BAK="$CONFIG_H.bak" + +UNIT_TESTS_ONLY=0 + +echo +if [ -z ${1+x} ] +then + echo "Running all tests" +else + if [ "$1" = "unit_test" ] + then + echo "Running only unit tests" + UNIT_TESTS_ONLY=1 + fi +fi +echo + +# Check test environment. If importer, src and inc folders are present then +# there is a different directory structure and we need to adapt to it. +if [ -d importer -a -d inc -a -d src ]; then + CONFIG_H='inc/mbedtls/config.h' + CONFIG_BAK="$CONFIG_H.bak" +elif [ -d library -a -d include -a -d tests ]; then :; else echo "Must be run from mbed TLS root" >&2 exit 1 fi @@ -49,9 +73,6 @@ export OPENSSL_CMD="$OPENSSL" export GNUTLS_CLI="$GNUTLS_CLI" export GNUTLS_SERV="$GNUTLS_SERV" -CONFIG_H='include/mbedtls/config.h' -CONFIG_BAK="$CONFIG_H.bak" - # Step 0 - print build environment info OPENSSL="$OPENSSL" \ OPENSSL_LEGACY="$OPENSSL_LEGACY" \ @@ -79,6 +100,12 @@ cd tests perl scripts/run-test-suites.pl -v 2 |tee unit-test-$TEST_OUTPUT echo +# only unit test are run? +if [ $UNIT_TESTS_ONLY -eq 1 ] +then + exit 0 +fi + # Step 2b - System Tests sh ssl-opt.sh |tee sys-test-$TEST_OUTPUT echo