From 5e525fb6e55d330c87327467f0a8092e7af1ec76 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 15 May 2019 17:29:15 +0200 Subject: [PATCH 1/4] Print a command trace if the check-names.sh exits unexpectedly We've observed that sometimes check-names.sh exits unexpectedly with status 2 and no error message. The failure is not reproducible. This commits makes the script print a trace if it exits unexpectedly. --- tests/scripts/check-names.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/scripts/check-names.sh b/tests/scripts/check-names.sh index f18a162cc..82ec54a29 100755 --- a/tests/scripts/check-names.sh +++ b/tests/scripts/check-names.sh @@ -16,12 +16,22 @@ if grep --version|head -n1|grep GNU >/dev/null; then :; else exit 1 fi +trace= +if [ $# -ne 0 ] && [ "$1" = "-v" ]; then + shift + trace='-x' + exec 2>check-names.err + trap 'echo "FAILED UNEXPECTEDLY, status=$?"; + cat check-names.err' EXIT + set -x +fi + printf "Analysing source code...\n" -tests/scripts/list-macros.sh +sh $trace tests/scripts/list-macros.sh tests/scripts/list-enum-consts.pl -tests/scripts/list-identifiers.sh -tests/scripts/list-symbols.sh +sh $trace tests/scripts/list-identifiers.sh +sh $trace tests/scripts/list-symbols.sh FAIL=0 @@ -82,6 +92,12 @@ else FAIL=1 fi +if [ -n "$trace" ]; then + set +x + trap - EXIT + rm check-names.err +fi + printf "\nOverall: " if [ "$FAIL" -eq 0 ]; then rm macros actual-macros enum-consts identifiers exported-symbols From 473f2d4ec28c17d8887fb7d16502e099a1b76bae Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 15 May 2019 17:52:22 +0200 Subject: [PATCH 2/4] all.sh: invoke check-names.sh in print-trace-on-exit mode --- tests/scripts/all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index 44df16249..936c665a1 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -576,7 +576,7 @@ component_check_files () { component_check_names () { msg "test/build: declared and exported names" # < 3s - record_status tests/scripts/check-names.sh + record_status tests/scripts/check-names.sh -v } component_check_doxygen_warnings () { From 902a1f3f7f626fdc3af1a498364931538ff0da83 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 22 May 2019 18:22:45 +0200 Subject: [PATCH 3/4] Document "check-names.sh -v" --- tests/scripts/check-names.sh | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/scripts/check-names.sh b/tests/scripts/check-names.sh index 82ec54a29..90ecfd272 100755 --- a/tests/scripts/check-names.sh +++ b/tests/scripts/check-names.sh @@ -2,15 +2,21 @@ # # This file is part of mbed TLS (https://tls.mbed.org) # -# Copyright (c) 2015-2016, ARM Limited, All Rights Reserved -# -# Purpose -# -# This script confirms that the naming of all symbols and identifiers in mbed -# TLS are consistent with the house style and are also self-consistent. -# +# Copyright (c) 2015-2019, ARM Limited, All Rights Reserved + set -eu +if [ $# -ne 0 ] && [ "$1" = "--help" ]; then + cat </dev/null; then :; else echo "This script requires GNU grep.">&2 exit 1 From 39d7c58db5542e532d8b699b0093f41b6d7cf82d Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Wed, 22 May 2019 18:22:58 +0200 Subject: [PATCH 4/4] list-symbols.sh: if the build fails, print the build transcript If "make clean lib" fails in list-symbols.sh, print the transcript from running make. --- tests/scripts/list-symbols.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/scripts/list-symbols.sh b/tests/scripts/list-symbols.sh index c25871942..ffdce8f35 100755 --- a/tests/scripts/list-symbols.sh +++ b/tests/scripts/list-symbols.sh @@ -14,8 +14,20 @@ fi cp include/mbedtls/config.h include/mbedtls/config.h.bak scripts/config.pl full -CFLAGS=-fno-asynchronous-unwind-tables make clean lib >/dev/null 2>&1 +make_ret= +CFLAGS=-fno-asynchronous-unwind-tables make clean lib \ + >list-symbols.make.log 2>&1 || + { + make_ret=$? + echo "Build failure: CFLAGS=-fno-asynchronous-unwind-tables make clean lib" + cat list-symbols.make.log >&2 + } +rm list-symbols.make.log mv include/mbedtls/config.h.bak include/mbedtls/config.h +if [ -n "$make_ret" ]; then + exit "$make_ret" +fi + if uname | grep -F Darwin >/dev/null; then nm -gUj library/libmbed*.a 2>/dev/null | sed -n -e 's/^_//p' elif uname | grep -F Linux >/dev/null; then