Leonardo Sandoval | 9dfdd1b | 2020-08-06 17:08:11 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 2 | # |
Harrison Mutai | 8c3afa3 | 2022-02-04 09:33:24 +0000 | [diff] [blame] | 3 | # Copyright (c) 2019-2022 Arm Limited. All rights reserved. |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 4 | # |
| 5 | # SPDX-License-Identifier: BSD-3-Clause |
| 6 | # |
| 7 | |
| 8 | # unittest-include-order.sh <path-to-root-folder> [patch] |
| 9 | |
| 10 | LOG_FILE=$(mktemp -t include-order-check.XXXX) |
| 11 | |
| 12 | if [[ "$2" == "patch" ]]; then |
| 13 | echo "# Check order of includes on the last patch" |
| 14 | TEST_CASE="Order of includes on the last patch(es)" |
| 15 | "$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \ |
| 16 | --patch --from-ref origin/master \ |
| 17 | &> "$LOG_FILE" |
| 18 | else |
| 19 | echo "# Check order of includes of the entire source tree" |
| 20 | TEST_CASE="Order of includes of the entire source tree" |
| 21 | "$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \ |
| 22 | &> "$LOG_FILE" |
| 23 | fi |
| 24 | |
| 25 | EXIT_VALUE=$? |
| 26 | |
| 27 | echo >> "$LOG_TEST_FILENAME" |
| 28 | echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME" |
| 29 | echo >> "$LOG_TEST_FILENAME" |
| 30 | if [[ "$EXIT_VALUE" == 0 ]]; then |
| 31 | echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME" |
| 32 | else |
| 33 | echo "Result : FAILURE" >> "$LOG_TEST_FILENAME" |
| 34 | echo >> "$LOG_TEST_FILENAME" |
| 35 | cat "$LOG_FILE" >> "$LOG_TEST_FILENAME" |
Harrison Mutai | 8c3afa3 | 2022-02-04 09:33:24 +0000 | [diff] [blame] | 36 | echo >> "$LOG_TEST_FILENAME" |
| 37 | echo -e "Please refer to the docs for further information on include statement ordering: https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-style.html#include-statement-ordering." >> "$LOG_TEST_FILENAME" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 38 | fi |
| 39 | echo >> "$LOG_TEST_FILENAME" |
| 40 | |
| 41 | rm -f "$LOG_FILE" |
| 42 | |
| 43 | exit "$EXIT_VALUE" |