generic: add OFD lock tests
authorXiong Zhou <xzhou@redhat.com>
Tue, 13 Feb 2018 14:10:26 +0000 (22:10 +0800)
committerEryu Guan <eguan@redhat.com>
Thu, 15 Feb 2018 17:28:32 +0000 (01:28 +0800)
commit4a6d40ad68655bceff5bbd9f460d4672abb6cb0a
tree86013b0614281d6bc9c0967fc9439b16b80663a5
parent03cc97346b1d2ace4c85583764c7f94024155cb1
generic: add OFD lock tests

Test OFD locks. Use fcntl F_OFD_SETLK/F_OFD_GETLK, to verify we are
being given correct advices through getlk by kernel.

The basic idea is one setlk routine setting locks via fcntl *_SETLK,
followed by operations like clone, dup then close fd; another
routine getlk getting locks via fcntl *_GETLK.

Firstly in setlk routine process P0, place a lock L0 on an opened
testfile, then do clone or dup and close relative fd.

In getlk process P2, do fcntl *_GETLK with lock L1 after get
notified by setlk routine.

In the end, getlk routine check the returned struct flock.l_type to
see if the lock mechanism works fine.

Test combainations of:
- shared or exclusive lock
- these locks are conflicting or not
- one OFD lock and one POSIX lock
- that open testfile RDONLY or RDWR
- clone with CLONE_FILES or not
- dup and close newfd

[eguan: made some minor non-functional changes]

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
.gitignore
common/rc
src/Makefile
src/t_ofd_locks.c [new file with mode: 0644]
tests/generic/478 [new file with mode: 0755]
tests/generic/478.out [new file with mode: 0644]
tests/generic/group