blob: 5ddf041ff637610a902d4b8f961ad7fea6767491 [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
14LOG_FILE=$(mktemp -t files-detection-check.XXXX)
15TFA_PATCH_NEWFILES_LIST=$(mktemp -t tfa-patch-newfiles-list.XXXX)
16EXIT_VALUE=0
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010017DOC_URL="https://trustedfirmware-a.readthedocs.io/en/latest/process/contributing.html\
18#add-build-configurations"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010019
20# Function : file_updation_report
21# Description : To update the inclusion of files listed in the temp file
22# (tfa-patch-newfiles-list.XXXX) for Coverity Scan Analysis.
23# Return : newly added source files,are captured onto the error log
24# and the Error status is printed.
25function file_updation_report( )
26{
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010027 echo "==============================================================================="
28 echo >> "$LOG_FILE"
29 echo "New source files have been identified in your patch.." | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010030# Iterating through the patch filenames and logging them onto error report.
31 while read filename
32 do
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010033 echo "$filename" | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010034 done < "$TFA_PATCH_NEWFILES_LIST"
35
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010036 echo | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand7f24bd22022-02-06 12:50:43 +000037 echo -e "1. Kindly ensure these newly added source files are covered by : \n\
38 a. Coverity scan analysis by adding them to \"tf-cov-make\" build script with \
39the appropriate build configurations. \n\
40 b. Built as part of one of the platform configurations present in \"tf-l1-build-plat\" \
41test group." | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010042
Jayanth Dodderi Chidanand718b37b2021-09-14 01:34:02 +010043 echo | tee -a "$LOG_FILE"
Jayanth Dodderi Chidanand7f24bd22022-02-06 12:50:43 +000044 echo -e " Please refer to the tf-a documentation for more detailed explanation. \n\
45 \"$DOC_URL\"" | tee -a "$LOG_FILE"
46
47 echo | tee -a "$LOG_FILE"
48 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 +010049 resolve the issue by taking appropriate action." | tee -a "$LOG_FILE"
50 echo "==============================================================================="
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010051
52 EXIT_VALUE=1
53}
54
Jayanth Dodderi Chidananddf2faca2021-09-08 18:17:22 +010055# Detecting source files not analysed by tf-coverity-job in the latest patch.
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010056 echo "# Check to detect whether newly added files are analysed by Coverity in the patch"
57 TEST_CASE="Newly added files detection check for Coverity Scan analysis on patch(es)"
58# Extracting newly added source files added between commits.
Jayanth Dodderi Chidananddf2faca2021-09-08 18:17:22 +010059 git diff origin/integration...HEAD --name-only --diff-filter=A "*.c" &> "$TFA_PATCH_NEWFILES_LIST"
Jayanth Dodderi Chidanand5132cb12021-08-09 17:54:47 +010060 if [ -s "$TFA_PATCH_NEWFILES_LIST" ]
61 then
62 file_updation_report
63 fi
64
65echo >> "$LOG_TEST_FILENAME"
66echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME"
67echo >> "$LOG_TEST_FILENAME"
68
69if [[ "$EXIT_VALUE" == 0 ]]; then
70 echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME"
71else
72 echo "Result : FAILURE" >> "$LOG_TEST_FILENAME"
73fi
74
75# Printing the script output to show the warnings.
76echo >> "$LOG_TEST_FILENAME"
77cat "$LOG_FILE" >> "$LOG_TEST_FILENAME"
78echo >> "$LOG_TEST_FILENAME"
79
80#Deleting temporary files
81rm -f "$LOG_FILE"
82rm -f "$TFA_PATCH_NEWFILES_LIST"
83
84exit "$EXIT_VALUE"