devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Attempt to auto-detect stat(1) being used if not given proper invocation
@ 2018-01-03 16:34 kevans-HZy0K5TPuP5AfugRpC6u6w
       [not found] ` <20180103163444.68928-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: kevans-HZy0K5TPuP5AfugRpC6u6w @ 2018-01-03 16:34 UTC (permalink / raw)
  To: David Gibson, Jon Loeliger
  Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA, Kyle Evans

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-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
---

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.

 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
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Attempt to auto-detect stat(1) being used if not given proper invocation
       [not found] ` <20180103163444.68928-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
@ 2018-01-04  3:21   ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2018-01-04  3:21 UTC (permalink / raw)
  To: kevans-HZy0K5TPuP5AfugRpC6u6w
  Cc: Jon Loeliger, devicetree-compiler-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 1610 bytes --]

On Wed, Jan 03, 2018 at 10:34:44AM -0600, kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org 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-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
> ---
> 
> 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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-01-04  3:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-03 16:34 [PATCH] Attempt to auto-detect stat(1) being used if not given proper invocation kevans-HZy0K5TPuP5AfugRpC6u6w
     [not found] ` <20180103163444.68928-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
2018-01-04  3:21   ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).