diff options
author | Emmanuel Dreyfus <manu@netbsd.org> | 2014-10-02 05:18:20 +0200 |
---|---|---|
committer | Harshavardhana <harsha@harshavardhana.net> | 2014-10-06 20:25:43 -0700 |
commit | 1642ee54cf78bb2d117f7ffb2a180acf12c54ab6 (patch) | |
tree | e665e7ce071e337406c8d432be7e025e3655b0d7 /tests/basic/rpc-coverage.sh | |
parent | 3e7508eafb1955a071da9108dce5ce1cf435f4f3 (diff) |
Regression test portability: rpc-coverage
- pull include.rc when running rpc-coverage.sh to get BSD stat(1)
compatibility.
- fix type in statfs_test and use mode instead of size so that
it cannot pass by chance like it did.
- BSD tail does not support --pid; Avoid that option by making
the test simplier.
- Use a subshell instead of pushd/popd, which seems more reliable.
- Use flock -x instead of flock -e: same result on Linux, compatible
with NetBSD flock.
- when using file descriptors in the shell, avoit too high numbers
otherwise we can easily hit the descriptor limit.
BUG: 1129939
Change-Id: I51bad02a0ef47f20e4a2c49098c1c6701b7e6b09
Signed-off-by: Emmanuel Dreyfus <manu@netbsd.org>
Reviewed-on: http://review.gluster.org/8566
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Harshavardhana <harsha@harshavardhana.net>
Tested-by: Harshavardhana <harsha@harshavardhana.net>
Diffstat (limited to 'tests/basic/rpc-coverage.sh')
-rwxr-xr-x | tests/basic/rpc-coverage.sh | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/tests/basic/rpc-coverage.sh b/tests/basic/rpc-coverage.sh index 1fae111d04b..11d3be66dcb 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 -c -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" } |