From: Tim Keith Date: Mon, 3 Jun 2019 20:21:35 +0000 (-0700) Subject: [flang] Fix test_folding.sh to work on MacOS X-Git-Tag: llvmorg-12-init~9537^2~1183 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=473658dd866c1af4e9cc3c6475bc88412d98c884;p=platform%2Fupstream%2Fllvm.git [flang] Fix test_folding.sh to work on MacOS There were a couple of small incompatibilities: - There is no `ldd` on MacOS; instead use `otools -L`. This has not been tested when libpgmath is linked in to f18. - `wc` outputs spaces where on Linux it outputs tabs; change how the number of lines is extracted to work on both. Also, fix a bug: change `passed_warnings` to `$passed_warnings`. Original-commit: flang-compiler/f18@5bede9e188e0f5e6b8ac922725d9d19a6aae96e6 Reviewed-on: https://github.com/flang-compiler/f18/pull/475 --- diff --git a/flang/test/evaluate/test_folding.sh b/flang/test/evaluate/test_folding.sh index 33dbcb7..8a27851 100755 --- a/flang/test/evaluate/test_folding.sh +++ b/flang/test/evaluate/test_folding.sh @@ -33,7 +33,16 @@ # - test_x is not folded (it is neither .true. nor .false.). This means the # compiler could not fold the expression. - +# Return ldd or similar tool to use to check for libpgmath +function get_ldd() { + case $(uname -s) in + Linux) echo 'ldd' ;; + Darwin) echo 'otool -L' ;; + *) + >&2 echo "Warning: cannot detect libpgmath on $(uname -s)" + echo 'true' ;; + esac +} PATH=/usr/bin:/bin srcdir=$(dirname $0) @@ -41,7 +50,7 @@ F18CC=${F18:-../../tools/f18/f18} CMD="$F18CC -fdebug-dump-symbols -fparse-only" # Check if libpgmath has been linked -lpgmath=$(ldd $F18CC | grep "pgmath") +lpgmath=$($(get_ldd) $F18CC | grep "pgmath") if [ -z "$lpgmath" ]; then echo "Assuming no libpgmath support" else @@ -115,9 +124,9 @@ if [ -s $src4 ] || [ -s $warning_diffs ]; then echo FAIL exit 1 else - passed_results="$(wc -l $src3 | sed 's/ .*//')" - passed_warnings="$(wc -l $expected_warnings | sed 's/ .*//')" - passed=$((passed_warnings + $passed_results)) + passed_results=$(wc -l < $src3) + passed_warnings=$(wc -l < $expected_warnings) + passed=$(($passed_warnings + $passed_results)) echo all $passed tests passed echo PASS fi