| 1 | #! /bin/bash |
| 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | # You may not use this file except in compliance with the License. |
| 6 | # A copy of the License is located at |
| 7 | # |
| 8 | # http://aws.amazon.com/apache2.0 |
| 9 | # |
| 10 | # or in the "license" file accompanying this file. This file is distributed |
| 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | # express or implied. See the License for the specific language governing |
| 13 | # permissions and limitations under the License. |
| 14 | # |
| 15 | |
| 16 | set -eu |
| 17 | |
| 18 | which KWStyle |
| 19 | |
| 20 | S2N_FILES=$(find "$PWD" -type f -name "s2n_*.[ch]" | grep -v "test") |
| 21 | FAILED=0 |
| 22 | |
| 23 | for file in $S2N_FILES; do |
| 24 | set +e |
| 25 | ERROR_LIST=$(KWStyle -gcc -v -xml codebuild/bin/KWStyle.xml "$file") |
| 26 | set -e |
| 27 | if [ "$ERROR_LIST" != "" ] ; |
| 28 | then |
| 29 | echo "$ERROR_LIST" |
| 30 | FAILED=1 |
| 31 | fi |
| 32 | done |
| 33 | |
| 34 | if [ $FAILED == 1 ]; |
| 35 | then |
| 36 | printf "\\033[31;1mFAILED kwstyle\\033[0m\\n" |
| 37 | exit -1 |
| 38 | else |
| 39 | printf "\\033[32;1mPASSED kwstyle\\033[0m\\n" |
| 40 | fi |