blob: 169e1ff11673cd9d198dda1109b23fadbc9e1329 [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Harrison Mutai8c3afa32022-02-04 09:33:24 +00003# Copyright (c) 2019-2022 Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8# unittest-include-order.sh <path-to-root-folder> [patch]
9
10LOG_FILE=$(mktemp -t include-order-check.XXXX)
11
12if [[ "$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" \
Paul Sokolovsky6e1f62a2024-06-13 18:20:03 +030016 --patch --from-ref "refs/heads/$TF_GERRIT_BRANCH" \
Fathi Boudra422bf772019-12-02 11:10:16 +020017 &> "$LOG_FILE"
18else
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"
23fi
24
25EXIT_VALUE=$?
26
27echo >> "$LOG_TEST_FILENAME"
28echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
29echo >> "$LOG_TEST_FILENAME"
30if [[ "$EXIT_VALUE" == 0 ]]; then
31 echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME"
32else
33 echo "Result : FAILURE" >> "$LOG_TEST_FILENAME"
34 echo >> "$LOG_TEST_FILENAME"
35 cat "$LOG_FILE" >> "$LOG_TEST_FILENAME"
Harrison Mutai8c3afa32022-02-04 09:33:24 +000036 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 Boudra422bf772019-12-02 11:10:16 +020038fi
39echo >> "$LOG_TEST_FILENAME"
40
41rm -f "$LOG_FILE"
42
43exit "$EXIT_VALUE"