aboutsummaryrefslogtreecommitdiff
path: root/libfshelp-tests/README.new_tests
diff options
context:
space:
mode:
authorNeal H Walfield <neal@cs.uml.edu>2019-10-30 00:03:13 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2019-10-30 00:04:40 +0100
commit3a8234d2440a464f5401b3444d454ac913d6b3d6 (patch)
tree409ff15b23279ea508c18fc4d1909da55fc9ca6e /libfshelp-tests/README.new_tests
parent14639382938714f07f76abd3d221c6d472710502 (diff)
downloadhurd-3a8234d2440a464f5401b3444d454ac913d6b3d6.tar.gz
hurd-3a8234d2440a464f5401b3444d454ac913d6b3d6.tar.bz2
hurd-3a8234d2440a464f5401b3444d454ac913d6b3d6.zip
libfshelp-tests: Tests for file record locking
2019-03-04 Svante Signell <svante.signell@gmail.com> * test-*.c: Update code, remove test results. * README.new_tests: New file, summarize new test results. 2019-02-12 Svante Signell <svante.signell@gmail.com> * test-*.c: Update code, add some test results. * Makefile: Remove extra flags. 2019-02-01 Svante Signell <svante.signell@gmail.com> * Update copyright years. 2016-05-23 Svante Signell <svante.signell@gmail.com> * Makefile: Add sub-directory libfshelp-tests. 2018-12-07 Svante Signell <svante.signell@gmail.com> * Update copyright years. * locks.c(cmd_lock): Call fshelp_rlock_tweak() with new last argument rendezvous = MACH_PORT_NULL. 2017-01-05 Svante Signell <svante.signell@gmail.com> * Update copyright years and headers. 2016-12-28 Svante Signell <svante.signell@gmail.com> * Makefile: test-flock.c, test-lockf.c and test-fcntl.c * test-lockf.c: New file * Rename set-flock.c, set-fcntl.c to test-flock.c test-fcntl.c * TODO: Update README 2016-05-23 Svante Signell <svante.signell@gmail.com> * Makefile: Link with pthread, add build of set-flock.c and set-fcntl.c * define temporary CPP_FLAGS until glibc is updated * set-flock.c, set-fcntl.c: New files. * Fix typos in README 2001-04-11 Neal H Walfield <neal@cs.uml.edu> * ChangeLog: New file, mentioning itself in this sentence. * Makefile: New file. * README: Likewise. * fork.c: Likewise. * locks: Likewise. * locks-tests: Likewise. * locks.c: Likewise. * race.c: Likewise.
Diffstat (limited to 'libfshelp-tests/README.new_tests')
-rw-r--r--libfshelp-tests/README.new_tests146
1 files changed, 146 insertions, 0 deletions
diff --git a/libfshelp-tests/README.new_tests b/libfshelp-tests/README.new_tests
new file mode 100644
index 00000000..b31b5034
--- /dev/null
+++ b/libfshelp-tests/README.new_tests
@@ -0,0 +1,146 @@
+File: README.new_tests
+
+C-code:
+=======
+test-fcntl.c
+test-lockf.c
+test-flock.c
+
+Compile:
+========
+gcc -g -Wall -D_FILE_OFFSET_BITS=64 -o test-fcntl test-fcntl.c
+gcc -g -Wall -D_FILE_OFFSET_BITS=64 -o test-lockf test-lockf.c
+gcc -g -Wall -D_FILE_OFFSET_BITS=64 -o test-flock test-flock.c
+
+./test-fcntl
+./test-fcntl: Usage: ./test-fcntl file [flags] [cmd] [len] [sleep_time]
+ file : file name/device name
+ flags : r (O_RDONLY) | w (O_WRONLY) | rw (O_RDWR) : [rw]
+ cmd : g (F_GETLK), s (F_SETLK), sw (F_SETLKW) : [s]
+ lock.l_type : rl (F_RDLCK), wl (F_WRLCK), ul [F_UNLCK] : [ul]
+ lock.l_whence : ss (SEEK_SET), sc (SEEK_CUR), se (SEEK_END) : [ss]
+ lock.l_start : b <number> : [b 0]
+ lock.l_len : l <number> : [l 0]
+ sleep_time : st <number> : [st 10]
+
+./test-lockf
+./test-lockf: Usage: ./test-lockf file [flags] [cmd] [len] [sleep_time]
+ file : file name/device name
+ flags : r (O_RDONLY) | w (O_WRONLY) | rw (O_RDWR) : [w]
+ cmd : x (F_LOCK), xt (F_TLOCK), u (F_ULOCK),
+ t (F_TEST) : [x]
+ len : l <number> : [0]
+ sleep_time : st <number> : [st 10]
+
+./test-flock
+./test-flock: Usage: ./test-flock file [flags] [operation] [sleep_time]
+ file : file name/device name
+ flags : r (O_RDONLY) | w (O_WRONLY) | rw (O_RDWR) : [w]
+ operation : s (LOCK_SH), x (LOCK_EX), u (LOCK_UN),
+ sn (LOCK_SH | LOCK_UN), xn (LOCK_EX | LOCK_UN) : [s]
+ sleep_time : st <number> : [st 10]
+
+Results:
+========
+New version of file_record_lock:
+libdiskfs/file-lock.c(diskfs_S_file_lock): Commented out
+libnetfs/file-lock.c(netfs_S_file_lock): Commented out
+libtrivfs/file-lock.c(trivfs_S_file_lock): TODO: Add+comment out
+libtrivfs/make-peropen.c(trivfs_S_file_lock): FIXME: po->openmodes = O_RDWR;
+if (openstat & (O_RDONLY|O_WRONLY|O_EXEC)) openstat |= O_RDONLY|O_WRONLY;
+
+libfshelp/rlock-tweak.c(fshelp_rlock_tweak): Removed
+if (lock->l_type == F_RDLCK && !(open_mode & O_READ))
+ return EACCES;
+if (lock->l_type == F_WRLCK && !(open_mode & O_WRITE))
+ return EACCES;
+Added:
+/* From POSIX-1003.1: A request for an exclusive lock shall fail if
+ the file descriptor was not opened with write access. */
+if ((cmd == F_SETLK64 || cmd == F_SETLKW64 )
+ && lock->l_type == F_WRLCK && !(open_mode & O_WRITE))
+ return EBADF;
+
+test-fcntl:
+===========
+libdiskfs:
+----------
+
+touch foo
+./test-fcntl foo {r,w} g {rl,wl}
+./test-fcntl foo r {s,sw} wl
+./test-fcntl: fcntl: Bad file descriptor
+./test-fcntl foo r {s,sw} {rl,ul}
+
+T1: T2:
+./test-fcntl foo {r,w} {s,sw} {rl,wl}
+./test-fcntl foo {r,w} {s,sw} {rl,wl}
+
+libnetfs:
+---------
+Not applicable on GNU/Linux?
+
+settrans -c ftp: /hurd/hostmux /hurd/ftpfs /
+Check:
+file ftp:
+ftp:: directory
+ls ftp://ftp.gnu.org/
+less ftp://ftp.gnu.org/README
+
+./test-fcntl ftp://ftp.gnu.org/README r g {rl,wl}
+./test-fcntl ftp://ftp.gnu.org/README w g {rl,wl}
+./test-fcntl: open: Permission denied
+
+./test-fcntl ftp://ftp.gnu.org/README r {s,sw} {rl,ul}
+./test-fcntl ftp://ftp.gnu.org/README r {s,sw} wl
+./test-fcntl: fcntl: Bad file descriptor
+
+settrans -fg ftp:
+rm ftp:
+
+libtrivs:
+---------
+BUG: ./test-fcntl /dev/null r s wl
+GNU/Linux:
+./test-fcntl: fcntl: Bad file descriptor
+
+test-lockf:
+===========
+libdiskfs:
+----------
+touch foo
+./test-lockf foo {r,w} {x,xt,u,t}
+T1, T2:
+./test-lockf foo {r,w} {x,xt,u,t}
+
+libnetfs:
+---------
+
+libtrivfs:
+----------
+
+test-flock:
+===========
+libdiskfs:
+----------
+touch foo
+./test-flock foo {r,w} {s,x,u,sn,xn}
+
+GNU/Linux:
+./test-flock foo r x
+
+GNU/Hurd:
+./test-flock foo r {x,xn}
+./test-flock: flock: Bad file descriptor
+
+T1: ./test-flock foo w s,x
+T2: ./test-flock foo w x (waits for the first lock)
+
+libnetfs:
+---------
+
+libtrivfs:
+----------
+GNU/Hurd
+T1: ./test-flock /dev/null w s,x
+BUG: T2: ./test-flock /dev/null w x (does not wait for the first lock)