From: kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org
To: David Gibson
<david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>,
Jon Loeliger <jdl-CYoMK+44s/E@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Kyle Evans <kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
Subject: [PATCH] Attempt to auto-detect stat(1) being used if not given proper invocation
Date: Wed, 3 Jan 2018 10:34:44 -0600 [thread overview]
Message-ID: <20180103163444.68928-1-kevans@FreeBSD.org> (raw)
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
next reply other threads:[~2018-01-03 16:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-03 16:34 kevans-HZy0K5TPuP5AfugRpC6u6w [this message]
[not found] ` <20180103163444.68928-1-kevans-HZy0K5TPuP5AfugRpC6u6w@public.gmane.org>
2018-01-04 3:21 ` [PATCH] Attempt to auto-detect stat(1) being used if not given proper invocation David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180103163444.68928-1-kevans@FreeBSD.org \
--to=kevans-hzy0k5tpup5afugrpc6u6w@public.gmane.org \
--cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
--cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=jdl-CYoMK+44s/E@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).