Browse Source

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>
main
kevans@FreeBSD.org 7 years ago committed by David Gibson
parent
commit
333d533a8f
  1. 9
      tests/run_tests.sh

9
tests/run_tests.sh

@ -8,7 +8,14 @@ fi @@ -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

Loading…
Cancel
Save