diff options
| author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-08-29 15:23:21 +0200 | 
|---|---|---|
| committer | Harshavardhana <harsha@harshavardhana.net> | 2014-10-01 08:51:25 -0700 | 
| commit | f54dd171bca5086f11733a1c4fe578e838b2e6fd (patch) | |
| tree | ca8f706fd99e40bab821c5f60b9a1bff7412d2ad | |
| parent | 192d5e6654cf4b3ebcfd6b36c0693955d0c41868 (diff) | |
Regression test portability: stat
Improve BSD compatibility for stat. The new version attemps to spawn
less stat subprocesses.
Also add translation for %X %Y and %Z
BUG: 1129939
Change-Id: I2b2134f9e8336a952aee6c7679ba0491abd5a35c
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8565
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
| -rw-r--r-- | tests/include.rc | 42 | 
1 files changed, 25 insertions, 17 deletions
diff --git a/tests/include.rc b/tests/include.rc index bcaafb90f66..82527856902 100644 --- a/tests/include.rc +++ b/tests/include.rc @@ -323,28 +323,36 @@ stat -c %s /dev/null > /dev/null 2>&1 || {      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 ' +       cmd="" +       case $format in  +       *%u*) cmd="${cmd} s/%u/`$( which stat ) -f %u $f`/g;" ;&  +       *%g*) cmd="${cmd} s/%g/`$( which stat ) -f %g $f`/g;" ;& +       *%a*) cmd="${cmd} s/%a/`$( which stat ) -f %p $f | +                  sed 's/^..//; s/^0//'`/g;" ;& +       *%A*) cmd="${cmd} s/%A/`ls -ld $f|awk '{print $1}'`/g;" ;& +       *%s*) cmd="${cmd} s/%s/`$( which stat ) -f %z $f`/g;" ;& +       *%h*) cmd="${cmd} s/%h/`$( which stat ) -f %l $f`/g;" ;& +       *%F*) cmd="${cmd} s/%F/`$( which stat ) -f %HT $f | sed '            s/Directory/directory/; -          s/Fifo file/fifo/; +          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; -      " +         ' | sed \"$( +           test -s $f || echo 's/regular file/regular empty file/g' +          )\"`/g;" ;& +       *%n*) cmd="${cmd} s|%n|`$( which stat ) -f %N $f`|g;" ;& +       *%Y*) cmd="${cmd} s/%Y/`$( which stat ) -f %m $f`/g;" ;& +       *%X*) cmd="${cmd} s/%X/`$( which stat ) -f %a $f`/g;" ;& +       *%Z*) cmd="${cmd} s/%Z/`$( which stat ) -f %c $f`/g;" ;& +       *%b*) cmd="${cmd} s/%b/`$( which stat ) -f %b $f`/g;" ;& +       *%B*) cmd="${cmd} s/%B/512/g;" ;& +       *%t*) cmd="${cmd} s/%t/`$( which stat ) -f %XHr $f`/g;" ;& +       *%T*) cmd="${cmd} s/%T/`$( which stat ) -f %XLr $f`/g;" ;& +       esac + +       `which stat` -f "`echo $format|sed \"$cmd\"`" $f      fi    }  }  | 
