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 | |
Paul Sokolovsky | 5abd138 | 2024-06-19 13:34:24 +0300 | [diff] [blame] | 10 | this_dir="$(readlink -f "$(dirname "$0")")" |
| 11 | . $this_dir/common.sh |
| 12 | |
| 13 | |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 14 | LOG_FILE=$(mktemp -t include-order-check.XXXX) |
| 15 | |
| 16 | if [[ "$2" == "patch" ]]; then |
Paul Sokolovsky | 5abd138 | 2024-06-19 13:34:24 +0300 | [diff] [blame] | 17 | TEST_CASE="Order of includes on the patch series" |
| 18 | echo "# $TEST_CASE" |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 19 | "$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \ |
Paul Sokolovsky | 5abd138 | 2024-06-19 13:34:24 +0300 | [diff] [blame] | 20 | --patch --from-ref $(get_merge_base) \ |
Fathi Boudra | 422bf77 | 2019-12-02 11:10:16 +0200 | [diff] [blame] | 21 | &> "$LOG_FILE" |
| 22 | else |
| 23 | echo "# Check order of includes of the entire source tree" |
| 24 | TEST_CASE="Order of includes of the entire source tree" |
| 25 | "$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \ |
| 26 | &> "$LOG_FILE" |
| 27 | fi |
| 28 | |
| 29 | EXIT_VALUE=$? |
| 30 | |
| 31 | echo >> "$LOG_TEST_FILENAME" |
| 32 | echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME" |
| 33 | echo >> "$LOG_TEST_FILENAME" |
| 34 | if [[ "$EXIT_VALUE" == 0 ]]; then |
| 35 | echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME" |
| 36 | else |
| 37 | echo "Result : FAILURE" >> "$LOG_TEST_FILENAME" |
| 38 | echo >> "$LOG_TEST_FILENAME" |
| 39 | cat "$LOG_FILE" >> "$LOG_TEST_FILENAME" |
Harrison Mutai | 8c3afa3 | 2022-02-04 09:33:24 +0000 | [diff] [blame] | 40 | echo >> "$LOG_TEST_FILENAME" |
| 41 | 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] | 42 | fi |
| 43 | echo >> "$LOG_TEST_FILENAME" |
| 44 | |
| 45 | rm -f "$LOG_FILE" |
| 46 | |
| 47 | exit "$EXIT_VALUE" |