diff options
author | kevans@FreeBSD.org <kevans@FreeBSD.org> | 2018-01-03 10:34:44 -0600 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2018-01-04 14:21:10 +1100 |
commit | 333d533a8f4dd38f5d8ae6489f675cc02dd6ee5e (patch) | |
tree | 67520328a14d56ec6bf101d37d3383fb4043d609 | |
parent | e54388015af1fb4bf04d0bca99caba1074d9cc42 (diff) | |
download | device-tree-compiler-333d533a8f4dd38f5d8ae6489f675cc02dd6ee5e.tar.gz |
Attempt to auto-detect stat(1) being used if not given proper invocation
GNU stat(1) uses '-c "%s"' as the proper invocation to print filesize of the
file in question, while BSD stat(1) uses '-f "%Uz"'. Do some trivial
autodetection to check if we're using GNU stat(1) and assume we're using BSD
stat(1) if we don't detect otherwise.
This should allow the test suite to run properly out-of-the-box on *BSDs and
MacOS in addition to the current Linux support.
Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rwxr-xr-x | tests/run_tests.sh | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 3fa7c0a..0d30edf 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -8,7 +8,14 @@ fi # stat differs between platforms if [ -z "$STATSZ" ]; then - STATSZ="stat -c %s" + stat --version 2>/dev/null | grep -q 'GNU' + GNUSTAT=$? + if [ "$GNUSTAT" -ne 0 ]; then + # Assume BSD stat if we can't detect as GNU stat + STATSZ="stat -f %Uz" + else + STATSZ="stat -c %s" + fi fi export QUIET_TEST=1 |