[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