Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (c) 2019, Arm Limited. All rights reserved. |
| 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | # Check the coding style of the entire source tree against the Linux coding |
| 9 | # style using the checkpatch.pl script from the Linux kernel source tree. |
| 10 | |
| 11 | TEST_CASE="Coding style of entire source tree" |
| 12 | |
| 13 | echo "# Check coding style of the entire source tree" |
| 14 | |
| 15 | LOG_FILE=$(mktemp -t coding-style-check.XXXX) |
| 16 | |
| 17 | # Passing V=1 to 'make checkcodebase' will make it generate a per-file summary |
| 18 | CHECKPATCH=$CI_ROOT/script/static-checks/checkpatch.pl \ |
| 19 | make checkcodebase V=1 &> "$LOG_FILE" |
| 20 | RES=$? |
| 21 | |
| 22 | if [[ "$RES" == 0 ]]; then |
| 23 | # Ignore warnings, only mark the test as failed if there are errors. |
| 24 | # We'll get as many 'total:' lines as the number of files in the source tree. |
| 25 | # Search for lines that show a non-null number of errors. |
| 26 | grep --quiet 'total: [^0][0-9]* errors' "$LOG_FILE" |
| 27 | # grep returns 0 when it founds the pattern, which means there is an error |
| 28 | RES=$? |
| 29 | else |
| 30 | RES=0 |
| 31 | fi |
| 32 | |
| 33 | if [[ "$RES" == 0 ]]; then |
| 34 | EXIT_VALUE=1 |
| 35 | else |
| 36 | EXIT_VALUE=0 |
| 37 | fi |
| 38 | |
| 39 | echo >> "$LOG_TEST_FILENAME" |
| 40 | echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME" |
| 41 | echo >> "$LOG_TEST_FILENAME" |
| 42 | if [[ "$EXIT_VALUE" == 0 ]]; then |
| 43 | echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME" |
| 44 | else |
| 45 | echo "Result : FAILURE" >> "$LOG_TEST_FILENAME" |
| 46 | fi |
| 47 | # Always print the script output to show the warnings |
| 48 | echo >> "$LOG_TEST_FILENAME" |
| 49 | cat "$LOG_FILE" >> "$LOG_TEST_FILENAME" |
| 50 | echo >> "$LOG_TEST_FILENAME" |
| 51 | |
| 52 | rm -f "$LOG_FILE" |
| 53 | |
| 54 | exit "$EXIT_VALUE" |