blob: bd31e2dad50ff02a6aa3d544b41e1e909ac12b48 [file] [log] [blame]
Leonardo Sandoval314eed82020-08-05 13:32:04 -05001#!/bin/bash
2#
3# Copyright (c) 2019, Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8TEST_CASE="Line endings not valid"
9
10EXIT_VALUE=0
11
12echo "# Check Line Endings"
13
14LOG_FILE=$(mktemp -t common.XXXX)
15
16if [[ "$2" == "patch" ]]; then
17 cd "$1"
Leonardo Sandoval900de582020-09-07 18:34:57 -050018 parent=$(git merge-base HEAD origin/master | head -1)
Leonardo Sandoval314eed82020-08-05 13:32:04 -050019 git diff ${parent}..HEAD --no-ext-diff --unified=0 --exit-code -a --no-prefix | grep -E "^\+" | \
20 grep --files-with-matches $'\r$' &> "$LOG_FILE"
21else
22 # For all the source and doc files
23 # We only return the files that contain CRLF
24 find "." -\( \
25 -name '*.S' -or \
26 -name '*.c' -or \
27 -name '*.h' -or \
28 -name '*.i' -or \
29 -name '*.dts' -or \
30 -name '*.dtsi' -or \
31 -name '*.rst' -or \
32 -name 'Makefile' -or \
33 -name '*.mk' \
34 -\) -exec grep --files-with-matches $'\r$' {} \; &> "$LOG_FILE"
35fi
36
37if [[ -s "$LOG_FILE" ]]; then
38 EXIT_VALUE=1
39fi
40
41{ echo; echo "****** $TEST_CASE ******"; echo; } >> "$LOG_TEST_FILENAME"
42
43{ if [[ "$EXIT_VALUE" == 0 ]]; then \
44 echo "Result : SUCCESS"; \
45 else \
46 echo "Result : FAILURE"; echo; cat "$LOG_FILE"; \
47 fi \
48} | tee -a "$LOG_TEST_FILENAME"
49
50rm "$LOG_FILE"
51
52exit "$EXIT_VALUE"