From ba0f31b2a5c8bd35f99b1ba2a74c81a2c2ded200 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Thu, 7 Aug 2014 17:01:18 +0200 Subject: Regression test portability: stat Linux uses stat -c, stat --printf= or stat --printf NetBSD uses stat -f with different format strings. This change set changes all stat usage to stat -c and introduce a shell stat() fonction to perform the format string translation. BUG: 764655 Change-Id: I024fca7c1b736b053f5888cbf21da0a72489ef63 Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/8424 Tested-by: Gluster Build System Reviewed-by: Harshavardhana Tested-by: Harshavardhana --- tests/include.rc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests/include.rc') diff --git a/tests/include.rc b/tests/include.rc index 72c0058820..78488b3797 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -247,6 +247,54 @@ which killall > /dev/null || { } } +stat -c %s /dev/null > /dev/null 2>&1 || { + stat() { + local format="" + local f="" + + if [ "x$1" = "x-c" ] ; then + argc=3 + format=$2 + f=$3 + else + argc=1 + f=$1 + fi + + if [ $# -ne $argc ] ; then + echo 'Usage: stat [-c format] file' + exit 2; + fi + + if [ "x${format}" = "x" ] ; then + `which stat` $f + else + echo ${format} | sed " + s/%u/`$( which stat ) -f %u $f`/g; + s/%g/`$( which stat ) -f %g $f`/g; + s/%a/`$( which stat ) -f %p $f |sed 's/^..//; s/^0//'`/g; + s/%A/`ls -l $f|awk '{print $1}'`/g; + s/%s/`$( which stat ) -f %z $f`/g; + s/%h/`$( which stat ) -f %l $f`/g; + s/%F/`$( which stat ) -f %HT $f | sed ' + s/Directory/directory/; + s/Fifo file/fifo/; + s/Symbolic Link/symbolic link/; + s/Regular File/regular file/; + s/Block Device/block special file/; + s/Character Device/character special file/; + ' | sed \"$( + test -s $f && echo 's/regular file/regular empty file/g' + )\"`/g; + s|%n|`$( which stat ) -f %N $f`|g; + s/%Y/`$( which stat ) -f %m $f`/g; + s/%b/`$( which stat ) -f %b $f`/g; + s/%B/512/g; + " + fi + } +} + function cleanup() { killall -15 glusterfs glusterfsd glusterd 2>/dev/null || true; -- cgit