From 20b1f0809ad3401851c06bfdaa5939b8fcb1b12f Mon Sep 17 00:00:00 2001 From: Alex Parent Date: Mon, 14 Nov 2016 16:27:01 -0500 Subject: [PATCH 1/3] Revert the previous change in 250681196f Make style check fail when astyle fails. --- .travis-banned-functions-check.sh | 2 ++ .travis-global-namespace-check.sh | 2 ++ .travis-style-check.sh | 13 +++++++++++-- .travis.yml | 20 ++++++++++++++++---- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.travis-banned-functions-check.sh b/.travis-banned-functions-check.sh index c64ae670c2..14e1596176 100755 --- a/.travis-banned-functions-check.sh +++ b/.travis-banned-functions-check.sh @@ -6,6 +6,7 @@ if [[ $(find -E . -name '*.[ch]' -exec grep -H bzero {} \;) ]]; then tput setaf 1; echo "Code uses banned functions (bzero)."; + tput sgr 0 retvalue=1; fi; @@ -15,6 +16,7 @@ if [[ $retvalue == 0 ]]; then tput setaf 2; echo "Code does not use banned functions."; + tput sgr 0 fi; exit $retvalue; diff --git a/.travis-global-namespace-check.sh b/.travis-global-namespace-check.sh index 40daba6697..f5b9a966f4 100755 --- a/.travis-global-namespace-check.sh +++ b/.travis-global-namespace-check.sh @@ -4,10 +4,12 @@ if [[ $(nm -g liboqs.a | grep ' T ' | grep -E -v -i ' T [_]?OQS') ]]; then tput setaf 1; echo "Code contains the following non-namespaced global symbols; see https://github.com/open-quantum-safe/liboqs/wiki/Coding-conventions for function naming conventions."; + tput sgr 0 nm -g liboqs.a | grep ' T ' | grep -E -v -i ' T [_]?OQS' exit 1; else tput setaf 2; echo "Code adheres to the project standards."; + tput sgr 0 exit 0; fi; diff --git a/.travis-style-check.sh b/.travis-style-check.sh index 9b0c30ba6b..f61dd39d9d 100755 --- a/.travis-style-check.sh +++ b/.travis-style-check.sh @@ -1,12 +1,21 @@ #!/bin/bash -if [[ $(make prettyprint | grep Formatted) ]]; -then +make prettyprint | grep -q Formatted +STATUS=(${PIPESTATUS[*]}) + +if [ ${STATUS[1]} == 0 ]; then tput setaf 1; echo "Code does not adhere to the project standards. Run \"make prettyprint\"."; + tput sgr 0; + exit 1; +elif [ ${STATUS[0]} != 0 ]; then + tput setaf 1; + echo "prettyprint failed."; + tput sgr 0; exit 1; else tput setaf 2; echo "Code adheres to the project standards."; + tput sgr 0; exit 0; fi; diff --git a/.travis.yml b/.travis.yml index 10dd4813ed..dc41ec404a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,10 @@ matrix: - ubuntu-toolchain-r-test packages: - gcc-4.8 - - astyle + before_install: + - wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz + - tar xzf astyle_2.05.1_linux.tar.gz + - cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../ - os: linux compiler: gcc env: CC_OQS=gcc-4.9 @@ -22,7 +25,10 @@ matrix: - ubuntu-toolchain-r-test packages: - gcc-4.9 - - astyle + before_install: + - wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz + - tar xzf astyle_2.05.1_linux.tar.gz + - cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../ - os: linux compiler: gcc env: CC_OQS=gcc-5 @@ -32,7 +38,10 @@ matrix: - ubuntu-toolchain-r-test packages: - gcc-5 - - astyle + before_install: + - wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz + - tar xzf astyle_2.05.1_linux.tar.gz + - cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../ - os: linux compiler: gcc env: CC_OQS=gcc-6 USE_OPENSSL=1 @@ -42,8 +51,11 @@ matrix: - ubuntu-toolchain-r-test packages: - gcc-6 - - astyle - libssl-dev + before_install: + - wget http://downloads.sourceforge.net/project/astyle/astyle/astyle%202.05.1/astyle_2.05.1_linux.tar.gz + - tar xzf astyle_2.05.1_linux.tar.gz + - cd astyle/build/gcc && make && export PATH=$(pwd)/bin:$PATH && cd ../../../ - os: osx compiler: clang env: CC_OQS=clang AES_NI=0 USE_OPENSSL=1 From 4c3ec162aff3d5951498e2260cfda32aec07de22 Mon Sep 17 00:00:00 2001 From: Alex Parent Date: Wed, 16 Nov 2016 11:02:25 -0500 Subject: [PATCH 2/3] Remove -E option from find. Not necessary for the regex and not compatible with the linux(GNU) version of find. --- .travis-banned-functions-check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis-banned-functions-check.sh b/.travis-banned-functions-check.sh index 14e1596176..48ae7e2142 100755 --- a/.travis-banned-functions-check.sh +++ b/.travis-banned-functions-check.sh @@ -2,7 +2,7 @@ retvalue=0 -if [[ $(find -E . -name '*.[ch]' -exec grep -H bzero {} \;) ]]; +if [[ $(find . -name '*.[ch]' -exec grep -H bzero {} \;) ]]; then tput setaf 1; echo "Code uses banned functions (bzero)."; From 96ff4c2bd272880b4904e60264b652ac46e8e939 Mon Sep 17 00:00:00 2001 From: Alex Parent Date: Thu, 17 Nov 2016 15:24:10 -0500 Subject: [PATCH 3/3] Write the name of the test which was was passed. --- .travis-global-namespace-check.sh | 2 +- .travis-style-check.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis-global-namespace-check.sh b/.travis-global-namespace-check.sh index f5b9a966f4..3824f220f0 100755 --- a/.travis-global-namespace-check.sh +++ b/.travis-global-namespace-check.sh @@ -9,7 +9,7 @@ then exit 1; else tput setaf 2; - echo "Code adheres to the project standards."; + echo "Code adheres to the project standards (global namespace)."; tput sgr 0 exit 0; fi; diff --git a/.travis-style-check.sh b/.travis-style-check.sh index f61dd39d9d..9764382be5 100755 --- a/.travis-style-check.sh +++ b/.travis-style-check.sh @@ -15,7 +15,7 @@ elif [ ${STATUS[0]} != 0 ]; then exit 1; else tput setaf 2; - echo "Code adheres to the project standards."; + echo "Code adheres to the project standards (prettyprint)."; tput sgr 0; exit 0; fi;