blob: 5b85ce68b40671a3143f75cf8827c1375a347e52 [file] [log] [blame]
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +01001#!/usr/bin/env bash
2#
Jayanth Dodderi Chidanand7f24bd22022-02-06 12:50:43 +00003# Copyright (c) 2022 Arm Limited. All rights reserved.
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +01004#
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
Paul Sokolovsky3304a3d2024-06-19 13:34:24 +030014this_dir="$(readlink -f "$(dirname "$0")")"
15. $this_dir/common.sh
16
17
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010018LOG_FILE=$(mktemp -t files-detection-check.XXXX)
19TFA_PATCH_NEWFILES_LIST=$(mktemp -t tfa-patch-newfiles-list.XXXX)
20EXIT_VALUE=0
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010021DOC_URL="https://trustedfirmware-a.readthedocs.io/en/latest/process/contributing.html\
22#add-build-configurations"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010023
24# Function : file_updation_report
25# Description : To update the inclusion of files listed in the temp file
26# (tfa-patch-newfiles-list.XXXX) for Coverity Scan Analysis.
27# Return : newly added source files,are captured onto the error log
28# and the Error status is printed.
29function file_updation_report( )
30{
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010031 echo "==============================================================================="
32 echo >> "$LOG_FILE"
33 echo "New source files have been identified in your patch.." | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010034# Iterating through the patch filenames and logging them onto error report.
35 while read filename
36 do
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010037 echo "$filename" | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010038 done < "$TFA_PATCH_NEWFILES_LIST"
39
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010040 echo | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand7f24bd22022-02-06 12:50:43 +000041 echo -e "1. Kindly ensure these newly added source files are covered by : \n\
42 a. Coverity scan analysis by adding them to \"tf-cov-make\" build script with \
43the appropriate build configurations. \n\
44 b. Built as part of one of the platform configurations present in \"tf-l1-build-plat\" \
45test group." | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010046
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010047 echo | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand7f24bd22022-02-06 12:50:43 +000048 echo -e " Please refer to the tf-a documentation for more detailed explanation. \n\
49 \"$DOC_URL\"" | tee -a "$LOG_FILE"
50
51 echo | tee -a "$LOG_FILE"
52 echo -e "2. Please ignore if your files are already updated. Further the Code Maintainer will \n\
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010053 resolve the issue by taking appropriate action." | tee -a "$LOG_FILE"
54 echo "==============================================================================="
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010055
56 EXIT_VALUE=1
57}
58
Jayanth Dodderi Chidananddf2faca2021-09-08 18:17:22 +010059# Detecting source files not analysed by tf-coverity-job in the latest patch.
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010060 echo "# Check to detect whether newly added files are analysed by Coverity in the patch"
61 TEST_CASE="Newly added files detection check for Coverity Scan analysis on patch(es)"
62# Extracting newly added source files added between commits.
Paul Sokolovsky3304a3d2024-06-19 13:34:24 +030063 git diff $(get_merge_base)..HEAD --name-only --diff-filter=A "*.c" &> "$TFA_PATCH_NEWFILES_LIST"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010064 if [ -s "$TFA_PATCH_NEWFILES_LIST" ]
65 then
66 file_updation_report
67 fi
68
69echo >> "$LOG_TEST_FILENAME"
70echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
71echo >> "$LOG_TEST_FILENAME"
72
73if [[ "$EXIT_VALUE" == 0 ]]; then
74 echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME"
75else
76 echo "Result : FAILURE" >> "$LOG_TEST_FILENAME"
77fi
78
79# Printing the script output to show the warnings.
80echo >> "$LOG_TEST_FILENAME"
81cat "$LOG_FILE" >> "$LOG_TEST_FILENAME"
82echo >> "$LOG_TEST_FILENAME"
83
84#Deleting temporary files
85rm -f "$LOG_FILE"
86rm -f "$TFA_PATCH_NEWFILES_LIST"
87
88exit "$EXIT_VALUE"