blob: 1c074ef24b64a4652ae30c13e814311483e4ee1f [file] [log] [blame]
Leonardo Sandoval9dfdd1b2020-08-06 17:08:11 -05001#!/usr/bin/env bash
Fathi Boudra422bf772019-12-02 11:10:16 +02002#
Leonardo Sandoval579c7372020-10-23 15:23:32 -05003# Copyright (c) 2019-2020 Arm Limited. All rights reserved.
Fathi Boudra422bf772019-12-02 11:10:16 +02004#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8# Check the coding style of the current patch (not the entire code base)
9# against the Linux coding style using the checkpatch.pl script from
10# the Linux kernel source tree.
11
12TEST_CASE="Coding style on current patch"
13
14echo "# Check coding style on the last patch"
15
16git show --summary
17
18LOG_FILE=$(mktemp -t coding-style-check.XXXX)
19
Fathi Boudra422bf772019-12-02 11:10:16 +020020chmod +x $CI_ROOT/script/static-checks/checkpatch.pl
21
22CHECKPATCH=$CI_ROOT/script/static-checks/checkpatch.pl \
Paul Sokolovsky8abdac72024-06-17 13:40:05 +030023 make checkpatch BASE_COMMIT=HEAD^ &> "$LOG_FILE"
Fathi Boudra422bf772019-12-02 11:10:16 +020024RES=$?
25
26if [[ "$RES" == 0 ]]; then
27 # Ignore warnings, only mark the test as failed if there are errors.
28 grep --quiet "total: [^0][0-9]* errors" "$LOG_FILE"
29 RES=$?
30else
31 RES=0
32fi
33
34if [[ "$RES" == 0 ]]; then
35 EXIT_VALUE=1
36else
37 EXIT_VALUE=0
38fi
39
40echo >> "$LOG_TEST_FILENAME"
41echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
42echo >> "$LOG_TEST_FILENAME"
43if [[ "$EXIT_VALUE" == 0 ]]; then
44 echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME"
45else
46 echo "Result : FAILURE" >> "$LOG_TEST_FILENAME"
47fi
48# Always print the script output to show the warnings
49echo >> "$LOG_TEST_FILENAME"
50cat "$LOG_FILE" >> "$LOG_TEST_FILENAME"
51echo >> "$LOG_TEST_FILENAME"
52
53rm -f "$LOG_FILE"
54
55exit "$EXIT_VALUE"