diff options
author | Jeffrey Walton <noloader@gmail.com> | 2020-12-21 11:47:46 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2020-12-21 11:47:46 -0500 |
commit | 6ef924b78b8730077fdb25ab84ab0190bd20f9cb (patch) | |
tree | 17e3757e4a6d1555c1a9fef5784527817cbd2f00 /TestScripts | |
parent | c10251bde047f2de4dd0f20e33182869b3c22f2b (diff) | |
download | cryptopp-git-6ef924b78b8730077fdb25ab84ab0190bd20f9cb.tar.gz |
Update cryptest-symbols.sh script
Diffstat (limited to 'TestScripts')
-rwxr-xr-x | TestScripts/cryptest-symbols.sh | 237 |
1 files changed, 68 insertions, 169 deletions
diff --git a/TestScripts/cryptest-symbols.sh b/TestScripts/cryptest-symbols.sh index 5482d16d..1aa3b6b3 100755 --- a/TestScripts/cryptest-symbols.sh +++ b/TestScripts/cryptest-symbols.sh @@ -7,18 +7,12 @@ # automate testing of the shared object to ensure linking and symbols don't go # missing from release to release. -# Fixup ancient Bash -# https://unix.stackexchange.com/q/468579/56041 -if [[ -z "$BASH_SOURCE" ]]; then - BASH_SOURCE="$0" -fi - ############################################ # Cleanup PWD_DIR=$(pwd) function cleanup { - rm -f adhoc.cpp *.a *.o *.so *.dylib + rm -f adhoc.cpp *\.a *\.o *\.so* *\.dylib* cd "$PWD_DIR" } trap cleanup EXIT @@ -27,13 +21,13 @@ trap cleanup EXIT # Tags to test OLD_VERSION_TAG=CRYPTOPP_8_2_0 -NEW_VERSION_TAG=master +NEW_VERSION_TAG=CRYPTOPP_8_3_0 ############################################ # If local repo is dirty, then promt first DIRTY=$(git diff --shortstat 2> /dev/null | tail -1) -if [[ ! (-z "$DIRTY") ]]; then +if [[ ! -z "$DIRTY" ]]; then echo echo "The local repo is dirty. Continuing will reset the repo and lose changes." @@ -64,116 +58,53 @@ AWK=awk CXXFILT=c++filt THIS_SYSTEM=$(uname -s 2>&1) -IS_DARWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c darwin) -IS_LINUX=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c linux) -IS_CYGWIN=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c cygwin) -IS_MINGW=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c mingw) -IS_OPENBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c openbsd) -IS_FREEBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c freebsd) -IS_NETBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c netbsd) -IS_SOLARIS=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c sunos) +IS_DARWIN=$("${GREP}" -i -c darwin <<< "${THIS_SYSTEM}") +IS_LINUX=$("${GREP}" -i -c linux <<< "${THIS_SYSTEM}") +IS_CYGWIN=$("${GREP}" -i -c cygwin <<< "${THIS_SYSTEM}") +IS_MINGW=$("${GREP}" -i -c mingw <<< "${THIS_SYSTEM}") +IS_OPENBSD=$("${GREP}" -i -c openbsd <<< "${THIS_SYSTEM}") +IS_FREEBSD=$("${GREP}" -i -c freebsd <<< "${THIS_SYSTEM}") +IS_NETBSD=$("${GREP}" -i -c netbsd <<< "${THIS_SYSTEM}") +IS_SOLARIS=$("${GREP}" -i -c sunos <<< "${THIS_SYSTEM}") THIS_MACHINE=$(uname -m 2>&1) -IS_X86=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(i386|i486|i586|i686)") -IS_X64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(amd64|x86_64)") -IS_PPC=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(Power|PPC)") -IS_ARM32=$(echo -n "$THIS_MACHINE" | "$GREP" -v "64" | "$EGREP" -i -c "(arm|aarch32)") -IS_ARM64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(arm64|aarch64)") -IS_S390=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "s390") -IS_X32=0 - -# Fixup -if [[ "$IS_SOLARIS" -ne "0" ]]; then - IS_X64=$(isainfo 2>/dev/null | "$GREP" -i -c "amd64") - if [[ "$IS_X64" -ne "0" ]]; then - IS_X86=0 - fi - - # Need something more powerful than the Posix versions - if [[ (-e "/usr/gnu/bin/grep") ]]; then - GREP=/usr/gnu/bin/grep - fi - if [[ (-e "/usr/gnu/bin/egrep") ]]; then - EGREP=/usr/gnu/bin/egrep - fi - if [[ (-e "/usr/gnu/bin/sed") ]]; then - SED=/usr/gnu/bin/sed - fi - if [[ (-e "/usr/gnu/bin/c++filt") ]]; then - CXXFILT=/usr/gnu/bin/c++filt - fi - if [[ (-e "/usr/gnu/bin/awk") ]]; then - AWK=/usr/gnu/bin/awk - else - AWK=nawk; - fi -fi - -if [[ "$IS_DARWIN" -ne "0" ]]; then - SED_OPTS=(-i '') -else - SED_OPTS=(-i) -fi +IS_X86=$("${EGREP}" -i -c 'i386|i486|i586|i686' <<< "${THIS_MACHINE}") +IS_X64=$("${EGREP}" -i -c "amd64|x86_64" <<< "${THIS_MACHINE}") +IS_PPC32=$("${EGREP}" -i -c "PowerPC|PPC" <<< "${THIS_MACHINE}") +IS_PPC64=$("${EGREP}" -i -c "PowerPC64|PPC64" <<< "${THIS_MACHINE}") +IS_ARM32=$("${EGREP}" -i -c "arm|aarch32" <<< "${THIS_MACHINE}") +IS_ARMV8=$("${EGREP}" -i -c "arm64|aarch64" <<< "${THIS_MACHINE}") +IS_S390=$("${EGREP}" -i -c "s390" <<< "${THIS_MACHINE}") + +if [[ "${IS_X64}" -eq 1 ]]; then IS_X86=0; fi +if [[ "${IS_ARMV8}" -eq 1 ]]; then IS_ARM32=0; fi +if [[ "${IS_PPC64}" -eq 1 ]]; then IS_PPC32=0; fi # Fixup -if [[ ("$IS_FREEBSD" -ne "0" || "$IS_OPENBSD" -ne "0" || "$IS_NETBSD" -ne "0") ]]; then +if [[ "$IS_FREEBSD" -ne "0" || "$IS_OPENBSD" -ne "0" || "$IS_NETBSD" -ne "0" ]]; then MAKE=gmake -elif [[ ("$IS_SOLARIS" -ne "0") ]]; then - MAKE=$(which gmake 2>/dev/null | "$GREP" -v "no gmake" | head -1) - if [[ (-z "$MAKE") && (-e "/usr/sfw/bin/gmake") ]]; then +elif [[ "$IS_SOLARIS" -ne "0" ]]; then + MAKE=$(command -v gmake 2>/dev/null | "${GREP}" -v "no gmake" | head -1) + if [[ -z "$MAKE" && -e "/usr/sfw/bin/gmake" ]]; then MAKE=/usr/sfw/bin/gmake fi else MAKE=make fi -# We need to use the C++ compiler to determine feature availablility. Otherwise -# mis-detections occur on a number of platforms. -if [[ ((-z "$CXX") || ("$CXX" == "gcc")) ]]; then - if [[ ("$CXX" == "gcc") ]]; then - CXX=g++ - elif [[ "$IS_DARWIN" -ne "0" ]]; then - CXX=c++ - elif [[ "$IS_SOLARIS" -ne "0" ]]; then - if [[ (-e "/opt/developerstudio12.5/bin/CC") ]]; then - CXX=/opt/developerstudio12.5/bin/CC - elif [[ (-e "/opt/solarisstudio12.4/bin/CC") ]]; then - CXX=/opt/solarisstudio12.4/bin/CC - elif [[ (-e "/opt/solarisstudio12.3/bin/CC") ]]; then - CXX=/opt/solarisstudio12.3/bin/CC - elif [[ (-e "/opt/solstudio12.2/bin/CC") ]]; then - CXX=/opt/solstudio12.2/bin/CC - elif [[ (-e "/opt/solstudio12.1/bin/CC") ]]; then - CXX=/opt/solstudio12.1/bin/CC - elif [[ (-e "/opt/solstudio12.0/bin/CC") ]]; then - CXX=/opt/solstudio12.0/bin/CC - elif [[ (! -z $(which CC 2>/dev/null | "$GREP" -v "no CC" | head -1)) ]]; then - CXX=$(which CC | head -1) - elif [[ (! -z $(which g++ 2>/dev/null | "$GREP" -v "no g++" | head -1)) ]]; then - CXX=$(which g++ | head -1) - else - CXX=CC - fi - elif [[ ($(which g++ 2>&1 | "$GREP" -v "no g++" | "$GREP" -i -c g++) -ne "0") ]]; then - CXX=g++ - else - CXX=c++ - fi +if [[ "$IS_DARWIN" -ne "0" ]]; then + LINK_LIBRARY=libcryptopp.dylib +else + LINK_LIBRARY=libcryptopp.so fi -SUN_COMPILER=$("$CXX" -V 2>&1 | "$EGREP" -i -c "CC: (Sun|Studio)") -GCC_COMPILER=$("$CXX" --version 2>&1 | "$GREP" -i -v "clang" | "$EGREP" -i -c "(gcc|g\+\+)") -INTEL_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "\(icc\)") -MACPORTS_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "MacPorts") -CLANG_COMPILER=$("$CXX" --version 2>&1 | "$EGREP" -i -c "clang") - -if [[ ("$SUN_COMPILER" -eq "0") ]]; then - AMD64=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$EGREP" -c "(__x64_64__|__amd64__)") - ILP32=$("$CXX" -dM -E - </dev/null 2>/dev/null | "$EGREP" -c "(__ILP32__|__ILP32)") - if [[ ("$AMD64" -ne "0") && ("$ILP32" -ne "0") ]]; then - IS_X32=1 - fi -fi +if [[ -z "${CXX}" ]]; then CXX=c++; fi + +SUN_COMPILER=$("${CXX}" -V 2>&1 | "${EGREP}" -i -c "CC: (Sun|Studio)") +GCC_COMPILER=$("${CXX}" --version 2>&1 | "${EGREP}" -i -c "^(gcc|g\+\+)") +INTEL_COMPILER=$("${CXX}" --version 2>&1 | "${GREP}" -i -c "icc") +MACPORTS_COMPILER=$("${CXX}" --version 2>&1 | "${GREP}" -i -c "MacPorts") +CLANG_COMPILER=$("${CXX}" --version 2>&1 | "${GREP}" -i -c "clang") ############################################ @@ -183,25 +114,25 @@ fi CPU_COUNT=1 MEM_SIZE=512 -if [[ (-e "/proc/cpuinfo") && (-e "/proc/meminfo") ]]; then - CPU_COUNT=$(cat /proc/cpuinfo | "$GREP" -c '^processor') - MEM_SIZE=$(cat /proc/meminfo | "$GREP" "MemTotal" | "$AWK" '{print $2}') +if [[ -e "/proc/cpuinfo" && -e "/proc/meminfo" ]]; then + CPU_COUNT=$(cat /proc/cpuinfo | "${GREP}" -c '^processor') + MEM_SIZE=$(cat /proc/meminfo | "${GREP}" "MemTotal" | "${AWK}" '{print $2}') MEM_SIZE=$(($MEM_SIZE/1024)) elif [[ "$IS_DARWIN" -ne "0" ]]; then - CPU_COUNT=$(sysctl -a 2>&1 | "$GREP" 'hw.availcpu' | "$AWK" '{print $3; exit}') - MEM_SIZE=$(sysctl -a 2>&1 | "$GREP" 'hw.memsize' | "$AWK" '{print $3; exit;}') + CPU_COUNT=$(sysctl -a 2>&1 | "${GREP}" 'hw.availcpu' | "${AWK}" '{print $3; exit}') + MEM_SIZE=$(sysctl -a 2>&1 | "${GREP}" 'hw.memsize' | "${AWK}" '{print $3; exit;}') MEM_SIZE=$(($MEM_SIZE/1024/1024)) elif [[ "$IS_SOLARIS" -ne "0" ]]; then - CPU_COUNT=$(psrinfo 2>/dev/null | wc -l | "$AWK" '{print $1}') - MEM_SIZE=$(prtconf 2>/dev/null | "$GREP" Memory | "$AWK" '{print $3}') + CPU_COUNT=$(psrinfo 2>/dev/null | wc -l | "${AWK}" '{print $1}') + MEM_SIZE=$(prtconf 2>/dev/null | "${GREP}" Memory | "${AWK}" '{print $3}') fi # Some ARM devboards cannot use 'make -j N', even with multiple cores and RAM # An 8-core Cubietruck Plus with 2GB RAM experiences OOM kills with '-j 2'. HAVE_SWAP=1 if [[ "$IS_LINUX" -ne "0" ]]; then - if [[ (-e "/proc/meminfo") ]]; then - SWAP_SIZE=$(cat /proc/meminfo | "$GREP" "SwapTotal" | "$AWK" '{print $2}') + if [[ -e "/proc/meminfo" ]]; then + SWAP_SIZE=$(cat /proc/meminfo | "${GREP}" "SwapTotal" | "${AWK}" '{print $2}') if [[ "$SWAP_SIZE" -eq "0" ]]; then HAVE_SWAP=0 fi @@ -210,20 +141,15 @@ if [[ "$IS_LINUX" -ne "0" ]]; then fi fi -if [[ ("$CPU_COUNT" -ge "2" && "$MEM_SIZE" -ge "1280" && "$HAVE_SWAP" -ne "0") ]]; then - if [[ ("$WANT_NICE" -eq "1") ]]; then - CPU_COUNT=$(echo -n "$CPU_COUNT 2" | "$AWK" '{print int($1/$2)}') - fi +if [[ "$CPU_COUNT" -ge "2" && "$MEM_SIZE" -ge "1280" && "$HAVE_SWAP" -ne "0" ]]; then MAKEARGS=(-j "$CPU_COUNT") fi ############################################################################### ############################################################################### -"$MAKE" distclean &>/dev/null - +"${MAKE}" distclean &>/dev/null && cleanup &>/dev/null git checkout master -f &>/dev/null - git checkout "$OLD_VERSION_TAG" -f &>/dev/null if [[ "$?" -ne "0" ]]; then @@ -237,13 +163,7 @@ echo "Building dynamic library for $OLD_VERSION_TAG" echo "****************************************************************" echo -if [[ "$IS_DARWIN" -ne "0" ]]; then - LINK_LIBRARY=libcryptopp.dylib -else - LINK_LIBRARY=libcryptopp.so -fi - -LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile dynamic +LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile cryptest.exe dynamic if [[ ! -f "$LINK_LIBRARY" ]]; then echo "Failed to make $OLD_VERSION_TAG library" @@ -252,44 +172,20 @@ fi echo echo "****************************************************************" -echo "Building cryptest.exe for $OLD_VERSION_TAG" -echo "****************************************************************" -echo - -"$MAKE" "${MAKEARGS[@]}" -f GNUmakefile cryptest.exe - -if [[ ! -f "cryptest.exe" ]]; then - echo "Failed to make cryptest.exe" - exit 1 -fi - -echo -echo "****************************************************************" echo "Running $OLD_VERSION_TAG cryptest.exe using $OLD_VERSION_TAG library" echo "****************************************************************" echo if [[ "$IS_DARWIN" -ne "0" ]]; then - DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT" - DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT" + DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT" + DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT" else - LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT" - LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT" + LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT" + LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT" fi -echo -echo "****************************************************************" -echo "Removing dynamic library and artifacts for $OLD_VERSION_TAG" -echo "****************************************************************" - -rm -f adhoc.cpp *.a *.o *.so *.dylib - -git checkout "$NEW_VERSION_TAG" -f &>/dev/null - -if [[ "$?" -ne "0" ]]; then - echo "Failed to checkout $OLD_VERSION_TAG" - exit 1 -fi +# Stash away old cryptest.exe +cp cryptest.exe cryptest.exe.saved echo echo "****************************************************************" @@ -297,13 +193,20 @@ echo "Building dynamic library for $NEW_VERSION_TAG" echo "****************************************************************" echo -LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile dynamic +"${MAKE}" distclean &>/dev/null && cleanup &>/dev/null +git checkout master -f &>/dev/null +git checkout "$NEW_VERSION_TAG" -f &>/dev/null + +LINK_LIBRARY="$LINK_LIBRARY" "$MAKE" "${MAKEARGS[@]}" -f GNUmakefile cryptest.exe dynamic if [[ ! -f "$LINK_LIBRARY" ]]; then echo "Failed to make $NEW_VERSION_TAG library" exit 1 fi +# Fetch old cryptest.exe +cp cryptest.exe.saved cryptest.exe + echo echo "****************************************************************" echo "Running $OLD_VERSION_TAG cryptest.exe using $NEW_VERSION_TAG library" @@ -311,18 +214,14 @@ echo "****************************************************************" echo if [[ "$IS_DARWIN" -ne "0" ]]; then - DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT" - DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT" + DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT" + DYLD_LIBRARY_PATH="$PWD:$DYLD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT" else - LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" v 2>&1 | "$CXXFILT" - LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" "$PWD/cryptest.exe" tv all 2>&1 | "$CXXFILT" + LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe v 2>&1 | "$CXXFILT" + LD_LIBRARY_PATH="$PWD:$LD_LIBRARY_PATH" ./cryptest.exe tv all 2>&1 | "$CXXFILT" fi +"${MAKE}" distclean &>/dev/null && cleanup &>/dev/null git checkout master -f &>/dev/null -if [[ "$?" -ne "0" ]]; then - echo "Failed to checkout Master" - exit 1 -fi - exit 0 |