From 7efa8cf4560194bd6811c259f5ad34919a38effc Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 21 Mar 2018 10:04:49 +0100 Subject: [PATCH 1/4] all.sh: option parsing: reduce vertical spread Only whitespace changes. --- tests/scripts/all.sh | 69 ++++++++++---------------------------------- 1 file changed, 15 insertions(+), 54 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 9728bd52ae..d6a0a415bd 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -186,60 +186,21 @@ check_tools() while [ $# -gt 0 ]; do case "$1" in - --armcc) - RUN_ARMCC=1 - ;; - --force|-f) - FORCE=1 - ;; - --gnutls-cli) - shift - GNUTLS_CLI="$1" - ;; - --gnutls-legacy-cli) - shift - GNUTLS_LEGACY_CLI="$1" - ;; - --gnutls-legacy-serv) - shift - GNUTLS_LEGACY_SERV="$1" - ;; - --gnutls-serv) - shift - GNUTLS_SERV="$1" - ;; - --help|-h) - usage - exit - ;; - --keep-going|-k) - KEEP_GOING=1 - ;; - --memory|-m) - MEMORY=1 - ;; - --no-armcc) - RUN_ARMCC=0 - ;; - --openssl) - shift - OPENSSL="$1" - ;; - --openssl-legacy) - shift - OPENSSL_LEGACY="$1" - ;; - --out-of-source-dir) - shift - OUT_OF_SOURCE_DIR="$1" - ;; - --release-test|-r) - RELEASE=1 - ;; - --seed|-s) - shift - SEED="$1" - ;; + --armcc) RUN_ARMCC=1;; + --force|-f) FORCE=1;; + --gnutls-cli) shift; GNUTLS_CLI="$1";; + --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; + --gnutls-legacy-serv) shift; GNUTLS_LEGACY_SERV="$1";; + --gnutls-serv) shift; GNUTLS_SERV="$1";; + --help|-h) usage; exit;; + --keep-going|-k) KEEP_GOING=1;; + --memory|-m) MEMORY=1;; + --no-armcc) RUN_ARMCC=0;; + --openssl) shift; OPENSSL="$1";; + --openssl-legacy) shift; OPENSSL_LEGACY="$1";; + --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; + --release-test|-r) RELEASE=1;; + --seed|-s) shift; SEED="$1";; *) echo >&2 "Unknown option: $1" echo >&2 "Run $0 --help for usage." From 243bb4ce6503a239a74a342e4c3ef6d9744c04e1 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 21 Mar 2018 08:40:26 +0100 Subject: [PATCH 2/4] all.sh: add opposites to all boolean options All options can now be overridden by a subsequent option, e.g. "all.sh --foo --no-foo" is equivalent to "all.sh --no-foo". This allows making wrapper scripts with default options and occasionally overriding those options when running the wrapper script. --- tests/scripts/all.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index d6a0a415bd..34954eaa0a 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -90,7 +90,6 @@ CONFIG_BAK="$CONFIG_H.bak" MEMORY=0 FORCE=0 KEEP_GOING=0 -RELEASE=0 RUN_ARMCC=1 # Default commands, can be overriden by the environment @@ -114,7 +113,11 @@ General options: -m|--memory Additional optional memory tests. --armcc Run ARM Compiler builds (on by default). --no-armcc Skip ARM Compiler builds. + --no-force Refuse to overwrite modified files (default). + --no-keep-going Stop at the first error (default). + --no-memory No additional memory tests (default). --out-of-source-dir= Directory used for CMake out-of-source build tests. + --random-seed Use a random seed value for randomized tests (default). -r|--release-test Run this script in release mode. This fixes the seed value to 1. -s|--seed Integer seed value to use for this test run. @@ -196,10 +199,14 @@ while [ $# -gt 0 ]; do --keep-going|-k) KEEP_GOING=1;; --memory|-m) MEMORY=1;; --no-armcc) RUN_ARMCC=0;; + --no-force) FORCE=0;; + --no-keep-going) KEEP_GOING=0;; + --no-memory) MEMORY=0;; --openssl) shift; OPENSSL="$1";; --openssl-legacy) shift; OPENSSL_LEGACY="$1";; --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; - --release-test|-r) RELEASE=1;; + --random-seed) unset SEED;; + --release-test|-r) SEED=1;; --seed|-s) shift; SEED="$1";; *) echo >&2 "Unknown option: $1" @@ -303,11 +310,6 @@ if_build_succeeded () { fi } -if [ $RELEASE -eq 1 ]; then - # Fix the seed value to 1 to ensure that the tests are deterministic. - SEED=1 -fi - msg "info: $0 configuration" echo "MEMORY: $MEMORY" echo "FORCE: $FORCE" @@ -326,7 +328,9 @@ export GNUTLS_CLI="$GNUTLS_CLI" export GNUTLS_SERV="$GNUTLS_SERV" # Avoid passing --seed flag in every call to ssl-opt.sh -[ ! -z ${SEED+set} ] && export SEED +if [ -n "${SEED-}" ]; then + export SEED +fi # Make sure the tools we need are available. check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \ From 32d9293dcf2875176d0d2288f1c51a9424a30dc7 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 21 Mar 2018 10:14:05 +0100 Subject: [PATCH 3/4] all.sh: add --no-yotta for compatibility with later Mbed TLS Allow scripts to run all.sh --no-yotta unconditionally. --no-yotta just happens to be a no-op in 2.1 since 2.1's all.sh doesn't do anything with Yotta. --- tests/scripts/all.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 34954eaa0a..5c9ea8d3df 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -116,6 +116,7 @@ General options: --no-force Refuse to overwrite modified files (default). --no-keep-going Stop at the first error (default). --no-memory No additional memory tests (default). + --no-yotta Ignored for compatibility with other Mbed TLS versions. --out-of-source-dir= Directory used for CMake out-of-source build tests. --random-seed Use a random seed value for randomized tests (default). -r|--release-test Run this script in release mode. This fixes the seed value to 1. @@ -202,6 +203,7 @@ while [ $# -gt 0 ]; do --no-force) FORCE=0;; --no-keep-going) KEEP_GOING=0;; --no-memory) MEMORY=0;; + --no-yotta) :;; # No Yotta support anyway, so just ignore --no-yotta --openssl) shift; OPENSSL="$1";; --openssl-legacy) shift; OPENSSL_LEGACY="$1";; --out-of-source-dir) shift; OUT_OF_SOURCE_DIR="$1";; From 37c88db612216bd764d29d3c0c9d4ea31259496a Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 21 Mar 2018 11:44:52 +0100 Subject: [PATCH 4/4] all.sh: support armcc path options for compatibility with later Mbed TLS Use $ARMC5_BIN_DIR or --armc5-bin-dir to set the location of armcc (version 5), for compatibility with later versions of Mbed TLS. Ignore --armc6-bin-dir for the same reason, since in 2.1 we only test with a single version of armcc and we expect version 5. Keep defaulting to armcc in the $PATH for backward compatibility with the 2.1 branch. --- tests/scripts/all.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 5c9ea8d3df..4e523385d8 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -123,6 +123,8 @@ General options: -s|--seed Integer seed value to use for this test run. Tool path options: + --armc5-bin-dir= ARM Compiler 5 bin directory. + --armc6-bin-dir= Ignored for compatibility with other Mbed TLS versions. --gnutls-cli= GnuTLS client executable to use for most tests. --gnutls-serv= GnuTLS server executable to use for most tests. --gnutls-legacy-cli= GnuTLS client executable to use for legacy tests. @@ -191,6 +193,8 @@ check_tools() while [ $# -gt 0 ]; do case "$1" in --armcc) RUN_ARMCC=1;; + --armc5-bin-dir) shift; ARMC5_BIN_DIR="$1";; + --armc6-bin-dir) shift;; # Ignore for compatibility with later Mbed TLS versions --force|-f) FORCE=1;; --gnutls-cli) shift; GNUTLS_CLI="$1";; --gnutls-legacy-cli) shift; GNUTLS_LEGACY_CLI="$1";; @@ -322,6 +326,15 @@ echo "GNUTLS_CLI: $GNUTLS_CLI" echo "GNUTLS_SERV: $GNUTLS_SERV" echo "GNUTLS_LEGACY_CLI: $GNUTLS_LEGACY_CLI" echo "GNUTLS_LEGACY_SERV: $GNUTLS_LEGACY_SERV" +echo "ARMC5_BIN_DIR: ${ARMC5_BIN_DIR:-UNSET}" + +if [ -n "${ARMC5_BIN_DIR-}" ]; then + ARMC5_CC="$ARMC5_BIN_DIR/armcc" + ARMC5_AR="$ARMC5_BIN_DIR/armar" +else + ARMC5_CC=armcc + ARMC5_AR=armar +fi # To avoid setting OpenSSL and GnuTLS for each call to compat.sh and ssl-opt.sh # we just export the variables they require @@ -339,7 +352,7 @@ check_tools "$OPENSSL" "$OPENSSL_LEGACY" "$GNUTLS_CLI" "$GNUTLS_SERV" \ "$GNUTLS_LEGACY_CLI" "$GNUTLS_LEGACY_SERV" "doxygen" "dot" \ "arm-none-eabi-gcc" if [ $RUN_ARMCC -ne 0 ]; then - check_tools "armcc" + check_tools "$ARMC5_CC" "$ARMC5_AR" fi @@ -578,7 +591,7 @@ if [ $RUN_ARMCC -ne 0 ]; then scripts/config.pl unset MBEDTLS_THREADING_C scripts/config.pl unset MBEDTLS_MEMORY_BACKTRACE # execinfo.h scripts/config.pl unset MBEDTLS_MEMORY_BUFFER_ALLOC_C # calls exit - make CC=armcc AR=armar WARNING_CFLAGS= lib + make CC="$ARMC5_CC" AR="$ARMC5_AR" WARNING_CFLAGS= lib fi msg "build: allow SHA1 in certificates by default"