diff options
Diffstat (limited to 'tests/basic/rpc-coverage.sh')
| -rwxr-xr-x | tests/basic/rpc-coverage.sh | 58 |
1 files changed, 37 insertions, 21 deletions
diff --git a/tests/basic/rpc-coverage.sh b/tests/basic/rpc-coverage.sh index dc66969d045..6203f0ac7cb 100755 --- a/tests/basic/rpc-coverage.sh +++ b/tests/basic/rpc-coverage.sh @@ -47,6 +47,9 @@ #set -e; set -o pipefail; +# pull compatibility functions (e.g.: stat replacement if not running Linux) +. $(dirname $0)/../include.rc + function fail() { echo "$*: failed."; exit 1; @@ -71,8 +74,8 @@ function test_statfs() { local size; - size=$(stat -f -c '%s' $PFX/dir/file); - test "x$size" != "x0" || fail "statfs" + mode=$(stat -c '%a' $PFX/dir/file); + test "x$mode" == "x644" || fail "statfs" } @@ -85,8 +88,8 @@ function test_open() function test_write() { - dd if=/dev/zero of=$PFX/dir/file bs=65536 count=16 2>/dev/null; - test $(stat -c '%s' $PFX/dir/file) == 1048576 || fail "open" + dd if=/dev/zero of=$PFX/dir/file bs=65536 count=16 + test $(stat -c '%s' $PFX/dir/file) == 1048576 || fail "write" } @@ -114,7 +117,9 @@ function test_fstat() local msg; export PFX; - msg=$(sh -c 'tail -f $PFX/dir/file --pid=$$ & sleep 1 && echo hooha > $PFX/dir/file && sleep 1'); + echo hooha > $PFX/dir/file + sleep 1 + msg=$(sh -c 'tail $PFX/dir/file') test "x$msg" == "xhooha" || fail "fstat" } @@ -139,10 +144,8 @@ function test_symlink() { local msg; - pushd; - cd $PFX/dir; - ln -s file symlink; - popd; + ( cd $PFX/dir && ln -s file symlink; ) + test "$(stat -c '%F' $PFX/dir/symlink)" == "symbolic link" || fail "Creation of symlink" msg=$(cat $PFX/dir/symlink); @@ -355,21 +358,21 @@ function test_utimes() function test_locks() { - exec 200>$PFX/dir/lockfile || fail "exec" + exec 100>$PFX/dir/lockfile || fail "exec" ## exclusive locks test - flock -e 200 || fail "flock -e" - ! flock -n -e $PFX/dir/lockfile -c true || fail "! flock -n -e" + flock -x 100 || fail "flock -x" + ! flock -n -x $PFX/dir/lockfile -c true || fail "! flock -n -x" ! flock -n -s $PFX/dir/lockfile -c true || fail "! flock -n -s" - flock -u 200 || fail "flock -u" + flock -u 100 || fail "flock -u" ## shared locks test - flock -s 200 || fail "flock -s" - ! flock -n -e $PFX/dir/lockfile -c true || fail "! flock -n -e" + flock -s 100 || fail "flock -s" + ! flock -n -x $PFX/dir/lockfile -c true || fail "! flock -n -x" flock -n -s $PFX/dir/lockfile -c true || fail "! flock -n -s" - flock -u 200 || fail "flock -u" + flock -u 100 || fail "flock -u" - exec 200>&- || fail "exec" + exec 100>&- || fail "exec" } @@ -416,9 +419,15 @@ function test_rmdir() rm -rf $PFX || fail "rm -rf" } +function test_statvfs() +{ + df $DIR 2>&1 || fail "df" +} + function run_tests() { + test_statvfs; test_mkdir; test_create; test_statfs; @@ -433,13 +442,15 @@ function run_tests() test_rename; test_chmod; test_chown; - test_utimes; - test_locks; test_readdir; test_setxattr; test_listxattr; test_getxattr; test_removexattr; + if [ "$run_lock_tests" = "1" ]; then + test_locks; + fi + test_utimes; test_unlink; test_rmdir; } @@ -450,14 +461,19 @@ function _init() DIR=$(pwd); } - +run_lock_tests=1 function parse_cmdline() { if [ "x$1" == "x" ] ; then - echo "Usage: $0 /path/mount" + echo "Usage: $0 [--no-locks] /path/mount" exit 1 fi + if [ "$1" == "--no-locks" ] ; then + run_lock_tests=0 + shift + fi + DIR=$1; if [ ! -d "$DIR" ] ; then |
