blob: c7907a60e73d856bf6bc202d02a6582a4f8f53e4 [file] [log] [blame]
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +01001#!/usr/bin/env bash
2#
3# Copyright (c) 2021 Arm Limited. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8# static-checks-detect-newly-added-files.sh
9# This script aims at identifying the newly added source files
10# between the commits.
11# It runs on every TF-A patch and detects the new files and updates
12# the patch contibutor to include them for Coverity Scan analysis.
13
14LOG_FILE=$(mktemp -t files-detection-check.XXXX)
15TFA_PATCH_NEWFILES_LIST=$(mktemp -t tfa-patch-newfiles-list.XXXX)
16EXIT_VALUE=0
17
18# Function : file_updation_report
19# Description : To update the inclusion of files listed in the temp file
20# (tfa-patch-newfiles-list.XXXX) for Coverity Scan Analysis.
21# Return : newly added source files,are captured onto the error log
22# and the Error status is printed.
23function file_updation_report( )
24{
25 echo "========================================================================"
26 echo "New source files have been identified in your patch.."
27 echo >> "$LOG_FILE"
28 echo "New source files have been identified in your patch.." >> "$LOG_FILE"
29# Iterating through the patch filenames and logging them onto error report.
30 while read filename
31 do
32 echo "$filename"
33 echo "$filename" >> "$LOG_FILE"
34 done < "$TFA_PATCH_NEWFILES_LIST"
35
36 echo
37 echo -e "1. Kindly ensure they are updated in the \"tf_cov_make\" build script as \n \
38well to consider them for Coverity Scan analysis."
39 echo >> "$LOG_FILE"
40 echo -e "1. Kindly ensure they are updated in the \"tf_cov_make\" build script as \n \
41well to consider them for Coverity Scan analysis." >> "$LOG_FILE"
42
43 echo
44 echo -e "2. Please ignore if files are already updated. Further the Code Maintainer \n \
45will resolve the issue by taking appropriate action."
46 echo >> "$LOG_FILE"
47 echo -e "2. Please ignore if files are already updated. Further the Code Maintainer \n \
48will resolve the issue by taking appropriate action." >> "$LOG_FILE"
49 echo "========================================================================"
50
51 EXIT_VALUE=1
52}
53
54# Detecting source files not analysed by tf-coverity-job in the latest patch
55 echo "# Check to detect whether newly added files are analysed by Coverity in the patch"
56 TEST_CASE="Newly added files detection check for Coverity Scan analysis on patch(es)"
57# Extracting newly added source files added between commits.
58 git diff origin/master...HEAD --name-only --diff-filter=A "*.c" &> "$TFA_PATCH_NEWFILES_LIST"
59 if [ -s "$TFA_PATCH_NEWFILES_LIST" ]
60 then
61 file_updation_report
62 fi
63
64echo >> "$LOG_TEST_FILENAME"
65echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
66echo >> "$LOG_TEST_FILENAME"
67
68if [[ "$EXIT_VALUE" == 0 ]]; then
69 echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME"
70else
71 echo "Result : FAILURE" >> "$LOG_TEST_FILENAME"
72fi
73
74# Printing the script output to show the warnings.
75echo >> "$LOG_TEST_FILENAME"
76cat "$LOG_FILE" >> "$LOG_TEST_FILENAME"
77echo >> "$LOG_TEST_FILENAME"
78
79#Deleting temporary files
80rm -f "$LOG_FILE"
81rm -f "$TFA_PATCH_NEWFILES_LIST"
82
83exit "$EXIT_VALUE"