blob: ded10a2b58f18142beac905fecfff822570e7485 [file] [log] [blame]
Leonardo Sandoval314eed82020-08-05 13:32:04 -05001#!/bin/bash
2#
Xinyu Zhange8015942021-02-22 16:06:00 +08003# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
Leonardo Sandoval314eed82020-08-05 13:32:04 -05004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8# unittest-include-order.sh <path-to-root-folder> [patch]
9
Paul Sokolovsky419c7bb2024-03-12 16:44:45 +070010set -o pipefail
11
Leonardo Sandoval314eed82020-08-05 13:32:04 -050012LOG_FILE=$(mktemp -t include-order-check.XXXX)
13
14if [[ "$2" == "patch" ]]; then
15 echo "# Check order of includes on the last patch"
16 TEST_CASE="Order of includes on the last patch(es)"
17 "$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \
18 --patch --from-ref origin/master \
Xinyu Zhange8015942021-02-22 16:06:00 +080019 | tee "$LOG_FILE"
Leonardo Sandoval314eed82020-08-05 13:32:04 -050020else
21 echo "# Check order of includes of the entire source tree"
22 TEST_CASE="Order of includes of the entire source tree"
23 "$CI_ROOT/script/static-checks/check-include-order.py" --tree "$1" \
Xinyu Zhange8015942021-02-22 16:06:00 +080024 | tee "$LOG_FILE"
Leonardo Sandoval314eed82020-08-05 13:32:04 -050025fi
26
27EXIT_VALUE=$?
28
29echo >> "$LOG_TEST_FILENAME"
30echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
31echo >> "$LOG_TEST_FILENAME"
32if [[ "$EXIT_VALUE" == 0 ]]; then
33 echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME"
34else
35 echo "Result : FAILURE" >> "$LOG_TEST_FILENAME"
36 echo >> "$LOG_TEST_FILENAME"
37 cat "$LOG_FILE" >> "$LOG_TEST_FILENAME"
38fi
39echo >> "$LOG_TEST_FILENAME"
40
41rm -f "$LOG_FILE"
42
43exit "$EXIT_VALUE"