tests: Add compatibility with uutils

In some places run_tsets.sh needs to get the size of files, which it does
with stat(1).  However the syntax to do this is different between GNU
coreutils stat(1) and BSD's stat(1).  We have some logic that looks for
"GNU" in the version string to figure out the correct version.

This will break upcoming Ubuntu versions which are now using uutils, a Rust
reimplementation of coreutils.  These support the same GNU syntax, but
don't have the "GNU" in the version string.

Update the detection to simply try the GNU version and otherwise assume
BSD.

Link: https://github.com/dgibson/dtc/issues/166

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson 2025-07-24 13:26:31 +10:00
parent a0dd7b6081
commit 33e66ec845

View file

@ -43,13 +43,14 @@ fi
# stat differs between platforms
if [ -z "$STATSZ" ]; then
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
# First attempt GNU style, this is supported by both the
# actual GNU coreutils version, and the Rust re-implementation
# uutils, used in recent Ubuntu versions
if stat -c %s $0; then
STATSZ="stat -c %s"
else
# Otherwise assume BSD style stat
STATSZ="stat -f %Uz"
fi
fi