Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 1 | #!/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 | |
| 14 | LOG_FILE=$(mktemp -t files-detection-check.XXXX) |
| 15 | TFA_PATCH_NEWFILES_LIST=$(mktemp -t tfa-patch-newfiles-list.XXXX) |
| 16 | EXIT_VALUE=0 |
Jayanth Dodderi Chidanand | 718b37b | 2021-09-14 01:34:02 +0100 | [diff] [blame^] | 17 | DOC_URL="https://trustedfirmware-a.readthedocs.io/en/latest/process/contributing.html\ |
| 18 | #add-build-configurations" |
Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 19 | |
| 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. |
| 25 | function file_updation_report( ) |
| 26 | { |
Jayanth Dodderi Chidanand | 718b37b | 2021-09-14 01:34:02 +0100 | [diff] [blame^] | 27 | echo "===============================================================================" |
| 28 | echo >> "$LOG_FILE" |
| 29 | echo "New source files have been identified in your patch.." | tee -a "$LOG_FILE" |
Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 30 | # Iterating through the patch filenames and logging them onto error report. |
| 31 | while read filename |
| 32 | do |
Jayanth Dodderi Chidanand | 718b37b | 2021-09-14 01:34:02 +0100 | [diff] [blame^] | 33 | echo "$filename" | tee -a "$LOG_FILE" |
Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 34 | done < "$TFA_PATCH_NEWFILES_LIST" |
| 35 | |
Jayanth Dodderi Chidanand | 718b37b | 2021-09-14 01:34:02 +0100 | [diff] [blame^] | 36 | echo | tee -a "$LOG_FILE" |
| 37 | echo -e "1. Kindly ensure they are updated in the \"tf-cov-make\" build script as well to \n\ |
| 38 | consider them for Coverity Scan analysis. Please refer to the tf-a documentation \n\ |
| 39 | \"$DOC_URL\" \n for more detailed explanation on adding your new build configurations." \ |
| 40 | | tee -a "$LOG_FILE" |
Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 41 | |
Jayanth Dodderi Chidanand | 718b37b | 2021-09-14 01:34:02 +0100 | [diff] [blame^] | 42 | echo | tee -a "$LOG_FILE" |
| 43 | echo -e "2. Please ignore if files are already updated. Further the Code Maintainer will \n\ |
| 44 | resolve the issue by taking appropriate action." | tee -a "$LOG_FILE" |
| 45 | echo "===============================================================================" |
Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 46 | |
| 47 | EXIT_VALUE=1 |
| 48 | } |
| 49 | |
Jayanth Dodderi Chidanand | df2faca | 2021-09-08 18:17:22 +0100 | [diff] [blame] | 50 | # Detecting source files not analysed by tf-coverity-job in the latest patch. |
Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 51 | echo "# Check to detect whether newly added files are analysed by Coverity in the patch" |
| 52 | TEST_CASE="Newly added files detection check for Coverity Scan analysis on patch(es)" |
| 53 | # Extracting newly added source files added between commits. |
Jayanth Dodderi Chidanand | df2faca | 2021-09-08 18:17:22 +0100 | [diff] [blame] | 54 | git diff origin/integration...HEAD --name-only --diff-filter=A "*.c" &> "$TFA_PATCH_NEWFILES_LIST" |
Jayanth Dodderi Chidanand | 5132cb1 | 2021-08-09 17:54:47 +0100 | [diff] [blame] | 55 | if [ -s "$TFA_PATCH_NEWFILES_LIST" ] |
| 56 | then |
| 57 | file_updation_report |
| 58 | fi |
| 59 | |
| 60 | echo >> "$LOG_TEST_FILENAME" |
| 61 | echo "****** $TEST_CASE ******" >> "$LOG_TEST_FILENAME" |
| 62 | echo >> "$LOG_TEST_FILENAME" |
| 63 | |
| 64 | if [[ "$EXIT_VALUE" == 0 ]]; then |
| 65 | echo "Result : SUCCESS" >> "$LOG_TEST_FILENAME" |
| 66 | else |
| 67 | echo "Result : FAILURE" >> "$LOG_TEST_FILENAME" |
| 68 | fi |
| 69 | |
| 70 | # Printing the script output to show the warnings. |
| 71 | echo >> "$LOG_TEST_FILENAME" |
| 72 | cat "$LOG_FILE" >> "$LOG_TEST_FILENAME" |
| 73 | echo >> "$LOG_TEST_FILENAME" |
| 74 | |
| 75 | #Deleting temporary files |
| 76 | rm -f "$LOG_FILE" |
| 77 | rm -f "$TFA_PATCH_NEWFILES_LIST" |
| 78 | |
| 79 | exit "$EXIT_VALUE" |