diff options
author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-08-07 17:01:18 +0200 |
---|---|---|
committer | Harshavardhana <harsha@harshavardhana.net> | 2014-08-18 01:09:39 -0700 |
commit | ba0f31b2a5c8bd35f99b1ba2a74c81a2c2ded200 (patch) | |
tree | 572eb19fb9cba596469fc529556c4708d1e0788c /tests/include.rc | |
parent | c80b5b915a6bf2c6506d789f8ab6f0dcbf3dc617 (diff) |
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 <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8424
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Diffstat (limited to 'tests/include.rc')
-rw-r--r-- | tests/include.rc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/include.rc b/tests/include.rc index 72c00588200..78488b37975 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; |