Dec 2035 22:08:03 GMT ETag: "11d3be66dcb6caf8d33546f89de161912355e547" #!/bin/bash # This script can be used to provoke 35 fops (if afr is used), # 28 fops (if afr is not used) (-fstat,-readdirp, and lk,xattrop calls) # Pending are 7 procedures. # getspec, fsyncdir, access, fentrylk, fsetxattr, fgetxattr, rchecksum # TODO: add commands which can generate fops for missing fops ## Script tests below File Operations over RPC (when afr is used) # CREATE # ENTRYLK # FINODELK # FLUSH # FSTAT # FSYNC # FTRUNCATE # FXATTROP # GETXATTR # INODELK # LINK # LK # LOOKUP # MKDIR # MKNOD # OPEN # OPENDIR # READ # READDIR # READDIRP # READLINK # RELEASE # RELEASEDIR # REMOVEXATTR # RENAME # RMDIR # SETATTR # SETXATTR # STAT # STATFS # SYMLINK # TRUNCATE # UNLINK # WRITE # XATTROP #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; } function test_mkdir() { mkdir -p $PFX/dir; test $(stat -c '%F' $PFX/dir) == "directory" || fail "mkdir" } function test_create() { : > $PFX/dir/file; test "$(stat -c '%F' $PFX/dir/file)" == "regular empty file" || fail "create" } function test_statfs() { local size; mode=$(stat -c '%a' $PFX/dir/file); test "x$mode" == "x644" || fail "statfs" } function test_open() { exec 4<$PFX/dir/file || fail "open" exec 4>&- || fail "open" } function test_write() { dd if=/dev/zero of=$PFX/dir/file bs=65536 count=16 test $(stat -c '%s' $PFX/dir/file) == 1048576 || fail "write" } function test_read() { local count; count=$(dd if=$PFX/dir/file bs=64k count=16 2>/dev/null | wc -c); test $count == 1048576 || fail "read" } function test_truncate() { truncate -s 512 $PFX/dir/file; test $(stat -c '%s' $PFX/dir/file) == 512 || fail "truncate" truncate -s 0 $PFX/dir/file; test $(stat -c '%s' $PFX/dir/file) == 0 || fail "truncate" } function test_fstat() { local msg; export PFX; echo hooha > $PFX/dir/file sleep 1 msg=$(sh -c 'tail $PFX/dir/file') test "x$msg" == "xhooha" || fail "fstat" } function test_mknod() { mknod -m 0666 $PFX/dir/block b 13 42; test "$(stat -c '%F %a %t %T' $PFX/dir/block)" == "block special file 666 d 2a" \ || fail "mknod for block device" mknod -m 0666 $PFX/dir/char c 13 42; test "$(stat -c '%F %a %t %T' $PFX/dir/char)" == "character special file 666 d 2a" \ || fail "mknod for character device" mknod -m 0666 $PFX/dir/fifo p; test "$(stat -c '%F %a' $PFX/dir/fifo)" == "fifo 666" || \ fail "mknod for fifo" } function test_symlink() { local msg; ( 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); test "x$msg" == "xhooha" || fail "Content match for symlink" } function test_hardlink() { local ino1; local ino2; local nlink1; local nlink2; local msg; ln $PFX/dir/file $PFX/dir/hardlink; ino1=$(stat -c '%i' $PFX/dir/file); nlink1=$(stat -c '%h' $PFX/dir/file); ino2=$(stat -c '%i' $PFX/dir/hardlink); nlink2=$(stat -c '%h' $PFX/dir/hardlink); test $ino1 == $ino2 || fail "Inode comparison for hardlink" test $nlink1 == 2 || fail "Link count for hardlink" test $nlink2 == 2 || fail "Link count for hardlink" msg=$(cat $PFX/dir/hardlink); test "x$msg" == "xhooha" || fail "Content match for hardlinks" } function test_rename() { local ino1; local ino2; local ino3; local msg; #### file ino1=$(stat -c '%i' $PFX/dir/file); mv $PFX/dir/file $PFX/dir/file2 || fail "mv"