Re: [PATCH] Attempt to auto-detect stat(1) being used if not given proper invocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Jan 03, 2018 at 10:34:44AM -0600, kevans@xxxxxxxxxxx wrote:
> 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@xxxxxxxxxxx>
> ---
> 
> I should also note here that I've not tested this on Linux, given that I don't
> really have any Linux boxes, but I don't see any reason why it
> wouldn't work.

Works for me, applied.

> 
>  tests/run_tests.sh | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> 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

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux