diff options
-rw-r--r-- | tests/basic/afr/self-heal.t | 8 | ||||
-rwxr-xr-x | tests/basic/rpc-coverage.sh | 2 | ||||
-rw-r--r-- | tests/bugs/bug-1122443.t | 6 | ||||
-rw-r--r-- | tests/bugs/bug-862967.t | 4 | ||||
-rwxr-xr-x | tests/bugs/bug-884597.t | 16 | ||||
-rw-r--r-- | tests/bugs/bug-949242.t | 10 | ||||
-rw-r--r-- | tests/bugs/bug-963678.t | 6 | ||||
-rw-r--r-- | tests/include.rc | 48 | ||||
-rw-r--r-- | tests/volume.rc | 2 |
9 files changed, 75 insertions, 27 deletions
diff --git a/tests/basic/afr/self-heal.t b/tests/basic/afr/self-heal.t index 731bd8fbc20..acdd6b73ca0 100644 --- a/tests/basic/afr/self-heal.t +++ b/tests/basic/afr/self-heal.t @@ -58,7 +58,7 @@ TEST ls $B0/brick0/def/ghi/file1.txt TEST ls $B0/brick0/def/ghi/file2.txt TEST ls $B0/brick0/jkl/mno/file.txt TEST ! ls $B0/brick0/abc/ghi -EXPECT "$NEW_UID$NEW_GID" stat --printf=%u%g $B0/brick0/abc/def/file_abc_def_2.txt +EXPECT "$NEW_UID$NEW_GID" stat -c %u%g $B0/brick0/abc/def/file_abc_def_2.txt TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs) #Cleanup @@ -105,7 +105,7 @@ TEST $CLI volume heal $V0 EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 #check heal has happened in the correct direction -EXPECT "777" stat --printf=%a $B0/brick0/file +EXPECT "777" stat -c %a $B0/brick0/file TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs) #Cleanup @@ -129,7 +129,7 @@ TEST $CLI volume heal $V0 EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 #check heal has happened in the correct direction -EXPECT "$NEW_UID$NEW_GID" stat --printf=%u%g $B0/brick0/file +EXPECT "$NEW_UID$NEW_GID" stat -c %u%g $B0/brick0/file TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs) #Cleanup @@ -160,7 +160,7 @@ TEST $CLI volume heal $V0 EXPECT_WITHIN $HEAL_TIMEOUT "0" afr_get_pending_heal_count $V0 #check heal has happened in the correct direction -EXPECT 0 stat --printf=%s $B0/brick1/file +EXPECT 0 stat -c %s $B0/brick1/file TEST diff <($AREQUAL_PATH/arequal-checksum -p $B0/brick0 -i .glusterfs) <($AREQUAL_PATH/arequal-checksum -p $B0/brick1 -i .glusterfs) #Cleanup diff --git a/tests/basic/rpc-coverage.sh b/tests/basic/rpc-coverage.sh index dc66969d045..1fae111d04b 100755 --- a/tests/basic/rpc-coverage.sh +++ b/tests/basic/rpc-coverage.sh @@ -71,7 +71,7 @@ function test_statfs() { local size; - size=$(stat -f -c '%s' $PFX/dir/file); + size=$(stat -c -c '%s' $PFX/dir/file); test "x$size" != "x0" || fail "statfs" } diff --git a/tests/bugs/bug-1122443.t b/tests/bugs/bug-1122443.t index 711b70cccca..db9d3a060bf 100644 --- a/tests/bugs/bug-1122443.t +++ b/tests/bugs/bug-1122443.t @@ -19,7 +19,7 @@ make_files() { bug_1113050_workaround() { # Test if graph change has settled (bug-1113050?) - test=$(stat --printf "%n:%Y," $1 2>&1) + test=$(stat -c "%n:%Y" $1 2>&1 | tr '\n' ',') if [ $? -eq 0 ] ; then echo RECONNECTED else @@ -41,7 +41,7 @@ TEST glusterfs -s $H0 --volfile-id $V0 $M0 TEST make_files $M0/subdir # Get mtime before migration -BEFORE="$(stat --printf "%n:%Y," $M0/subdir/*)" +BEFORE="$(stat -c %n:%Y $M0/subdir/* | tr '\n' ',')" # Migrate brick TEST $CLI volume add-brick $V0 $H0:$B0/${V0}1 @@ -51,7 +51,7 @@ TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}0 commit # Get mtime after migration EXPECT_WITHIN 5 RECONNECTED bug_1113050_workaround $M0/subdir/* -AFTER="$(stat --printf "%n:%Y," $M0/subdir/*)" +AFTER="$(stat -c %n:%Y $M0/subdir/* | tr '\n' ',')" # Check if mtime is unchanged TEST [ "$AFTER" == "$BEFORE" ] diff --git a/tests/bugs/bug-862967.t b/tests/bugs/bug-862967.t index bd500b1da9d..30d71185405 100644 --- a/tests/bugs/bug-862967.t +++ b/tests/bugs/bug-862967.t @@ -50,8 +50,8 @@ sleep 10; ls -l $M0/dir; # check if uid/gid is healed on backend brick which was taken down -BACKEND_UID=`stat --printf=%u $B0/${V0}1/dir`; -BACKEND_GID=`stat --printf=%g $B0/${V0}1/dir`; +BACKEND_UID=`stat -c %u $B0/${V0}1/dir`; +BACKEND_GID=`stat -c %g $B0/${V0}1/dir`; EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID diff --git a/tests/bugs/bug-884597.t b/tests/bugs/bug-884597.t index a0540b628a0..2d2bb745e52 100755 --- a/tests/bugs/bug-884597.t +++ b/tests/bugs/bug-884597.t @@ -61,8 +61,8 @@ get_hashed_brick $i cached=$? # check if uid/gid on linkfile is created with correct uid/gid -BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/$i`; -BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/$i`; +BACKEND_UID=`stat -c %u $B0/${V0}$cached/$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/$i`; EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID @@ -79,8 +79,8 @@ TEST glusterfs --attribute-timeout=0 --entry-timeout=0 -s $H0 --volfile-id $V0 $ lookup=`ls -l $M0/$i 2>/dev/null` # check if uid/gid on linkfile is created with correct uid/gid -BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/$i`; -BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/$i`; +BACKEND_UID=`stat -c %u $B0/${V0}$cached/$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/$i`; EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID # create hardlinks. Make sure a linkfile gets created @@ -117,8 +117,8 @@ get_hashed_brick link$i cached=$? # check if uid/gid on linkfile is created with correct uid/gid -BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/link$i`; -BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/link$i`; +BACKEND_UID=`stat -c %u $B0/${V0}$cached/link$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/link$i`; EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID @@ -166,8 +166,8 @@ get_hashed_brick user_file$i cached=$? # check if uid/gid on linkfile is created with correct uid/gid -BACKEND_UID=`stat --printf=%u $B0/${V0}$cached/user_file$i`; -BACKEND_GID=`stat --printf=%g $B0/${V0}$cached/user_file$i`; +BACKEND_UID=`stat -c %u $B0/${V0}$cached/user_file$i`; +BACKEND_GID=`stat -c %g $B0/${V0}$cached/user_file$i`; EXPECT "0" uid_gid_compare $NEW_UID $NEW_GID $BACKEND_UID $BACKEND_GID cleanup; diff --git a/tests/bugs/bug-949242.t b/tests/bugs/bug-949242.t index 027c25afd88..c596cf7f25b 100644 --- a/tests/bugs/bug-949242.t +++ b/tests/bugs/bug-949242.t @@ -25,8 +25,8 @@ require_fallocate -l 1m -n $M0/file && rm -f $M0/file # fallocate a file and verify blocks are allocated TEST fallocate -l 1m $M0/file -blksz=`stat --printf=%b $M0/file` -nblks=`stat --printf=%B $M0/file` +blksz=`stat -c %b $M0/file` +nblks=`stat -c %B $M0/file` TEST [ $(($blksz * $nblks)) -eq 1048576 ] TEST unlink $M0/file @@ -35,9 +35,9 @@ TEST unlink $M0/file # change TEST truncate --size=1m $M0/file TEST fallocate -l 2m -n $M0/file -blksz=`stat --printf=%b $M0/file` -nblks=`stat --printf=%B $M0/file` -sz=`stat --printf=%s $M0/file` +blksz=`stat -c %b $M0/file` +nblks=`stat -c %B $M0/file` +sz=`stat -c %s $M0/file` TEST [ $sz -eq 1048576 ] # Note that gluster currently incorporates a hack to limit the number of blocks # reported as allocated to the file by the file size. We have allocated beyond the diff --git a/tests/bugs/bug-963678.t b/tests/bugs/bug-963678.t index ba3d3ae0549..9431010d60d 100644 --- a/tests/bugs/bug-963678.t +++ b/tests/bugs/bug-963678.t @@ -31,12 +31,12 @@ require_fallocate -p -l 512k $M0/file && rm -f $M0/file # allocate some blocks, punch a hole and verify block allocation TEST fallocate -l 1m $M0/file -blksz=`stat --printf=%B $M0/file` -nblks=`stat --printf=%b $M0/file` +blksz=`stat -c %B $M0/file` +nblks=`stat -c %b $M0/file` TEST [ $(($blksz * $nblks)) -ge 1048576 ] TEST fallocate -p -o 512k -l 128k $M0/file -nblks=`stat --printf=%b $M0/file` +nblks=`stat -c %b $M0/file` # allow some room for xattr blocks TEST [ $(($blksz * $nblks)) -lt $((917504 + 16384)) ] TEST unlink $M0/file 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; diff --git a/tests/volume.rc b/tests/volume.rc index 0f47f7e6741..9c0e20970b5 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -313,7 +313,7 @@ function data_written_count { } function has_holes { - if [ $((`stat -c '%b*%B-%s' -- $1`)) -lt 0 ]; + if [ $((`stat -c '%b*%B-%s' $1`)) -lt 0 ]; then echo "1" else |