check_abi.sh (5395B)
1 #! /bin/bash 2 3 set_env() 4 { 5 OUTPUTDIR=$(pwd)$(echo "/output") 6 DATE=$(date "+TB [%Y-%m-%d %H:%M:%S]") 7 8 if [ ! -d "${OUTPUTDIR}" ]; then 9 echo "Creating output dir" 10 mkdir "${OUTPUTDIR}" 11 fi 12 13 cp -a ${VCS_PATH}/nss ${VCS_PATH}/nspr . 14 pushd nspr 15 if [[ -f ../nss/nspr.patch && "$ALLOW_NSPR_PATCH" == "1" ]]; then 16 cat ../nss/nspr.patch | patch -p1 17 fi 18 popd 19 20 cd nss 21 ./build.sh -v -c --python=python3 22 cd .. 23 } 24 25 check_abi() 26 { 27 set_env 28 if [[ "$1" != --nobuild ]]; then # Start nobuild block 29 30 echo "######## NSS ABI CHECK ########" 31 echo "######## creating temporary HG clones ########" 32 33 rm -rf baseline 34 mkdir baseline 35 BASE_NSS=`cat nss/automation/abi-check/previous-nss-release` #Reads the version number of the last release from the respective file 36 if ! hg clone -u "${BASE_NSS}" "${VCS_PATH}/nss" baseline/nss; then 37 echo "invalid tag in automation/abi-check/previous-nss-release" 38 return 1 39 fi 40 41 BASE_NSPR=NSPR_$(head -1 baseline/nss/automation/release/nspr-version.txt | cut -d . -f 1-2 | tr . _)_BRANCH 42 if ! hg clone -u "${BASE_NSPR}" "${VCS_PATH}/nspr" baseline/nspr; then 43 rm -rf baseline/nspr 44 hg clone -u "default" "${VCS_PATH}/nspr" baseline/nspr 45 echo "Nonexisting tag ${BASE_NSPR} derived from ${BASE_NSS} automation/release/nspr-version.txt" 46 echo "Using default branch instead." 47 fi 48 49 echo "######## building baseline NSPR/NSS ########" 50 echo "${PWD}/baseline/nss/build.sh" 51 cd baseline/nss 52 ./build.sh -v -c --python=python3 53 cd - 54 else # Else nobuild block 55 echo "######## using existing baseline NSPR/NSS build ########" 56 fi # End nobuild block 57 58 echo "######## Starting abidiff procedure ########" 59 abi_diff 60 } 61 62 #Slightly modified from build.sh in this directory 63 abi_diff() 64 { 65 ABI_PROBLEM_FOUND=0 66 ABI_REPORT=${OUTPUTDIR}/abi-diff.txt 67 rm -f ${ABI_REPORT} 68 PREVDIST=baseline/dist 69 NEWDIST=dist 70 # libnssdbm3.so isn't built by default anymore, skip it. 71 ALL_SOs="libfreebl3.so libfreeblpriv3.so libnspr4.so libnss3.so libnssckbi.so libnsssysinit.so libnssutil3.so libplc4.so libplds4.so libsmime3.so libsoftokn3.so libssl3.so" 72 for SO in ${ALL_SOs}; do 73 if [ ! -f nss/automation/abi-check/expected-report-$SO.txt ]; then 74 touch nss/automation/abi-check/expected-report-$SO.txt 75 fi 76 abidiff --hd1 $PREVDIST/public/ --hd2 $NEWDIST/public \ 77 $PREVDIST/*/lib/$SO $NEWDIST/*/lib/$SO \ 78 > nss/automation/abi-check/new-report-temp$SO.txt 79 RET=$? 80 cat nss/automation/abi-check/new-report-temp$SO.txt \ 81 | grep -v "^Functions changes summary:" \ 82 | grep -v "^Variables changes summary:" \ 83 | sed -e 's/__anonymous_enum__[0-9]*/__anonymous_enum__/g' \ 84 > nss/automation/abi-check/new-report-$SO.txt 85 rm -f nss/automation/abi-check/new-report-temp$SO.txt 86 87 ABIDIFF_ERROR=$((($RET & 0x01) != 0)) 88 ABIDIFF_USAGE_ERROR=$((($RET & 0x02) != 0)) 89 ABIDIFF_ABI_CHANGE=$((($RET & 0x04) != 0)) 90 ABIDIFF_ABI_INCOMPATIBLE_CHANGE=$((($RET & 0x08) != 0)) 91 ABIDIFF_UNKNOWN_BIT_SET=$((($RET & 0xf0) != 0)) 92 93 # If abidiff reports an error, or a usage error, or if it sets a result 94 # bit value this script doesn't know yet about, we'll report failure. 95 # For ABI changes, we don't yet report an error. We'll compare the 96 # result report with our allowlist. This allows us to silence changes 97 # that we're already aware of and have been declared acceptable. 98 99 REPORT_RET_AS_FAILURE=0 100 if [ $ABIDIFF_ERROR -ne 0 ]; then 101 echo "abidiff reported ABIDIFF_ERROR." 102 REPORT_RET_AS_FAILURE=1 103 fi 104 if [ $ABIDIFF_USAGE_ERROR -ne 0 ]; then 105 echo "abidiff reported ABIDIFF_USAGE_ERROR." 106 REPORT_RET_AS_FAILURE=1 107 fi 108 if [ $ABIDIFF_UNKNOWN_BIT_SET -ne 0 ]; then 109 echo "abidiff reported ABIDIFF_UNKNOWN_BIT_SET." 110 REPORT_RET_AS_FAILURE=1 111 fi 112 113 if [ $ABIDIFF_ABI_CHANGE -ne 0 ]; then 114 echo "Ignoring abidiff result ABI_CHANGE, instead we'll check for non-allowlisted differences." 115 fi 116 if [ $ABIDIFF_ABI_INCOMPATIBLE_CHANGE -ne 0 ]; then 117 echo "Ignoring abidiff result ABIDIFF_ABI_INCOMPATIBLE_CHANGE, instead we'll check for non-allowlisted differences." 118 fi 119 120 if [ $REPORT_RET_AS_FAILURE -ne 0 ]; then 121 ABI_PROBLEM_FOUND=1 122 echo "abidiff {$PREVDIST , $NEWDIST} for $SO FAILED with result $RET, or failed writing to nss/automation/abi-check/new-report-$SO.txt" 123 fi 124 if [ ! -f nss/automation/abi-check/expected-report-$SO.txt ]; then 125 ABI_PROBLEM_FOUND=1 126 echo "FAILED to access report file: nss/automation/abi-check/expected-report-$SO.txt" 127 fi 128 129 diff -wB -u nss/automation/abi-check/expected-report-$SO.txt \ 130 nss/automation/abi-check/new-report-$SO.txt >> ${ABI_REPORT} 131 if [ ! -f ${ABI_REPORT} ]; then 132 ABI_PROBLEM_FOUND=1 133 echo "FAILED to compare exepcted and new report: nss/automation/abi-check/new-report-$SO.txt" 134 fi 135 done 136 137 if [ -s ${ABI_REPORT} ]; then 138 echo "FAILED: there are new unexpected ABI changes" 139 cat ${ABI_REPORT} 140 return 1 141 elif [ $ABI_PROBLEM_FOUND -ne 0 ]; then 142 echo "FAILED: failure executing the ABI checks" 143 cat ${ABI_REPORT} 144 return 1 145 fi 146 147 return 0 148 } 149 150 check_abi $1